Skip to content
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: Replace SecurityGroups with SecurityGroupIds in EC2 resource #450

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

katsuhisa91
Copy link
Contributor

Overview

This PR fixes an issue where specifying the security group name (groupName) in the AWS::EC2::Instance resource along with the subnet parameter causes an error. The security group should be referenced by its ID rather than by its name.

Changes

  • Updated the SecurityGroups parameter to SecurityGroupIds and used Fn::GetAtt to retrieve the security group ID.
  • This change ensures proper association between the subnet and security group, preventing errors during EC2 instance creation.

Background

The AWS EC2 API does not allow the use of groupName (security group name) in combination with subnet. Instead, security groups must be referenced by their ID. This change addresses that limitation by updating the template to use the security group ID.

Testing

The updated template was successfully tested by creating a stack without encountering errors.

- Updated the EC2 instance template to reference security groups by ID instead of name.
- Resolved conflict between subnet and groupName parameters, preventing errors during stack creation.
@ericzbeard ericzbeard merged commit 00c51c8 into aws-cloudformation:main Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants