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.
- A
terraform
installation: https://learn.hashicorp.com/tutorials/terraform/install-cli - An account with your chosen cloud provider
- If you choose Google Cloud, you will also need to create a service account and generate a key for it
- The command line interface installation for your chosen cloud provider, either:
-
Clone the repo
git clone https://github.com/sgibson91/terraform-example.git cd terraform-example
-
Change into the
terraform
subdirectory of your chosen cloud providercd terraform/{{ azure | gcp }}
-
Authenticate with your chosen cloud provider
# For Azure az login # For Google Cloud gcloud auth login
-
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 invariables.tf
.cp inputs.example.tfvars inputs.tfvars
-
Initialise
terraform
terraform init
-
Plan your infrastructure changes
terraform plan -var-file=inputs.tfvars -out=plan
-
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
-
Once you are finished, destroy your infrastructure
terraform plan -var-file=inputs.tfvars -out-plan -destroy terraform apply plan