I was learning about lifecycle hooks recently. Before I added my own, I thought I'd do some research in the lifecycle hooks available. I was hoping to find a simple terraform module lambda for ECS. After some searching, I curated this list and thought "Why not another awesome list?" And the list was born.
Feel free to contribute.
- aws-samples/ecs-cid-sample - Drain using cloudwatch event, sns, and python lambda. Deploy with cloudformation.
- getsocial-rnd/ecs-drain-lambda - Drain using cloudwatch event and golang lambda. Deploy with sls.
- terraform-community-modules/tf_aws_ecs_instance_draining_on_scale_in
- ktruckenmiller/aws-ecs-spot-instance-drainer
- blinkist/terraform-aws-airship-ecs-instance-draining - Drain using cloudwatch event, sns, and python lambda. Deploy lambda with terraform.
- btisdall/ecs-cid
- docker-production-aws/lambda-lifecycle-hooks
- ericdahl/tf-ecs - Drain using cloudwatch event, sns, and python lambda. Deploy with terraform.
- claranet/terraform-aws-ecs-container-instances - Drain using cloudwatch event, sqs, and python lambda. Deploy with terraform.
- aws-samples/aws-lambda-lifecycle-hooks-function - backup data to s3 using sns and lambda
# set variables
INSTANCE_ID=i-aaaabbbbcccc
ASG_NAME=asg-xyz
LIFECYCLE_HOOK_NAME=lifecycle-xyz
# terminate a specific instance id
aws autoscaling \
terminate-instance-in-auto-scaling-group \
--should-decrement-desired-capacity \
--instance-id $INSTANCE_ID
# once the instance is in a Terminating:Wait stage, continue the lifecycle
aws autoscaling \
complete-lifecycle-action \
--lifecycle-action-result CONTINUE \
--lifecycle-hook-name $LIFECYCLE_HOOK_NAME \
--auto-scaling-group-name $ASG_NAME \
--instance-id $INSTANCE_ID
References
- How do I delay Auto Scaling termination of unhealthy Amazon EC2 instances so I can troubleshoot them?
- aws autosclaing terminate-instance-in-auto-scaling-group
- aws autosclaing complete-lifecycle-action
- 03 Sep 2020 - Graceful shutdown using AWS Auto Scaling groups and Terraform
- 04 Oct 2019 - Autoscaling like a pro: how to use EC2 Auto Scaling Lifecycle Hooks, the right way.
- 22 Sep 2019 - Scale down a Kube Cluster Minion without Downtime using AWS Autoscaling Lifecycle Hook — Part III
- 24 Sep 2018 - AWS Auto Scaling Group: Working With Lifecycle Hooks
- 05 Jun 2018 - Amazon EC2 Auto Scaling lifecycle hooks to Export Instance Logs After Marked For Terminate
- 16 May 2018 - AWS Auto Scaling Lifecycle
- 25 Jan 2017 - How to Automate Container Instance Draining in Amazon ECS
- 04 Nov 2015 - Under the Hood: AWS CodeDeploy and Auto Scaling Integration
- 20 Jan 2015 - Deep Dive Into Auto Scaling Lifecycle Hooks