Search code examples
c#amazon-web-servicesaws-cdk.net-8.0aws-fargate

AWS CDK for .NET Core hangs at "ApplicationLoadBalancedFargateService" Task


I have an ASP.NET Core 8 Web API project that has this structure:

.sln
 |_ Api.csproj
 |_ SharedLibrary.csproj
 |_ Dockerfile

Api.csproj references SharedLibrary.csproj. I am able to build the docker image and run it locally on my docker desktop.

I added the following fargate deployment codeblock to my CDK stack:

new ApplicationLoadBalancedFargateService(this, "docker-tag", new ApplicationLoadBalancedFargateServiceProps
{
    Cluster = cluster,
    DesiredCount = 1,
    TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions
    {
        Image = ContainerImage.FromAsset("../../src/"),
        ContainerPort = 8080
    },
    MemoryLimitMiB = 512,
    PublicLoadBalancer = false
});

While executing cdk deploy , the terminal just stays blank without giving any output. I tried cdk deploy --verbose and it shows some initial outputs that are not related to the Fargate task and then hangs there.

I even tried giving the absolute path to my Dockerfile but the result was same.

I would really appreciate if someone has a clue what might be happening.

The cdk deploy works fine if I changed

Image = ContainerImage.FromAsset("../../src/")

to

Image= ContainerImage.FromRegistry("amazon/amazon-ecs-sample")

Solution

  • Found the issue after breaking my head for so many days. I had my docker file at the root level of the solution. This caused the CDK assets to be copied during docker build. Added the CDK folder to docker ignore and it worked. Very disappointing that cdk deploy doesn't give any error output that would help troubleshoot the issue.