Skip to content

Terraforming Google Cloud Platform - examples and testing code

Notifications You must be signed in to change notification settings

zygiss/gcp-terraform-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraforming the Google Cloud Platform

This repo contains various bits of Terraform code to provision resources on Google Cloud Platform (GCP), mainly a Google Compute Instance, together with its associated resources, such as disk, network interface and provisioning metadata.

We're making use of the Always Free GCP usage tier and the 12 month, 300USD free trial to minimise the monetary impact of learning how to work with both Terraform and GCP.

The included Terraform states currently are able to provision the following resources:

The following attributes can be customised in the variable file, vars.tf:

Getting started

Install dependencies

  • Cloud SDK - we'll use the gcloud tool for some initial setup since Terraform GCP provider doesn't yet have complete feature support.
  • Terraform

Create a GCP project

Terraform GCP provider only supports creating projects that are part of an Organisation which can only be created by speaking to the Google sales team and we won't be doing that. Just navigate to the GCP Console and create a new project.

Generate credentials & configure GCP authentication in Terraform

Follow the docs here to configure and download the account file.

Then update the credentials like in the included settings.tf file with the name of your credentials file, e.g. gce-project-111111111111.json and enter the correct project ID, e.g. 111111111111:

provider "google" {
  credentials = "${file("gce-project-111111111111.json")}"
  project     = "111111111111"
  region      = "us-west1"
}

Run it

You can run terraform plan to get the output of what Terraform is about to do, if anything. In other words, terraform plan will check the existing state of the environment and prepare any required steps to make the environment match the configuration.

Once you're happy, let Terraform apply the state:

terraform apply

And observe the results.

About

Terraforming Google Cloud Platform - examples and testing code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published