github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/terraform-gcp-example/README.md (about) 1 # Terraform GCP Example 2 3 This folder contains a simple Terraform module that deploys resources in [GCP](https://cloud.google.com/) to demonstrate 4 how you can use Terratest to write automated tests for your GCP Terraform code. This module deploys a [Compute 5 Instance](https://cloud.google.com/compute/) and gives that Instance a `Name` with the value specified in the 6 `instance_name` variable. It also creates a Cloud Storage Bucket using the `bucket_name` and `bucket_location` variables. 7 8 Check out [test/terraform_gcp_example_test.go](/test/gcp/terraform_gcp_example_test.go) to see how you can write 9 automated tests for this module. 10 11 Note that the Compute Instance in this module doesn't actually do anything; it just runs a Vanilla Ubuntu 16.04 Image for 12 demonstration purposes. For slightly more complicated, real-world examples of Terraform modules, see 13 [terraform-http-example](/examples/terraform-http-example) and [terraform-ssh-example](/examples/terraform-ssh-example). 14 15 **WARNING**: This module and the automated tests for it deploy real resources into your GCP account which can cost you 16 money. The resources are all part of the [GCP Free Tier](https://cloud.google.com/free/), so if you haven't used that up, 17 it should be free, but you are completely responsible for all GCP charges. 18 19 ## Running this module manually 20 21 1. Sign up for [GCP](https://cloud.google.com/). 22 1. Configure your GCP credentials using one of the [supported methods for GCP CLI 23 tools](https://cloud.google.com/sdk/docs/quickstarts). 24 1. Install [Terraform](https://www.terraform.io/) and make sure it's in your `PATH`. 25 1. Ensure the desired Project ID is set: `export GOOGLE_CLOUD_PROJECT=terratest-ABCXYZ`. 26 1. Run `terraform init`. 27 1. Run `terraform apply`. 28 1. When you're done, run `terraform destroy`. 29 30 ## Running automated tests against this module 31 32 1. Sign up for [GCP](https://cloud.google.com/free/). 33 1. Configure your GCP credentials using the [GCP CLI 34 tools](https://cloud.google.com/sdk/docs/quickstarts). 35 1. Install [Terraform](https://www.terraform.io/) and make sure it's on your `PATH`. 36 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 37 1. Set `GOOGLE_CLOUD_PROJECT` environment variable to your project name. 38 1. `cd test` 39 1. `dep ensure` 40 1. `go test -v -run TestTerraformGcpExample`