aws-samples / aws-cdk-examples

Example projects using the AWS CDK
Apache License 2.0
5.05k stars 2.13k forks source link

(ecs): ecs-service-with-advanced-alb-config example does not work #585

Open anggras opened 2 years ago

anggras commented 2 years ago

What is the problem?

Upon cdk deploy, the ECS service stuck and unable to proceed with message:

service XXXXX was unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster. For more information, see the Troubleshooting section.

Reproduction Steps

  1. Clone the ecs-service-with-advanced-alb-config example
  2. Install the requirements
  3. Run cdk deploy

What did you expect to happen?

The sample ECS service should be deployed successfully

What actually happened?

The deployment is stuck and unable to complete. The ECS service event console shows the following message:

service XXXXX was unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster. For more information, see the Troubleshooting section.

CDK CLI Version

2.3.0 (build beaa5b2)

Framework Version

No response

Node.js Version

16.13.1

OS

macOS

Language

Python

Language Version

No response

Other information

No response

its-mirus-lu commented 2 years ago

There's another issue with the example... it's attempting to use instance type m5.micro (https://github.com/aws-samples/aws-cdk-examples/blob/752df6302e534a7df22a809536c588deaf444c4d/python/ecs/ecs-service-with-advanced-alb-config/app.py#L26) when there isn't an instance size 'micro' for family m5: https://aws.amazon.com/ec2/instance-types/m5/

its-mirus-lu commented 2 years ago

This error is also coming up... it may have to do with how the name of the resource is interpolated as a concatenation of the stack and resource name: The specified capacity provider name is invalid. Up to 255 characters are allowed, including letters (upper and lowercase), numbers, underscores, and hyphens. The name cannot be prefixed with "aws", "ecs", or "fargate". Specify a valid name and try again.

its-mirus-lu commented 2 years ago

With respect to @anggras' original error, I was not able to reproduce the error message: "service XXXXX was unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster. For more information, see the Troubleshooting section."

However, I did discover that an incorrect instance type was specified for the autoscaling group definition (m5.micro doesn't exist). The stack wouldn't synth because the ecs autoscaling group name did not meet the name requirements. I'll create a new issue since these issues don't directly address OP's issue.

its-mirus-lu commented 2 years ago

The fix for this is in PR #626