/terraform-example

An example repo to demonstrate terraform with GCP and Azure

Primary LanguageHCLMIT LicenseMIT

Terraforming the Cloud

This is an example repo to demonstrate terraform with GCP and Azure as part of a talk.

Slides are available here 👉 https://docs.google.com/presentation/d/1L22ox6M8Yl0-Ocw_wREyJNeQp25vhhkdFeCwzjdjDSY/edit?usp=sharing

The examples in this repo where developed using Hashicorp's Terraform Get Started guides for Azure and GCP.

What you will need

How to use this repo

  1. Clone the repo

    git clone https://github.com/sgibson91/terraform-example.git
    cd terraform-example
  2. Change into the terraform subdirectory of your chosen cloud provider

    cd terraform/{{ azure | gcp }}
  3. Authenticate with your chosen cloud provider

    # For Azure
    az login
    # For Google Cloud
    gcloud auth login
  4. Create a copy of inputs.example.tfvars and replace the placeholder values with your desired inputs. You may even choose to change some other values that are listed in variables.tf.

    cp inputs.example.tfvars inputs.tfvars
  5. Initialise terraform

    terraform init
  6. Plan your infrastructure changes

    terraform plan -var-file=inputs.tfvars -out=plan
  7. Apply your infrastructure changes

    terraform apply plan

💡 Steps 6 and 7 can be repeated as many times as you wish as you make changes to your infrastructure

  1. Once you are finished, destroy your infrastructure

    terraform plan -var-file=inputs.tfvars -out-plan -destroy
    terraform apply plan