-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Correct capacity reservation target #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Correct capacity reservation target #288
Conversation
################################################################################ | ||
|
||
module "vpc" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved the supporting stuff to the bottom
@@ -123,10 +51,6 @@ module "ec2_complete" { | |||
cpu_core_count = 2 # default 4 | |||
cpu_threads_per_core = 1 # default 2 | |||
|
|||
capacity_reservation_specification = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what the fix enables - users do not need to set this if they are not using capacity reservations
@@ -295,15 +219,13 @@ module "ec2_spot_instance" { | |||
create_spot_instance = true | |||
|
|||
ami = data.aws_ami.amazon_linux.id | |||
instance_type = "c4.4xlarge" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got kids to feed 😅
availability_zone = element(module.vpc.azs, 0) | ||
subnet_id = element(module.vpc.private_subnets, 0) | ||
vpc_security_group_ids = [module.security_group.security_group_id] | ||
placement_group = aws_placement_group.web.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required on this example, looks to be copy+paste from another example
@@ -35,14 +35,15 @@ resource "aws_instance" "this" { | |||
ebs_optimized = var.ebs_optimized | |||
|
|||
dynamic "capacity_reservation_specification" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the issue and it now matches
terraform-aws-ec2-instance/main.tf
Lines 184 to 197 in dbf16a2
dynamic "capacity_reservation_specification" { | |
for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : [] | |
content { | |
capacity_reservation_preference = try(capacity_reservation_specification.value.capacity_reservation_preference, null) | |
dynamic "capacity_reservation_target" { | |
for_each = try([capacity_reservation_specification.value.capacity_reservation_target], []) | |
content { | |
capacity_reservation_id = try(capacity_reservation_target.value.capacity_reservation_id, null) | |
capacity_reservation_resource_group_arn = try(capacity_reservation_target.value.capacity_reservation_resource_group_arn, null) | |
} | |
} | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
### [4.1.4](v4.1.3...v4.1.4) (2022-08-13) ### Bug Fixes * Correct capacity reservation target ([#288](#288)) ([135145e](135145e))
This PR is included in version 4.1.4 🎉 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
capacity_reservation_specification
definitions - one in the instance resource and one in the spot request resource. In the original PR only one of the definition was updated correctly to match the default value type of{}
. This is now synchronized across the two resourcesMotivation and Context
Breaking Changes
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request