fix(ec2_instance): adding placement_group_id to aws_instance resource for shared placement groups from different account #38527
+77
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently when sharing a placement group to another AWS account, and trying to launch EC2s via
aws_instance
or an ASG with a launch template with the placement group name provided, I ran into the following error:I could create manually in the UI using the same shared placement group causing the error, and after opening a support request it was confirmed from AWS that referencing the placement group by name is only possible when used in the account that created the placement group.
A simple cut down example of how I encountered it is below:
I have looked through the provider code and can see it only references by name, and have made this PR that should resolve it for the
aws_instance
resource use case.However the AWS Go SDK does not actually support the placement group ID field in all places where it would be needed (ie launch templates, spot requests) so it is not as simple or easy as the small changes I've made here.
vs
I have left a commented section in this PR where the error happens in a spot request within this single resource.
It would be great if it could be merged with just this small change and adding
instance_market_options
to theConflictsWith
to protect against any errors until the AWS Go SDK version gets bumped/supports it for all the other resources.Closes #38908