Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
68 lines (54 sloc) 3.02 KB


Getting set up

Install the pre-requisites python, pip (comes with Python > 2.7.9 or > 3.4), awscli, terraform, terragrunt, packer and optionally install virtualenv, aws-shell with pip.

Set up an automatically loaded SSH agent or just run ssh-agent to create a temporary agent for the duration of this login. If you'd like help with the pre-requisites, there's a guide here for linux (CentOS 7).

Alternatively all the pre-requisites are installed on a publicly accessible AMI. The follow instructions that explain how to instantiate a VM using the Remote Provisioning machine image (workstation-remprov).

Create an AWS credentials file. This can be done using aws configure or manually creating a file in your home directory (e.g. /home/your-username/.aws/credentials or /Users/your-username/.aws/credentials) containing your access and secret keys:

aws_secret_access_key = <secret key>
aws_access_key_id = <access key>
region = eu-west-2

Restrict file access to your user using chmod 0600 ~/.aws/credentials

Check that you've got access to your AWS account:

aws ec2 describe-instances

Set up permissions for that AWS account to run these examples. You can do this as widely or as narrowly as you'd like for your experiment, but the AWS Permissions guide gives you a simple, fairly-open example set.

Create an SSH key and when prompted save it in ~/.ssh/id_rsa_devops_simple_key:

ssh-keygen -t rsa -b 4096 -C ""

Load the key you've created into your ssh-agent.

ssh-add ~/.ssh/id_rsa_devops_simple_key

Clone this repo (git clone, then change directory into ./terraform within it.

Initialise terraform:

terraform get
terraform init

Prepare your terraform calls. Each will take the form:

terraform <action> <vars>

All calls beyond this point require a few variables to be set unless you use the defaults:

-var 'aws_region=eu-west-2' \
-var 'key_name=devops_simple_key' \
-var 'public_key_path=~/.ssh/'

or set them in an .aws/config file like:

region = eu-west-2

so a typical call, abbreviated to terraform plan because we're using the default values would look like

terraform plan -var 'aws_region=eu-west-2' -var 'key_name=devops_simple_key' -var 'public_key_path=~/.ssh/'

I'm using the terraform plan syntax here, but you're better using the wrapper terragrunt plan if you've got it installed.