Frank Mancini
Frank Mancini

Reputation: 157

AWS CDK and creating ECS/Fargate Service on existing ALB. Use existing listener?

So, I've been pulling out my hair on this issue.

I'm trying to create a new Service that's based on an existing ALB and listener that uses TLS/443

I'm using the CDK Python.

I'm doing a

service = ecs_patterns.ApplicationLoadBalancedFargateService(
  self, "a-service",
...

load_balancer=existing_lb

)

putting in all my parameters..... Everytime I do this, it tries to create a new listener on port 80. Even if I try to select my existing listener which is on 443, it errors out and says that existing listener exists and it errors out.

Any thoughts on how to do this on against an existing SSL listener?

Upvotes: 3

Views: 2500

Answers (3)

rikusv
rikusv

Reputation: 666

You may not be able to do it using the ECS patterns package, but you should be able to do it using the ECS and Elastic Load Balancer V2 packages. I think you should be able to import either the listener or a target group, and then add your service to that. See https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_elasticloadbalancingv2/ApplicationListener.html#aws_cdk.aws_elasticloadbalancingv2.ApplicationListener.from_application_listener_attributes

Upvotes: 0

Frank Mancini
Frank Mancini

Reputation: 157

I checked https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_ecs_patterns/ApplicationLoadBalancedFargateService.html

There is nothing in there that you would point to an existing listener.

there is listener, but then you need to specify the domain and a bunch of other things that aren't relevant...

and when I did put the listener in, it said, that the port was busy...

So i guess there is no way to create a Fargate Service with an existing ALB and existing listener

Upvotes: 0

OllieB
OllieB

Reputation: 81

If you are talking about an existing resource within AWS you need to set a variable as the listener ARN and then use ApplicationListenerAttributes you should then be able use the load balancer like you would if you were creating a new one in CDK

Upvotes: 1

Related Questions