container-instance-draining
edispark/container-instance-draining/ecs
Automates Container Instance Draining in Amazon ECS by removing tasks from an instance before scaling down a cluster with Auto Scaling Groups.
ECS container instance draining on lifecycle events  !CI Overview Automates Container Instance Draining in Amazon ECS by removing tasks from an instance before scaling down a cluster with Auto Scaling Groups. Heavily inspired by this blog post from AWS. Lambda source code taken from and terraform inspired by the CloudFormation stack from Amazon available here. It works by consuming lifecyle events from an autoscaling group. When an autoscaling:EC2_INSTANCE_TERMINATING event happens for the specified ASG it is placed on an SNS topic which in turn triggers lambda that will drain the tasks first from the ECS instance and then terminate the instance once the number of tasks on the instance become zero. !Architecture Usage ``hcl data "aws_
| Name | Type | Description | Default |
|---|---|---|---|
| region | string | AWS Region for ECS cluster | required |
| ecs_cluster_name | string | Specifies the ECS Cluster Name with which the resources would be associated | required |
| ecs_cluster_arn | string | Specifies the ECS Cluster ARN with which the resources would be associated | required |
| autoscaling_group_arn | string | The name of the Auto Scaling group to which you want to assign the lifecycle hoo | required |
| autoscaling_group_name | string | The name of the Auto Scaling group to which you want to assign the lifecycle hoo | required |
| tags | map(string) | Additional tags (_e.g._ { BusinessUnit : ABC }) | {} |
sns_topic_arn — Topic used by ASG to send notifications when instance state is changing