This tutorial will walk you through setting up a Jenkins Pipeline to Deploy a Docker app to AWS ECS using Terraform. If you are looking to use docker then this is the perfect choice for high traffic microservice infrastucture. The tutorial will show you the power of Terraform to provision your cloud infrastructure, how jenkins can help speed up deployments, and how AWS Elastic Container Service can be a great solution for hosting your Enterpise level applications. Be aware this tutorial will spin up infrastructure in AWS and you must run the destroy scripts at the end so you aren't leaving the example running.
Please read the following and install/sign up for what you need before the tutorial for the best experience.
-
Use a *nix bash/zsh terminal (Mac/Linux)
- There are probably workarounds for windows but I didn’t try them. The ubuntu sub-env might work.
-
Create a GitHub Account and make sure you have the git scm installed in CLI.
- Terraform version v0.10+
https://www.terraform.io/downloads.html
- Sign up for an AWS account and put a card on file.
- Install AWS CLI
https://docs.aws.amazon.com/cli/latest/userguide/installing.html
- Install JQ (For CLI JSON Parsing)
https://stedolan.github.io/jq/
- DockerHub Account (*This step is optional but recommended)
- Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install Terraform
brew install terraform
- Install AWS CLI
brew install awscli
- Install JQ
brew install jq
I have been doing this on my mac but have tested linux in the past. Everything should be available if you are using a major Distro.
- Install Terraform
- Install Python/AWS CLI
- Install jq from apt-get or yum
Either run the script below or continue on to clone the repos manually.
bash <(curl -s https://raw.githubusercontent.com/OGProgrammer/terraform-aws-init/master/clone-cd-example.sh)
Clone down the following repositories:
git clone [email protected]:OGProgrammer/terraform-aws-ecs-service.git
git clone [email protected]:OGProgrammer/terraform-aws-init.git
git clone [email protected]:OGProgrammer/terraform-aws-jenkins.git
git clone [email protected]:OGProgrammer/terraform-aws-ecs-infrastructure.git
You don't need to clone the following but are apart of the tutorial.
git clone [email protected]:OGProgrammer/jenkins-pipeline-groovy.git
git clone [email protected]:OGProgrammer/docker-test-app.git
git clone [email protected]:OGProgrammer/test-app.git
Fork this repository and clone it to your machine.
https://github.com/OGProgrammer/terraform-example-manifest
# Fork this and clone your version of it down
git clone [email protected]:OGProgrammer/terraform-example-manifest.git
If you want full control, then fork/clone all the above repos aswell but isn't required.