Deploying to AWS using Terraform for Local Experimentation

Terraform is a tool used to turn an api into code, and in this case we are going to use with AWS.

The download of terraform is available here

You don’t want aws secrets in your git repo, so this is a basic structure i start out with when i am doing local terraform experimentation.

Terraform Setup on Ubuntu

There is a nice script here that installs terraform.  Just run it periodically to keep it up to date.

I am a noob in the linux stuff so i needed to google to how to make it executable.

sudo chmod +x scriptname

Used to define the set of variables used in Terraform

variable "AWS_ACCESS_KEY" { }
variable "AWS_SECRET_KEY" { }
variable "AWS_REGION" 
    default = "us-east-1"

Defines what api will get ran. Since this is aws we are deploying to we are using the aws provider.  If we were deploying to azure the provider would be azurerm

provider "aws" {
    access_key = "${var.AWS_ACCESS_KEY}"
    secret_key = "${var.AWS_SECRET_KEY}"
    region = "${var.AWS_REGION}


Put this in the git ignore so the secrets stay on your local machine. If we were using a build server an alternative solution would need to be used.  But for a small scripting effort this works great.


This one can really be named anything. It is where all of the resources would get built out.

resource "aws_instance" "example" {
   ami             = ""
   instance_type   = "t2.micro"

Here is the github repo that this is stored in.