Hi all,
I'm not sure if this is the right place to raise, as this is an issue in CDK and potentially the ECS API also. I will try to keep both of these separate in my description.
Summary of the issue:
The container instance draining hook Lambda included with aws-ecs' Cluster class currently does not work, as it fails to get the container instance ARN to drain.
The issue with the Lambda code is that it is calling list_container_instances, which does not return the ec2InstanceId property being searched/filtered on. I found it was necessary to follow that call with describe_container_instances . I have attempted a fix with #6864
In testing my fix to that I realised that as soon as an instance is terminated* and enters the Terminating:Wait stage of the ASG lifecycle hook, it disappears from the ECS console and is no longer returned in calls to list_container_instances, meaning looking up its ARN is impossible.
*FWIW I am terminating instances from the console
cluster.addCapacity(). Set the mincapacity to 2. The defaults are fine for optional values.
In the Cloudwatch logs:
Instance i-0aefbc4a591d4ed1c has container instance ARN None
Terminating:Wait stage of the lifecycle hook.This is :bug: Bug Report
Hey there @jakebanks sorry for the delay! Let me take a look.
This looks fixed now actually! I am using 1.31.0 of aws-autoscaling. Thanks for looking.
Instance xxxxxx has container instance ARN arn:aws:ecs:xxxxxxxxxx
Closing the issue as it appears to be fixed.
Most helpful comment
Hey there @jakebanks sorry for the delay! Let me take a look.