A Getting Started Tutorial for Terraform and Google Cloud Platform (GCP), using Google's interactive Cloud Shell.
This tutorial will help you learn Terraform, an open source Infrastructure as Code tool.
This tutorial assumes you know basic GCP concepts and terminology.
To follow this tutorial, you will need a Google Cloud Platform account. If you do not have a GCP account, create one now. This tutorial uses services included in the GCP free tier.
Complete this tutorial in Google's Cloud Shell.
When prompted to trust the tutorial image, answer "Yes".
This tutorial uses a Docker image. The version of Terraform included in that image (v1.0.1
) may not be the latest version. To build and use a Docker image with the latest version see the instructions below.
- Set up Docker and the gcloud command line utility as described in the "Before you begin" section of the GCP Container Registry Quickstart.
- Build the image:
docker build . -t terraform-gcp-gsg:v$(date "+%Y-%m-%d")
- Optionally, inspect/test image locally:
docker run -it --entrypoint /bin/sh terraform-gcp-gsg:v$(date "+%Y-%m-%d")
- Make sure docker is configured to authenticate with gcloud:
gcloud auth configure-docker
- Tag the image, replacing
[PROJECT-ID]
with your Google Cloud's project ID:docker tag terraform-gcp-gsg:v$(date "+%Y-%m-%d") gcr.io/[PROJECT-ID]/terraform-gcp-gsg:v$(date "+%Y-%m-%d")
- Update the URL above to use the URL to your new docker image.
- You'll be prompted to trust this image. Answer "Yes".