ECS fargate service with ALB deployed using CDK

0

This is my first time trying to use CDK to deploy a Fargate service stack with an ALB configured in a separate stack. I tried to follow this example https://github.com/aws-samples/aws-cdk-examples/blob/master/typescript/ecs/cross-stack-load-balancer/split-at-listener.ts

Note: By itself the task definition and the service is getting deployed perfectly, however when I try to add a listener/target group and register the service with the target group then it fails with this error.

Resource handler returned message: "Invalid request provided: UpdateService error: Health check grace period is only valid for services config
ured to use load balancers (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: c49473d9-f5d1-47c2-b113-3
0551d484d3f; Proxy: null)" (RequestToken: e68aef9e-ed8f-8d28-d29c-fec52c7339e0, HandlerErrorCode: InvalidRequest)
asked 2 years ago1995 views
1 Answer
0

Can you check whether the service you created is using load balancing or not?

You cannot update an ECS service whether or not to use load balancing.

If you want to change it (i.e. from non-load balancing to load balancing or vice-versa), you need to re-create the service.

https://docs.aws.amazon.com/AmazonECS/latest/userguide/service-load-balancing.html#load-balancing-considerations

You cannot add, remove, or change the load balancer configuration of an existing service.

answered 2 years ago
  • Thanks for your response.. Yeah, so I have been adding resources in this stack one at a time. I started with taskDefinition, then FargateService (started with just 1 desired count) with appropriate taskRole and executionRole. Once this deployed successfully I started adding ALB/TG connection. Basically I imported ALB and added listener/targetGroup... I guess it does not like this approach. Based on your response I thought let me delete the stack and recreate with all the resources that I need, and it appears to help.. Now I am further along.. the necessary plumbing between ALB/Listener/TG/Service seems to have been made.. Now the failure is that TargetGroup does not have healthy targets. I wonder if its the security group issue.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions