@@ -73,6 +73,14 @@ resource "aws_network_interface" "this" {
73
73
subnet_id = element (module. vpc . private_subnets , 0 )
74
74
}
75
75
76
+ resource "aws_ec2_capacity_reservation" "open" {
77
+ instance_type = " t3.micro"
78
+ instance_platform = " Linux/UNIX"
79
+ availability_zone = " ${ local . region } a"
80
+ instance_count = 1
81
+ instance_match_criteria = " open"
82
+ }
83
+
76
84
resource "aws_ec2_capacity_reservation" "targeted" {
77
85
instance_type = " t3.micro"
78
86
instance_platform = " Linux/UNIX"
@@ -81,9 +89,9 @@ resource "aws_ec2_capacity_reservation" "targeted" {
81
89
instance_match_criteria = " targeted"
82
90
}
83
91
84
- # ################################################################################
85
- # # EC2 Module
86
- # ################################################################################
92
+ # # # ###############################################################################
93
+ # # # EC2 Module
94
+ # # # ###############################################################################
87
95
88
96
module "ec2_disabled" {
89
97
source = " ../../"
@@ -341,16 +349,36 @@ module "ec2_spot_instance" {
341
349
# EC2 Module - Capacity Reservation
342
350
# ###############################################################################
343
351
344
- module "ec2_capacity_reservation " {
352
+ module "ec2_open_capacity_reservation " {
345
353
source = " ../../"
346
354
347
- name = " ${ local . name } -capacity-reservation"
355
+ name = " ${ local . name } -open- capacity-reservation"
348
356
349
357
ami = data. aws_ami . amazon_linux . id
350
358
instance_type = " t3.micro"
351
359
subnet_id = element (module. vpc . private_subnets , 0 )
352
360
vpc_security_group_ids = [module . security_group . security_group_id ]
353
- associate_public_ip_address = true
361
+ associate_public_ip_address = false
362
+
363
+ capacity_reservation_specification = {
364
+ capacity_reservation_target = {
365
+ capacity_reservation_id = aws_ec2_capacity_reservation.open.id
366
+ }
367
+ }
368
+
369
+ tags = local. tags
370
+ }
371
+
372
+ module "ec2_targeted_capacity_reservation" {
373
+ source = " ../../"
374
+
375
+ name = " ${ local . name } -targeted-capacity-reservation"
376
+
377
+ ami = data. aws_ami . amazon_linux . id
378
+ instance_type = " t3.micro"
379
+ subnet_id = element (module. vpc . private_subnets , 0 )
380
+ vpc_security_group_ids = [module . security_group . security_group_id ]
381
+ associate_public_ip_address = false
354
382
355
383
capacity_reservation_specification = {
356
384
capacity_reservation_target = {
0 commit comments