Skip to content

EC2: Security Groups lookup by Owner #30331

@eschirle

Description

@eschirle

Describe the feature

SecurityGroup.fromLookupByName() provides an option for looking up a security group by name - but this fails if multiple SGs are found with the provided name.

This feature is for the ability to filter security groups by Owner as well.

Use Case

I have a use case where I'd like to use a Baseline SecurityGroup for Lambda Functions that are a part of a custom construct to avoid creating a new SG and using up more Hyperplane ENIs. I can lookup by name "BaselineSecurityGroup", but my VPC is shared across multiple micro accounts, and so multiple SecurityGroups are returned.

This feature would include the option to filter SecurityGroups by SecurityGroupName and Owner, so that I can grab the SG when there are multiple with the same name in a single VPC.

Proposed Solution

Either adding an optional owner input to fromLookupByName or add a new method fromLookupByNameAndOwner in security-group.ts

public static fromLookupByName(scope: Construct, id: string, securityGroupName: string, vpc: IVpc, owner?: string) { return this.fromLookupAttributes(scope, id, { securityGroupName, vpc, owner }); }

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.142.0

Environment details (OS name and version, etc.)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute Cloudeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions