Giter Site home page Giter Site logo

samrocketman / terraform-aws-ecs-codedeploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yardbirdsax/terraform-aws-ecs-codedeploy

0.0 2.0 1.0 48 KB

A Terraform module for deploying AWS ECS with an integrated CodeDeploy project for rolling out new versions of applications.

License: MIT License

Dockerfile 0.43% HCL 60.87% Shell 6.25% Python 32.45%

terraform-aws-ecs-codedeploy's Introduction

Deploying AWS ECS integrated with CodeDeploy using Terraform

This Terraform module will deploy an ECS cluster, service, and task definition which is integrated with AWS CodeDeploy for easily rolling out new versions of containers.

Module Requirements

This module requires Terraform version 0.12.31 or higher. At some point in the near future support for versions under 0.14 will be dropped.

Pre-requisites

  • You need an AWS account that you have admin privileges on.
  • You must create an ECR repository in your account. The module currently grants ECS the ability to pull images from any repository in your account; in the future this will be configurable to only allow access to specified ones.

Full example walk-through

The following steps walk through a complete use of the module using all defaults. This will deploy things in the default VPC of your account, and this assumes that you will be deploying in US-EAST-2.

Creating the first Docker image

  • Create an ECR called nginx-test in your account.

    aws ecr create-repository --repository-name nginx-test
    
  • Generate the local Docker image

    docker build . -t nginx-test:1.0 --build-arg version=1.0
  • Log in to ECR in your account

    ACCOUNT_ID=`aws sts get-caller-identity | jq '.Account' -r`
    aws ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.us-east-2.amazonaws.com
  • Tag and push the image

    DOCKER_TAG=${ACCOUNT_ID}.dkr.ecr.us-east-2.amazonaws.com 
    docker tag nginx-test:1.0 $DOCKER_TAG/nginx-test:1.0
    docker push $DOCKER_TAG/nginx-test:1.0

Deploying infrastructure

DO NOT do this in a production subscription.

  • Run Terraform

    cd examples/basic
    terraform apply -auto-approve

Creating a second version

  • Build and push a new Docker image

    cd ../..
    docker build . -t nginx-test:2.0 --build-arg version=2.0
    ACCOUNT_ID=`aws sts get-caller-identity | jq '.Account' -r`
    aws ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.us-east-2.amazonaws.com
    DOCKER_TAG=${ACCOUNT_ID}.dkr.ecr.us-east-2.amazonaws.com 
    docker tag nginx-test:2.0 $DOCKER_TAG/nginx-test:2.0
    docker push $DOCKER_TAG/nginx-test:2.0
  • Apply a new Terraform config with the new version

    terraform apply -var docker_tag=2.0

    This should only change the task definition.

  • Start and monitor the CodeDeploy deployment.

terraform-aws-ecs-codedeploy's People

Contributors

yardbirdsax avatar

Watchers

James Cloos avatar  avatar

Forkers

tonystark0122

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.