GithubHelp home page GithubHelp logo

isabella232 / terraform-ecs-container-instance-draining Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metabase/terraform-ecs-container-instance-draining

0.0 0.0 0.0 218 KB

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

License: Apache License 2.0

Makefile 2.96% HCL 53.90% Python 24.00% Go 19.15%

terraform-ecs-container-instance-draining's Introduction

ECS container instance draining on lifecycle events

Conventional Commits 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

data "aws_region" "current" {}

module "example_module_test" {
  source = "git::https://github.com/edispark/terraform-ecs-container-instance-draining"

  autoscaling_group_name = "my-asg-name"
  ecs_cluster_name       = "my-cluster-name"
}

Requirements

Name Version
terraform >= 0.12.26
aws >= 3.0
local 1.4.0

Providers

Name Version
aws >= 3.0
local 1.4.0

Inputs

Name Description Type Default Required
autoscaling_group_name The name of the Auto Scaling group to which you want to assign the lifecycle hook to string n/a yes
ecs_cluster_name Specifies the ECS Cluster Name with which the resources would be associated string n/a yes
tags Additional tags (_e.g._ { BusinessUnit : ABC }) map(string) {} no

Outputs

Name Description
sns_topic_arn Topic used by ASG to send notifications when instance state is changing

Development

Prerequisites

Configurations

  • Configure pre-commit hooks
pre-commit install
  • Configure golang deps for tests
> go get github.com/gruntwork-io/terratest/modules/terraform
> go get github.com/stretchr/testify/assert

Tests

  • Tests are available in test directory
  • In the test directory, run the below command
go test

terraform-ecs-container-instance-draining's People

Contributors

dependabot[bot] avatar john-metabase avatar mridehalgh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.