aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

Security Groups should have `withoutModifications()` like Roles do.

Open CONJAUMCGCG opened this issue 6 years ago • 4 comments

High level constructs force broadening of the security group rules and IAM role policies even if I provide security group or IAM roles with enough permissions , CDK still tries to broaden it.

In the example below it tries to broaden ingress to 0.0.0.0/80

Reproduction Steps

  const alb_sec_group=new ec2.SecurityGroup(this,"AlbSecGroup",{vpc:props.vpc_from_vpc_stack,allowAllOutbound:true,securityGroupName: "-alb-sg",description:"security group for ALB"})

  const http_port=ec2.Port.tcp(80)
  const https_port=ec2.Port.tcp(443)
  const from_cidr=ec2.Peer.ipv4('10.0.0.0/8')

  this.alb=new elb.ApplicationLoadBalancer(this, "ALB",{
    loadBalancerName:"lb_name",
    vpc: props.vpc_from_vpc_stack,
    vpcSubnets:{subnets:[private_us_west_1a,private_us_west_1b]},
    securityGroup:alb_sec_group,
     internetFacing:false 
  })

Error Log

Environment

  • CLI Version : 1.39.0
  • Framework Version:
  • OS : MacOs
  • Language : TypeScript

Other


This is :bug: Bug Report

CONJAUMCGCG avatar May 22 '20 18:05 CONJAUMCGCG

True. Detecting this requires calculation that I'm not sure we're prepared to do, definitely not for IAM.

The correct solution in this case (I think) is to pass an immutable copy of the Security Group. You can already do this for Roles, we should also add it for Security Groups.

rix0rrr avatar May 27 '20 07:05 rix0rrr

@rix0rrr Thank you.Will use withoutPolicyUpdates() for IAM Roles. Currently there is a flag to make security group immutable if it is imported security group. So for security groups created within CDK withoutModifications() is under development ?

CONJAUMCGCG avatar May 27 '20 16:05 CONJAUMCGCG

Sorry for the long response time @CONJAUMCGCG, I can confirm that this is still on our TODO list

peterwoodworth avatar Apr 16 '21 17:04 peterwoodworth

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

github-actions[bot] avatar Jun 17 '22 16:06 github-actions[bot]