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

[AWS::EC2::SecurityGroup] - [BUG] - CFN prevents creating Security Groups (SGs) with the same name in different accounts within a shared VPC #2255

Open
harshitjain99 opened this issue Feb 9, 2025 · 0 comments
Labels

Comments

@harshitjain99
Copy link

Name of the resource

AWS::EC2::SecurityGroup

Resource Name

No response

Issue Description

CloudFormation Incorrectly preventing the creation of SG. CFN prevents creating Security Groups (SGs) with the same name in different accounts within a shared VPC when using CloudFormation (CFN). While this is possible manually, attempting it via CloudFormation fails if the SG is created in the participant account first, followed by the owner account.

Expected Behavior

Creating Security Groups (SGs) with the same name in different accounts within a shared VPC should be allowed via CFN.

Observed Behavior

CloudFormation performs a lookup based on the Security Group name. In shared VPC scenarios, the VPC owner account can see all Security Groups across accounts, while participant accounts only see their own.

Test Cases

Replication Notes

  1. Create a shared VPC using RAM, here you will going to share a VPC and Subnets from management account to member account.
  2. Verify you are able to see management account VPC in member account
  3. Now create the SG in member account first

Resources:
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow http to client host
GroupName: 'my-security-group'
VpcId: 'vpc-xxx'

This will be created successfully

  1. Now create the same SG in management account

It will fail, Failed with an error - Resource handler returned message: "Security Group with my-security-group already exists" (RequestToken: xxx , HandlerErrorCode: AlreadyExists)

  1. However creating the SG in management account first followed by member account works fine.

Other Details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant