container-instance-draining

edispark/container-instance-draining/ecs

Terraform Module HCL ECS

Automates Container Instance Draining in Amazon ECS by removing tasks from an instance before scaling down a cluster with Auto Scaling Groups.

Install
module "container-instance-draining" {
source = "edispark/container-instance-draining/ecs"
version = "1.1.0"
}
plain text: /constructs/tfmod-edispark-container-instance-draining-ecs/install.txt
⭐ Source on GitHub 📦 Registry page
README

ECS container instance draining on lifecycle events ![Conventional Commits](https://conventionalcommits.org) !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_

Inputs (6)
NameTypeDescriptionDefault
regionstringAWS Region for ECS cluster required
ecs_cluster_namestringSpecifies the ECS Cluster Name with which the resources would be associated required
ecs_cluster_arnstringSpecifies the ECS Cluster ARN with which the resources would be associated required
autoscaling_group_arnstringThe name of the Auto Scaling group to which you want to assign the lifecycle hoo required
autoscaling_group_namestringThe name of the Auto Scaling group to which you want to assign the lifecycle hoo required
tagsmap(string)Additional tags (_e.g._ { BusinessUnit : ABC }){}
Outputs (1)
sns_topic_arn — Topic used by ASG to send notifications when instance state is changing
Resources (8)
aws_autoscaling_lifecycle_hookaws_cloudwatch_log_groupaws_iam_roleaws_iam_role_policyaws_lambda_functionaws_lambda_permissionaws_sns_topicaws_sns_topic_subscription
Details
FrameworkTerraform Module
LanguageHCL
Version1.1.0
Cloud ECS
★ Stars6
Forks13
Total downloads3.2k
Inputs6
Outputs1
Resources8
LicenseApache-2.0
Namespaceedispark
Updated