Skip to content

Instantly share code, notes, and snippets.

@chanson5000
Created December 12, 2019 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanson5000/8d9cacb0ec5d91402bd86349294c7413 to your computer and use it in GitHub Desktop.
Save chanson5000/8d9cacb0ec5d91402bd86349294c7413 to your computer and use it in GitHub Desktop.
Terraform Quickstart Example (OSX)

Setting Up Terraform with AWS Account (OSX)

Requires an AWS account. The example uses a free tier EC2 instance. If you do not have free tier example, this example would likely not incur any costs over $3.

This is a shortened "getting started" version of the official Terraform documentation.

  • From console, brew install terraform
  • terraform --version to check if installed correctly
  • Install AWS CLI using the bundled installer
    • cd ~/Downloads
    • curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
    • unzip awscli-bundle.zip
    • sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
    • aws --version to check if installed correctly
  • To verify your AWS profile and esure Terraform as correct provider credentials
    • Run aws configure
    • The credentials for this stage can be found or set up here
  • Create Terraform configuration file
    • cd to your desired working directory
    • Create an example.tf file with the following:
      provider "aws" {
        profile    = "default"
        region     = "us-east-1"
      }
      
      resource "aws_instance" "example" {
        ami           = "ami-2757f631"
        instance_type = "t2.micro"
      }
      
    • Replace region with your desired region
    • Replace ami with an AMI that exists in your desired region (AMI Id's are different between regions)
  • terraform validate to check Terraform config for errors
  • terraform init to download the AWS provider plugin
  • terraform apply to begin the process of applying the the configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment