feat: Add placement group_id support to EC2 launch templates#44097
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
|
✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible. |
4df85d5 to
1a462d4
Compare
Add support for specifying placement groups by ID in EC2 launch templates, providing an alternative to the existing group_name parameter. Changes: - Add group_id field to launch template placement configuration - Implement proper conflict validation between group_name and group_id - Add expand/flatten functions for group_id API mapping - Include comprehensive acceptance test coverage: * Test basic group_id functionality * Test migration from group_name to group_id * Test data source support for group_id - Add documentation for new group_id parameter with conflict notes - Add proper changelog entry file (.changelog/38908.txt) This enables users to reference placement groups by their unique ID rather than name, providing more robust infrastructure as code practices and supporting programmatic placement group management. This is particularly useful for placement groups that are shared through Resource Access Manager (RAM), where cross-account access may provide the group ID but not the name. The implementation maintains full backward compatibility with existing group_name configurations while adding the new group_id option with proper validation to prevent conflicting specifications.
1a462d4 to
638f3a9
Compare
ewbankkit
left a comment
There was a problem hiding this comment.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccEC2LaunchTemplate_basic\|TestAccEC2LaunchTemplate_Placement_\|TestAccEC2LaunchTemplateDataSource_name' PKG=ec2 ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.24.6 test ./internal/service/ec2/... -v -count 1 -parallel 3 -run=TestAccEC2LaunchTemplate_basic\|TestAccEC2LaunchTemplate_Placement_\|TestAccEC2LaunchTemplateDataSource_name -timeout 360m -vet=off
2025/09/02 11:43:13 Creating Terraform AWS Provider (SDKv2-style)...
2025/09/02 11:43:13 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccEC2LaunchTemplateDataSource_name
=== PAUSE TestAccEC2LaunchTemplateDataSource_name
=== RUN TestAccEC2LaunchTemplate_basic
=== PAUSE TestAccEC2LaunchTemplate_basic
=== RUN TestAccEC2LaunchTemplate_Placement_groupID
=== PAUSE TestAccEC2LaunchTemplate_Placement_groupID
=== RUN TestAccEC2LaunchTemplate_Placement_groupNameToGroupID
=== PAUSE TestAccEC2LaunchTemplate_Placement_groupNameToGroupID
=== RUN TestAccEC2LaunchTemplate_Placement_hostResourceGroupARN
=== PAUSE TestAccEC2LaunchTemplate_Placement_hostResourceGroupARN
=== RUN TestAccEC2LaunchTemplate_Placement_partitionNum
=== PAUSE TestAccEC2LaunchTemplate_Placement_partitionNum
=== CONT TestAccEC2LaunchTemplateDataSource_name
=== CONT TestAccEC2LaunchTemplate_Placement_partitionNum
=== CONT TestAccEC2LaunchTemplate_Placement_groupNameToGroupID
--- PASS: TestAccEC2LaunchTemplate_Placement_partitionNum (35.57s)
=== CONT TestAccEC2LaunchTemplate_Placement_hostResourceGroupARN
--- PASS: TestAccEC2LaunchTemplate_Placement_groupNameToGroupID (35.64s)
=== CONT TestAccEC2LaunchTemplate_Placement_groupID
--- PASS: TestAccEC2LaunchTemplate_Placement_groupID (20.29s)
=== CONT TestAccEC2LaunchTemplate_basic
--- PASS: TestAccEC2LaunchTemplate_Placement_hostResourceGroupARN (21.74s)
--- PASS: TestAccEC2LaunchTemplateDataSource_name (69.98s)
--- PASS: TestAccEC2LaunchTemplate_basic (19.65s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 81.488s|
@aljazmbts Thanks for the contribution 🎉 👏. |
|
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
|
This functionality has been released in v6.12.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
|
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. |
Description
Add support for specifying placement groups by ID in EC2 launch templates, providing an alternative to the existing group_name parameter.
Changes:
This enables users to reference placement groups by their unique ID rather than name, providing more robust infrastructure as code practices and supporting programmatic placement group management. This is required for placement groups that are shared through Resource Access Manager (RAM).
The implementation maintains full backward compatibility with existing group_name configurations while adding the new group_id option with proper validation to prevent conflicting specifications.
Rollback Plan
This change adds a new optional parameter (
group_id) with proper conflict validation. If rollback is needed:group_namecontinue to work unchangedgroup_idfield can be removed in a future version without breaking existing infrastructuregroup_idback togroup_nameby updating their configurationNo state migration or data conversion is needed for rollback as this is an additive change.
Changes to Security Controls
No changes to security controls. This change only adds a new optional parameter for specifying placement groups by ID rather than name.
Relations
Closes #38908.
Output from Acceptance Testing