Skip to content

Instantly share code, notes, and snippets.

@veggiemonk
Last active June 26, 2019 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veggiemonk/8d79063f95fdb55a0f8e0032685f4d8d to your computer and use it in GitHub Desktop.
Save veggiemonk/8d79063f95fdb55a0f8e0032685f4d8d to your computer and use it in GitHub Desktop.
TERRAFORM workshop 2

Terraform

  1. take the code from the previous workshop -> https://gist.github.com/veggiemonk/097890ff101a995f3c31f4d25b69665e
  2. install terraform 0.12 => https://releases.hashicorp.com/terraform/0.12.3/terraform_0.12.3_linux_amd64.zip
  3. convert it to Terraform 0.12 by using the command terraform 0.12upgrade
  4. make sure it works (terraform plan, terraform apply and terraform destroy)
  5. spit into modules. https://www.terraform.io/docs/modules/index.html
  6. manually go into the console, create a small VM and try to import it into the terraform state -> see https://www.terraform.io/docs/import/usage.html
  7. destroy everything.
  8. << FIKA >>
  9. create a repo for the terraform code.
  10. setting up cloudbuild to trigger a build for that repo. 2 triggers: one for terraform plan on pull request, one for terraform apply on push to master
  11. create the infrastructure through the pipeline.

Create terraform container image

In cloud-shell:

git clone https://github.com/GoogleCloudPlatform/cloud-builders-community.git
cd cloud-builders-community/terraform
gcloud builds submit . --config=cloudbuild.yaml

Create trigger in cloudbuid

https://codelabs.developers.google.com/codelabs/cloud-builder-gke-continuous-deploy/index.html?index=..%2F..index#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment