On Nov 8, 2022, You can now share Amazon EC2 placement groups across multiple AWS accounts using AWS Resource Access Manager (RAM). When a placement group is shared, instances launched by one AWS account can utilize a placement group created by another account.
The current terraform implementation of aws_instance.placement_group doesn't support this feature.
Introduce placement_group_id that support both non-shared or shared cases and make it conflict to placement_group
Errors Log
case 1: using placement_group="shared-placement-group-name"
An error occurred (InvalidPlacementGroup.Unknown) when calling the RunInstances operation:
The placement group 'shared_cluster-placement-group' is unknown.
case 2: using placement_group="pg-xxxxxxxxxxxx"
Error: creating EC2 Instance: operation error EC2: RunInstances, https response error StatusCode: 400, RequestID: xxxxx-xxxx-xxxx-xxxx, api error InvalidPlacementGroup.Unknown:
The placement group 'pg-xxxxxxxxxxxx' is unknown.
case 3. using placement_group="GroupId=pg-xxxxxxxxxxxx"
Error: creating EC2 Instance: operation error EC2: RunInstances, https response error StatusCode: 400, RequestID: xxxxx-xxxx-xxxx-xxxx, api error InvalidPlacementGroup.Unknown:
The placement group 'GroupId=pg-xxxxxxxxxxx' is unknown
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Description
On Nov 8, 2022, You can now share Amazon EC2 placement groups across multiple AWS accounts using AWS Resource Access Manager (RAM). When a placement group is shared, instances launched by one AWS account can utilize a placement group created by another account.
The current terraform implementation of
aws_instance.placement_group
doesn't support this feature.Affected Resource(s) and/or Data Source(s)
Potential Terraform Configuration
References
To launch EC2 instance with shared cluster placement group
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/share-placement-group.html
The existing terraform implementation assign
placement_group
toPlacement.GroupName
while a shared placement group has to assign toGroupId
.https://github.com/hashicorp/terraform-provider-aws/blob/a0609b9810341fe94a3dd0b5f14aed30973ba06c/internal/service/ec2/ec2_instance.go#L2988-L2989
Potential Fix
Introduce
placement_group_id
that support both non-shared or shared cases and make it conflict toplacement_group
Errors Log
case 1: using
placement_group="shared-placement-group-name"
case 2: using
placement_group="pg-xxxxxxxxxxxx"
case 3. using
placement_group="GroupId=pg-xxxxxxxxxxxx"
Relevant PR
38527
Would you like to implement a fix?
No