Stuck Deployment Issue with Fargate Service using AWS CDK

0

Creating my 1st Fargate service using the AWS CDK (Java). I have pushed container images to an ECR repository named "ers" and created a Fargate service. "cdk synth" command compiles with No errors. "cdk deploy" deployment process gets stuck at the following point: UPDATE_IN_PROGRESS | AWS::ECS::Service | MyFargateService/Service/Service

Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated. Thank you!

Here is CdkStack.java class that defines the Fargate service:

public class CdkStack extends Stack { public CdkStack(final Construct scope, final String id) { this(scope, id, null); }

public CdkStack(final Construct scope, final String id, final StackProps props) {
    super(scope, id, props);

    Vpc vpc = Vpc.Builder.create(this, "MyVpc")
            .maxAzs(3) // Default is all AZs in region
            .build();

    Cluster cluster = Cluster.Builder.create(this, "MyCluster")
            .vpc(vpc).build();

    // Create a load-balanced Fargate service and make it public
    ApplicationLoadBalancedFargateService.Builder.create(this, "MyFargateService")
            .cluster(cluster) // Required
            .cpu(512) // Default is 256
            .desiredCount(6) // Default is 1
            .taskImageOptions(
                    ApplicationLoadBalancedTaskImageOptions.builder()
                            .image(ContainerImage.fromEcrRepository(
                                    Repository.fromRepositoryName(this, "EcrRepository", "ers"),
                                    "ingest-api"))
                            .build())
            .memoryLimitMiB(2048) // Default is 512
            .publicLoadBalancer(true) // Default is true
            .build();
}

}

2 Answers
0

Under tasks, change the filter to stopped tasks. See if there are any recent stopped tasks and open the logs.

The logs should help figure out the issue

profile picture
EXPERT
answered 9 months ago
0

@katya I had the same exact problem, though using Javascript. Came looking for answers, but ultimately found the problem.

The ECS creation was getting hung up because it was trying to do a "health check". This is normal even though you can override the behavior in CDK, I could not find a way to ignore it altogether.

I had to ultimately combine the Temporal Worker, with a server that listened to port 80 for the health check ping. As long as there is an HTTP server on your ECS container that responds with a 200-code to the healthcheck, the cdk deploy will eventually succeed.

I ended up combining the 2 "servers" together into one, so that if the worker goes offline, the ECS healthcheck fails and it will re-create the Container.

I know this is months later, but hopefully it helps the next person who has this problem

answered 6 days ago

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