-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Labels
@aws-cdk/aws-ecsRelated to Amazon Elastic ContainerRelated to Amazon Elastic Container@aws-cdk/aws-elasticloadbalancingRelated to Amazon Elastic Load BalancingRelated to Amazon Elastic Load Balancinggood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.md
Description
22/26 | 10:15:33 | CREATE_FAILED | AWS::ECS::Service | greeting-service/Service (greetingserviceService8DA58640) The target group with targetGroupArn arn:aws:elasticloadbalancing:us-east-1:209640446841:targetgroup/greet-inter-7A1DWCFAH8FU/c4bab708f6cad935 does not have an associated load balancer. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: f6e72ff4-e756-11e8-afbf-dd214588018c)
When creating a service and adding it to a load balancer the CloudFormation template fails to deploy with the above error. Example code:
const greeterService = new ecs.Ec2Service(this, 'greeter-service', {
cluster: cluster,
desiredCount: 2,
taskDefinition: greeterTaskDefinition
});
// Internet facing load balancer for the frontend services
const externalLB = new elbv2.ApplicationLoadBalancer(this, 'external', {
vpc: vpc,
internetFacing: true
});
const externalListener = externalLB.addListener('PublicListener', { port: 80, open: true });
externalListener.addTargets('greeter', {
port: 80,
targets: [greeterService]
});
This is probably happening because the AWS::ECS::Service
resource needs a DependsOn
to the AWS::ElasticLoadBalancingV2::ListenerRule
resource. Otherwise it is a race condition that causes a failure if the service resource creation starts before the listener rule is ready.
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-ecsRelated to Amazon Elastic ContainerRelated to Amazon Elastic Container@aws-cdk/aws-elasticloadbalancingRelated to Amazon Elastic Load BalancingRelated to Amazon Elastic Load Balancinggood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.md