-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(ecs): allow adding multiple security groups when creating an ecs service #3985
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
Conversation
Pull Request Checklist
|
|
Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged. |
660241f to
97983e0
Compare
97983e0 to
355e6f1
Compare
|
@pkandasamy91 Do you think this can make it in |
|
Hey @pkandasamy91 - ECS is a stable module, we can't introduce breaking changes. |
eladb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking changes are not allowed in stable modules unless they are bugs that were unusable.
|
@eladb I understand that this is a breaking change, but cloudformation expects list of SGs, not a single SG. We have some production ECS Services that require multiple SGs, but we don't have ability to create custom SGs (due to DevOps team policy) and we can only use pre-created SGs. We are currently manually updating CFN with additional SGs after initial IaC push with cdk, which is far from ideal. Any help is much appreciated. 👍 |
|
The solution here is very simple: introduce a new property, |
|
@robertd I think escape hatches are exactly what you need for this case - no need to manually edit the CloudFormation template. |
|
@skinny85 I've tried different override before unsuccessfully, but this one seemed to work just fine. Thanks. 👍 My initial try: const resource = ecsService.node.findChild("Service") as ecs.CfnService;
resource.networkConfiguration.awsvpcConfiguration.securityGroups = [ "sg-12345", "sg-54321"];Working example: const cfnService = ecsService.node.findChild("Service") as ecs.CfnService;
//Inject cfn override for multiple SGs
cfnService.addOverride("Properties.NetworkConfiguration.AwsvpcConfiguration.SecurityGroups", [
secGroupA.securityGroupId,
secGroupB.securityGroupId
]);Output CFN: |
@skinny85 I can give it a try implementing this, but I'm more in favor of setting this straight, rather than adding an additional parameter. I understand the implications downstream, but users would only have to add extra brackets (AFAIK). Anyway, let's say we do go this route. Do we mark securityGroups as deprecated then? Talking off the top of my head... I also wonder if implementation would get hairy since we would end up having to deal with |
|
Yes, we should mark |
|
Thanks @eladb ... I'll update this PR accordingly. edit: I'll try 😄 |
|
I've tried few implementations but I'm not satisfied with any of them. 😞 Current implementation expects a single // fargate-service.ts & ec2-service.ts
this.configureAwsVpcNetworking(props.cluster.vpc, props.assignPublicIp, props.vpcSubnets, props.securityGroup);That means that I just can't find clean way to do it and add deprecated warning because any implementation will require post v2.0.0 cleanup of dead code logic mentioned above. Perhaps we should hold off on this PR until #3398 (v2.0.0)? After all it's only a few weeks away and I already have workaround in place. Any thoughts? |
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
355e6f1 to
10b73b5
Compare
is there any way I can just add the additional security group instead of replacing it . my problem is the CDK construct ecsPatterns.ApplicationLoadBalancedEc2Service or ecsPatterns.ApplicationLoadBalancedFargateService add some lb security group on the fly and I don't want to touch them , instead I want to add my security group to it . |
|
@robertd this looks great, one minor suggestion that I have is, why don't we keep the logic for a single security group as well as separate the logic for a single security group vs an array of security groups. I have an example that I built for the event targets, but could be applied to this service as well. It should explain what I mean above: https://github.com/pkandasamy91/aws-cdk/pull/2/files#diff-ff9924269c86d48cca4fcca9e89bbd73R89-R100 |
10b73b5 to
0a5cf75
Compare
|
@pkandasamy91 Please review now and let me know what you think. I'm still unsure where the logic for creating security group if not provided should go. Please advise. |
60b75f9 to
ddba56a
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
ddba56a to
9b626e8
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Hi @pkandasamy91. Did you get a chance to review this? |
9b626e8 to
53b70e8
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
53b70e8 to
7acced6
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
I'm closing this PR and resolved the conflicts in #7813! We'll track the changes there, thanks for the contribution 😊 |
|
Yay!!! Glad to see this getting picked up in #7813. |
|
@efekarakus Sorry for not turning on |
|
No problem! thanks a lot for all your work :D |
Closes #2540
@pkandasamy91 @rix0rrr please review.
This PR will allow users to add multiple security groups when creating ECS service (ec2 or Fargate). Currently only single SG can be added to an ECS service while CFN expects list of SGs. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-service-awsvpcconfiguration.html
BREAKING CHANGES:
securityGroup: ISecurityGroupreplaced bysecurityGroups: ISecurityGroup[]whencreating ECS service (ec2 or Fargate) in @aws-cdk/aws-ecs
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license