Skip to content
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

ApplicationLoadBalancedEc2Service allows 0.0.0.0/0 for listenerPort, and no way to remove it #8342

Closed
szurgotc opened this issue Jun 3, 2020 · 6 comments
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@szurgotc
Copy link

szurgotc commented Jun 3, 2020

When creating an ApplicationLoadBalancedEc2Service, the resulting Security Group allows 0.0.0.0/0 access for the specified listener port and there is no way to remove it. This happens even if you provide an ApplicationLoadBalancer directly.

It appears to be related to the fact that you can't set "open" on the listener created: https://github.com/aws/aws-cdk/blob/v1.42.1/packages/%40aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts#L186-L188

Reproduction Steps

Create an ApplicationLoadBalancedEC2Service

        this.service = new ApplicationLoadBalancedEc2Service(this, 'Service',{
            cluster: this.cluster.cluster,
            cpu: 512,
            taskDefinition: ec2TaskDefinition,
            listenerPort: 443,
            loadBalancer: webLoadBalancer,
            publicLoadBalancer: true,
            domainName: props.dnsName,
            domainZone:
                HostedZone.fromHostedZoneAttributes(this, 'HostedZone', {
                    hostedZoneId: props.hostedZoneId,
                    zoneName: props.dnsName
                })
        });

View the security group after synthesize.

Error Log

No error log.

Environment

  • 1.32.2 (but this code is still present in the latest code)
  • v12.16.3
  • All
  • All

Other

This should be called out in the documentation.

Also, there should be a way to specify that the listenerPort in the construct not include 0.0.0.0/0 so that it can be specified directly.

This is 🐛 Bug Report

@szurgotc szurgotc added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 3, 2020
@SomayaB SomayaB added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Jun 5, 2020
@rix0rrr rix0rrr added @aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-ecs-patterns Related to ecs-patterns library p1 and removed @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 labels Jun 8, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 8, 2020

As a workaround, it's pretty trivial to recreate what the ApplicationLoadBalancedEc2Service does for you, which gives you more control.

@justin8
Copy link
Contributor

justin8 commented Jun 9, 2020

Is recreating a construct from scratch really a workaround?

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jun 12, 2020
@rix0rrr rix0rrr added the effort/small Small work item – less than a day of effort label Aug 12, 2020
@flemjame-at-amazon
Copy link
Contributor

Fixed by #9433

@metametadata
Copy link

@justin8 I think it's a good idea in a long term. Now I really understand and control all the moving parts, don't rely on surprising defaults and don't need to wait for tickets such as the current one or #6210 to be fixed.

Can't say it was a walk in the park to migrate away from ecs-patterns though, mainly because it took me some time to figure out how to set ECS service as an ALB target.

@SomayaB
Copy link
Contributor

SomayaB commented Oct 21, 2020

Closing this issue since it seems to have been fixed by #9433. Feel free to reopen.

@SomayaB SomayaB closed this as completed Oct 21, 2020
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

No branches or pull requests

6 participants