Giter Club home page Giter Club logo

tf_docker_host's Introduction

ECS-Optimized AMI Terraform Module

Repository contains a terraform module for ECS-Optimized instance deployment to your cluster.

In addition to standard deployment, it

  1. allows to define what cluster the instance must be deployed to
  2. turns on awslogs driver
  3. creates a record in internal Route 53 hosted zone
  4. attaches, formats and mounts an EBS volume for permanent data storage

Usage

Describe docker host configuration as a module in the terraform JSON config (*.tf.json):

{
  "module": {
    "docker_host_1": {
      "source": "github.com/snatalenko/tf_docker_host//2016.09.g",
      "app": "myapp",
      "env": "production",

      // where the instance should be deployed to
      "region": "us-east-1",
      "subnet_id": "${aws_subnet.public_1.id}",
      "cluster_name": "${aws_ecs_cluster.web.name}",
      "associate_public_ip_address": true,
      "disable_api_termination": false,

      // instance size
      "instance_type": "t2.micro",

      // data volume configuration (10Gb standard EBS volume mounted to /ecs/)
      "volume_data_size": 10,
      "volume_data_type": "gp2",
      "volume_data_terminate": false,

      // security configuration
      "iam_instance_profile": "${aws_iam_instance_profile.docker_host.name}",
      "vpc_security_group_ids": "${aws_security_group.web.id},${aws_security_group.admin.id}",
      "key_name": "${aws_key_pair.admin.key_name}",

      // instance location within an internal hosted zone (VPC DNS)
      "route53_zone_id": "${aws_route53_zone.local.zone_id}",
      "hostname": "my-ecs-host-1.internal.domain",
      "instance_index": 1
    }
  }
}

The above configuration depends on the following services, which should be defined either in additional modules on in the main Terraform script:

{
  "resource": {
    "aws_ecs_cluster": {
      "web": { /* ... */ }
    },
    "aws_subnet": {
      "public_1": { /* ... */ }
    },
    "aws_key_pair": {
      "admin": { /* ... */ }
    },
    "aws_security_group": {
      "web": { /* ... */ },
      "admin": { /* ... */ }
    },
    "aws_iam_instance_profile": {
      "docker_host": { /* ... */ }
    },
    "aws_route53_zone": {
      "local": { /* ... */ }
    }
  }
}

After the configuraton is complete, run terraform get in terminal to download the module from github.

The following attributes are exported:

  • id - ECS instance ID
  • public_ip - instance public IP, if attached
  • private_ip - instance private IP within VPC
  • hostname - either defined in configuration or autogenerated instance hostname

tf_docker_host's People

Contributors

snatalenko 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.