Git Product home page Git Product logo

hello-go-ecs-terraform's Introduction

A "Hello World" in Golang deployed to AWS ECS (Docker) using Terraform

Big thanks to Tadas Vilkeliskis for Bootstrapping Docker Infrastructure With Terraform write up.

How to use this

  1. Make sure you have the following installed and/or created/configured/working:

  2. Allow Terraform to use your credentials in ~/.aws/config by symlinking it to credentials:

ln -s ~/.aws/confic ~/.aws/credentials
  1. Install this example:
go get github.com/grisha/hello-go-ecs-terraform
  1. Change into the project directory:
cd $GOPATH/src/grisha/hello-go-ecs-terraform
  1. Edit tf/variables.tf file so that it has the following:
variable "key_name" { default = "YOUR-AWS-KEY-PAIR-NAME" }
variable "dockerimg" { default = "YOUR-DOCKER-HUB-USERNAME/IMAGE-NAME" }
  1. The docker hub username must be correct (though the actual image doesn not need to exist, it will be created for you), and you should be authenticated with:
docker login
  1. Check that terraform works with:
make plan
  1. If the above produces no errors, give it a try. Note that due to timing of AWS object creations sometimes you have to run this twice, it succeeds on the second try:
make apply
  1. You should now see a load balancer in the AWS console, where it should list its DNS name. You should also see an ECS service and its tasks and associated EC2 instances. The whole thing will take a few minutes to create.

  2. Once it's all created, you should be able to hit the ELB DNS name with your browser and see the app in action.

  3. In this set up Terraform uses the .git/logs/HEAD file as the indicator that code has changed, but this file only changes when you commit something (The idea being that your CI, e.g. Jenkins would actually perform the make apply). If you want to force deploy the code that you currently have, you can do this:

    make force_deploy

    Once you do this, you should see the ECS gradually replace your tasks with the new version.

  4. When finished, you can destroy everything with:

make destroy

hello-go-ecs-terraform's People

Contributors

grisha avatar

Watchers

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