Coder Social home page Coder Social logo

onaio / terraform-aws-asg-compute Goto Github PK

View Code? Open in Web Editor NEW
1.0 29.0 1.0 15 KB

Terraform module for defining the compute infrastructure for an Auto Scaling Group deployment. Meant to be used with https://github.com/onaio/terraform-aws-asg-base

HCL 100.00%

terraform-aws-asg-compute's Introduction

Auto-Scaling Compute Terraform module Build Status

s module creates an aws launch configuration, an aws auto-scaling group and cloudwatch alarms for the auto-scaling group. It also allows for a blue green deployment if the module is imported twice under a blue and a green configuration name.

Usage Example

module "rapidpro-blue" {
  source = "../../modules/asg-compute"

  asg_max_size             = "${var.blue_asg_max_size}"
  asg_min_size             = "${var.blue_asg_min_size}"
  deployment               = "blue"
  deployed                 = "${var.deploy_blue}"
  env                      = "${var.env}"
  project                  = "${var.project}"
  project_id               = "${var.project_id}"
  owner                    = "${var.owner}"
  end_date                 = "${var.end_date}"
  ssh_key_name             = "${var.ssh_key_name}"
  ami                      = "${var.blue_ami}"
  instance_type            = "${var.instance_type}"
  attached_volume_size     = "${var.attached_volume_size}"
  cloudwatch_alarm_actions = "${var.cloudwatch_alarm_actions}"
  target_group_arns        = "${module.rapidpro.target_group_arns}"
  security_groups          = "${module.rapidpro.security_groups}"
  subnet_ids               = "${module.rapidpro-vpc.subnet_ids}"
  user_data                = "${data.template_cloudinit_config.rapidpro.rendered}"
}

module "rapidpro-green" {
  source = "../../modules/asg-compute"

  asg_max_size             = "${var.green_asg_max_size}"
  asg_min_size             = "${var.green_asg_min_size}"
  deployment               = "green"
  deployed                 = "${var.deploy_green}"
  env                      = "${var.env}"
  project                  = "${var.project}"
  project_id               = "${var.project_id}"
  owner                    = "${var.owner}"
  end_date                 = "${var.end_date}"
  ssh_key_name             = "${var.ssh_key_name}"
  ami                      = "${var.green_ami}"
  instance_type            = "${var.instance_type}"
  attached_volume_size     = "${var.attached_volume_size}"
  cloudwatch_alarm_actions = "${var.cloudwatch_alarm_actions}"
  target_group_arns        = "${module.rapidpro.target_group_arns}"
  security_groups          = "${module.rapidpro.security_groups}"
  subnet_ids               = "${module.rapidpro-vpc.subnet_ids}"
  user_data                = "${data.template_cloudinit_config.rapidpro.rendered}"
}

A cloudinit config template can be provided for the auto-scaling group instances. For example:

data "template_cloudinit_config" "rapidpro" {
  gzip          = true
  base64_encode = true

  part {
    content_type = "text/x-shellscript"

    content = <<-EOF
      #!/bin/bash
      . /home/rapidpro/.virtualenvs/rapidpro/bin/activate
      . /home/rapidpro/app/django.sh
      cd /home/rapidpro/app
      python manage.py migrate --noinput
      python manage.py collectstatic --noinput
      systemctl reload nginx.service
      systemctl enable rapidpro.service
      systemctl start rapidpro.service
      EOF
  }
}

Note on IAM Role

Make sure the EC2 instances that are created using this module are attached to an IAM role (using the ec2_instance_role variable) that has the following permissions:

  • ec2:DeleteTags
  • ec2:CreateTags
  • All ec2:Describe* permissions

These permissions are needed by sre-tooling to update the details of the tags of the instances from within the instances.

terraform-aws-asg-compute's People

Contributors

jasonrogena avatar davisraym avatar ukanga avatar

Stargazers

Mark Ekisa avatar

Watchers

Matt Berg avatar  avatar Kelvin Jayanoris avatar Simon Kiarie avatar Wambere avatar James Cloos avatar  avatar Carolyn Footitt avatar Emmanuel Tarus avatar Conor Kelly avatar  avatar Tychus avatar  avatar Brian Mwasi avatar  avatar Winnie Kiragu avatar Lincoln Simba avatar L≡ZRS avatar Benn Simon avatar kahammer avatar Rosalia Lorenzen avatar Faith Mutua avatar hngondoki avatar Kipchirchir Cheroigin avatar Kelvin Muchiri avatar  avatar  avatar Brian Cheye  avatar Henry Wambugu avatar

Forkers

mraztevin

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.