Get default security group from VPC
See original GitHub issueI would like to export the default security group id from a VPC I create. In CloudFormation I would reference the VPC return value of DefaultSecurityGroup
, but how would I accomplish the same using the CDK?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Default and custom security groups - AWS Documentation
Your AWS account automatically has a default security group for the default VPC in each Region. If you don't specify a security group...
Read more >AWS CloudFormation: VPC default security group - Server Fault
When a VPC gets created (whether manually though the GUI, by cloudformation, or any other means), AWS creates a default security group with...
Read more >VPC default security groups restrict all traffic - Datadog Docs
A VPC comes with a default security group whose initial settings deny all inbound traffic, allow all outbound traffic, and allow all traffic...
Read more >Ensure the default security group of every VPC restricts all traffic
A VPC comes with a default security group whose initial settings deny all inbound traffic, allow all outbound traffic, and allow all traffic...
Read more >Default Security Groups In Use | Trend Micro
04 Click inside the Filter instances box located under the console top menu, choose Security group name, type default, then press Enter. This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just about to (I think) bump into this. One use case I can see is that the CIS security benchmark for AWS dictates that all default security groups should restrict all traffic (control 4.3 - https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-cis-controls.html#cis-4.3-remediation). To comply with that, it would be nice to configure the default security group as part of the CDK template.
I’ll do some reading and find out whether (a) this is already possible as @rix0rr says, or (b) needs to be added. Had to do something similar to retrieve the default IGW id, so hopefully isn’t too dissimilar.
@shearn89 & @AaronFinn95: FYI- I ran into this issue yesterday because of the same use case and solved it by wrapping the
Vpc
class and adding two custom resources that revoke the default security group’s ingress and egress rules. (As a bonus they are also restored when deleting the construct, so that it nicely rolls back in case a stack deployment fails.)