1 Answer
- Newest
- Most votes
- Most comments
2
Hi,
Can you try to adapt your syntax to the one below ?
This is working
const mySG = new ec2.SecurityGroup(this, `${stack}-security-group`, {
vpc: vpc,
allowAllOutbound: true,
description: 'CDK Security Group'
});
mySG.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(22), 'SSH frm anywhere');
mySG.addIngressRule(ec2.Peer.ipv4('10.200.0.0/24'), ec2.Port.tcp(5439), 'Redshift Ingress1');
mySG.addIngressRule(ec2.Peer.ipv4('10.0.0.0/24'), ec2.Port.tcp(5439), 'Redshift Ingress2');
Best,
Didier
Relevant content
- asked 4 years ago
- AWS OFFICIALUpdated 3 years ago
You should not permit tcp/22 (SSH) traffic from 0.0.0.0/0 (or ::0/0). SSH and RDP (Remote Desktop) are among the most popular targets for casual amateur hackers and professional cybercriminals alike. If Security Hub is configured, it will also flag this as a high-severity risk: https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-13 for SSH and https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-14 for RDP.
It turns out the egress definition was inline in AWS::EC2::SecurityGroup, instead of as a separate AWS::EC2::SecurityGroupIngress / Egress resources, so both my example and yours work. :). I second the idea that allow 0.0.0.0/0 is a generally a bad idea