diff --git a/docs/slides/aws/terraform-cloud-v2/index.md b/docs/slides/aws/terraform-cloud-v2/index.md index e8e786e3..c56ee417 100644 --- a/docs/slides/aws/terraform-cloud-v2/index.md +++ b/docs/slides/aws/terraform-cloud-v2/index.md @@ -7,7 +7,7 @@ count: true ??? # Terraform Cloud on AWS workshop ## Getting started -This is a half-day workshop that introduces Terraform Cloud using an AWS-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform OSS on AWS Instruqt track before this one. +This is a half-day workshop that introduces Terraform Cloud using an AWS-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform Community Edition on AWS Instruqt track before this one. The instructions on how to conduct a workshop are in the standard [instructor's guide](https://github.com/hashicorp/field-workshops-terraform/blob/main/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md). @@ -233,7 +233,7 @@ This chapter is organized in three sections: 2. Terraform Editions - - Understand Terraform OSS and the differences between OSS and Cloud and Enterprise + - Understand Terraform Community Edition and the differences between Community Edition and Cloud and Enterprise 3. Benefits of using Terraform Cloud @@ -414,7 +414,7 @@ class: col-3, header-adjust, header-adjust-minimal-list ??? # Terraform Editions -## Terraform OSS +## Terraform Community Edition - A.K.A. Terraform - Terraform is a sophisticated technology used to deploy infrastructure @@ -455,7 +455,7 @@ class: col-2, header-adjust, minimal-list - Terraform Cloud provides infrastructure automation as a service, is free to get started, and has an in-place upgrade to paid option. -- Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. +- Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. --- name: terraform-cloud-build @@ -620,7 +620,7 @@ class: review, no-footer 1. The adoption patterns we see, both among our large-scale users as well as individual contributors, involve multiple adaptive stages. The central idea remains uniform in that automation should be standardized as shared practice, and that governance guidelines are needed to support emerging requirements. -2. Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [OSS]. +2. Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [Community]. --- name: Access-Control class: title, no-footer diff --git a/docs/slides/azure/terraform-cloud-v2/index.md b/docs/slides/azure/terraform-cloud-v2/index.md index 65269019..16bf1254 100644 --- a/docs/slides/azure/terraform-cloud-v2/index.md +++ b/docs/slides/azure/terraform-cloud-v2/index.md @@ -7,7 +7,7 @@ count: true ??? # Terraform Cloud on Azure workshop ## Getting started -This is a half-day workshop that introduces Terraform Cloud using an Azure-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform OSS on Azure Instruqt track before this one. +This is a half-day workshop that introduces Terraform Cloud using an Azure-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform Community Edition on Azure Instruqt track before this one. The instructions on how to conduct a workshop are in the standard [instructor's guide](https://github.com/hashicorp/field-workshops-terraform/blob/main/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md). @@ -233,7 +233,7 @@ This chapter is organized in three sections: 2. Terraform Editions - - Understand Terraform OSS and the differences between OSS and Cloud and Enterprise + - Understand Terraform Community Edition and the differences between Community Edition and Cloud and Enterprise 3. Benefits of using Terraform Cloud @@ -414,7 +414,7 @@ class: col-3, header-adjust, header-adjust-minimal-list ??? # Terraform Editions -## Terraform OSS +## Terraform Community Edition - A.K.A. Terraform - Terraform is a sophisticated technology used to deploy infrastructure @@ -455,7 +455,7 @@ class: col-2, header-adjust, minimal-list - Terraform Cloud provides infrastructure automation as a service, is free to get started, and has an in-place upgrade to paid option. -- Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. +- Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. --- name: terraform-cloud-build @@ -620,7 +620,7 @@ class: review, no-footer 1. The adoption patterns we see, both among our large-scale users as well as individual contributors, involve multiple adaptive stages. The central idea remains uniform in that automation should be standardized as shared practice, and that governance guidelines are needed to support emerging requirements. -2. Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [OSS]. +2. Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [Community]. --- name: Access-Control class: title, no-footer diff --git a/docs/slides/gcp/terraform-cloud-v2/index.md b/docs/slides/gcp/terraform-cloud-v2/index.md index ed8f3406..a7ae13b9 100644 --- a/docs/slides/gcp/terraform-cloud-v2/index.md +++ b/docs/slides/gcp/terraform-cloud-v2/index.md @@ -7,7 +7,7 @@ count: true ??? # Terraform Cloud on GCP workshop ## Getting started -This is a half-day workshop that introduces Terraform Cloud using an GCP-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform OSS on GCP Instruqt track before this one. +This is a half-day workshop that introduces Terraform Cloud using an GCP-based application for the Instruqt labs. If you're brand new to Terraform you should try the Introduction to Terraform Community Edition on GCP Instruqt track before this one. The instructions on how to conduct a workshop are in the standard [instructor's guide](https://github.com/hashicorp/field-workshops-terraform/blob/main/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md). @@ -233,7 +233,7 @@ This chapter is organized in three sections: 2. Terraform Editions - - Understand Terraform OSS and the differences between OSS and Cloud and Enterprise + - Understand Terraform Community Edition and the differences between Community Edition and Cloud and Enterprise 3. Benefits of using Terraform Cloud @@ -414,7 +414,7 @@ class: col-3, header-adjust, header-adjust-minimal-list ??? # Terraform Editions -## Terraform OSS +## Terraform Community Edition - A.K.A. Terraform - Terraform is a sophisticated technology used to deploy infrastructure @@ -455,7 +455,7 @@ class: col-2, header-adjust, minimal-list - Terraform Cloud provides infrastructure automation as a service, is free to get started, and has an in-place upgrade to paid option. -- Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. +- Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. --- name: terraform-cloud-build @@ -620,7 +620,7 @@ class: review, no-footer 1. The adoption patterns we see, both among our large-scale users as well as individual contributors, involve multiple adaptive stages. The central idea remains uniform in that automation should be standardized as shared practice, and that governance guidelines are needed to support emerging requirements. -2. Terraform Cloud is not the same as Terraform OSS. Terraform Cloud is a cloud service, and Terraform OSS is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [OSS]. +2. Terraform Cloud is not the same as Terraform Community Edition. Terraform Cloud is a cloud service, and Terraform Community Edition is the technology used to provision infrastructure. We use Terraform Cloud to manage the lifecyle of infrastructure deployemnts using Terraform [Community]. --- name: Access-Control class: title, no-footer diff --git a/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md b/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md index d7383941..a5d41aef 100644 --- a/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md +++ b/instructor-guides/all_terraform_cloud_INSTRUCTOR_GUIDE.md @@ -45,7 +45,7 @@ Supercharge your Cloud infrastructure management with Terraform Cloud. Here's the workshop syllabus showing the topics we will cover: -1. OSS to Cloud/Enterprise +1. Community Edition to Cloud/Enterprise 🌥️ Terraform Cloud Overview 👨🏽‍🏫 Review the Basics 🔗 Configure Remote State diff --git a/instruqt-tracks/terraform-cloud-aws-v2/02-terraform-cloud-setup/check-workstation b/instruqt-tracks/terraform-cloud-aws-v2/02-terraform-cloud-setup/check-workstation index 8ad351de..de23a298 100755 --- a/instruqt-tracks/terraform-cloud-aws-v2/02-terraform-cloud-setup/check-workstation +++ b/instruqt-tracks/terraform-cloud-aws-v2/02-terraform-cloud-setup/check-workstation @@ -1,15 +1,32 @@ #!/bin/bash -l +# Copyright (c) HashiCorp, Inc. +set -euxvo pipefail + +# Get TFC token and organization +# these jq commands may fail, that's okay, we account for +# that later, so temporarily disable set -e +set +e +# Check to make sure these are the right paths +TFC_TOKEN=$(jq -r '.credentials."app.terraform.io".token' /root/.terraform.d/credentials.tfrc.json 2>/dev/null) set -e # Create /tmp/skip-check to disable this check +# This /tmp/skip-check file is only necessary for the instruqt track test command +# When running this track as a customer/participant, skipping is disabled so it +# this code will not have an affect. if [ -f /tmp/skip-check ]; then rm /tmp/skip-check exit 0 fi +# Save the Terraform Org and Workspace name as env variables export ORG=$(grep organization /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) export WORKSPACE=$(grep workspace /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) +# These are considered runtime variables, which allow you to use dynamic content in the challenge +# assignments and lifecycle scripts. +# In order to register a runtime variable in a host's lifecycle script, use the following command: +# agent variable set {KEY} {VALUE} agent variable set TF_ORG $ORG agent variable set TF_WORKSPACE $WORKSPACE @@ -19,9 +36,17 @@ cd /root/hashicat-aws sed -i "s/YOUR_ORGANIZATION/$ORG/g" remote_backend.tf sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" remote_backend.tf -cd /root/terraform-api -sed -i "s/YOUR_ORGANIZATION/$ORG/g" terraform.tfvars.example -mv terraform.tfvars.example terraform.tfvars +cp /root/hashicat-aws/terraform.tfvars.example /root/hashicat-aws/terraform.tfvars + +# This was originally going into the terraform-api directory... might need to check on this in the API challenge +cd /root/terraform-cloud +sed -i "s/YOUR_ORGANIZATION/$ORG/g" terraform.tfvars # This was originally looking in terraform.tfvars.example +sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" terraform.tfvars +# mv terraform.tfvars.example terraform.tfvars +# The above command will get rid of the terraform.tfvars.example file, but when +# we run the check script more than once, it cannot find that file bc it no longer +# exists. However, to keep the consistency between code blocks, we kept this the +# same as above where we search and replace in the remote_backend.tf file. # Store the ORG in /root/.bashrc grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc @@ -29,4 +54,67 @@ grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc # Store the WORKSPACE in /root/.bashrc grep $WORKSPACE /root/.bashrc || echo "export WORKSPACE=\"$WORKSPACE\"" >> /root/.bashrc -exit 0 +# Do we have a valid token +if [ -z "${TFC_TOKEN}" ]; then + fail-message "Unable to find Terraform Cloud Token, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/account/details 2>/dev/null) + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get account details, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Terraform Cloud Token is not valid, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +rm -f /tmp/.out.json +echo "We have a valid TFC token" + +# Is it a trial organization +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/organizations/"${ORG}" 2>/dev/null) # originally TFC_ORG + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get organization entitlements, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Unable to get TFC Organization Entitlements, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +TRIAL=$(jq -r '.data.attributes."plan-is-trial"' /tmp/.out.json 2>/dev/null) +if [ -z "${TRIAL}" ]; then + echo ".data.attributes.plan-is-trial was empty" + fail-message "Unable to determine TFC Trial Status, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +if [ "${TRIAL}" != "true" ]; then + echo ".data.attributes.plan-is-trial was '${TRIAL}' not 'true'" + fail-message "Your TFC Organization is not a trial one, please go back to the \"2- Terraform Cloud Trial Plan\" step" + exit 1 +fi + +exit 0 \ No newline at end of file diff --git a/instruqt-tracks/terraform-cloud-azure-v2/02-terraform-cloud-setup/check-workstation b/instruqt-tracks/terraform-cloud-azure-v2/02-terraform-cloud-setup/check-workstation index ec4fd105..a52e0718 100755 --- a/instruqt-tracks/terraform-cloud-azure-v2/02-terraform-cloud-setup/check-workstation +++ b/instruqt-tracks/terraform-cloud-azure-v2/02-terraform-cloud-setup/check-workstation @@ -1,9 +1,119 @@ #!/bin/bash -l +# Copyright (c) HashiCorp, Inc. set -euxvo pipefail +# Get TFC token and organization +# these jq commands may fail, that's okay, we account for +# that later, so temporarily disable set -e +set +e +# Check to make sure these are the right paths +TFC_TOKEN=$(jq -r '.credentials."app.terraform.io".token' /root/.terraform.d/credentials.tfrc.json 2>/dev/null) +set -e + # Create /tmp/skip-check to disable this check +# This /tmp/skip-check file is only necessary for the instruqt track test command +# When running this track as a customer/participant, skipping is disabled so it +# this code will not have an affect. if [ -f /tmp/skip-check ]; then rm /tmp/skip-check fi +# Save the Terraform Org and Workspace name as env variables +export ORG=$(grep organization /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) +export WORKSPACE=$(grep workspace /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) + +# These are considered runtime variables, which allow you to use dynamic content in the challenge +# assignments and lifecycle scripts. +# In order to register a runtime variable in a host's lifecycle script, use the following command: +# agent variable set {KEY} {VALUE} +agent variable set TF_ORG $ORG +agent variable set TF_WORKSPACE $WORKSPACE + +cp /root/hashicat-azure/remote_backend.tf.example /root/hashicat-azure/remote_backend.tf + +cd /root/hashicat-azure +sed -i "s/YOUR_ORGANIZATION/$ORG/g" remote_backend.tf +sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" remote_backend.tf + +cp /root/hashicat-azure/terraform.tfvars.example /root/hashicat-azure/terraform.tfvars + +# This was originally going into the terraform-api directory... might need to check on this in the API challenge +cd /root/terraform-cloud +sed -i "s/YOUR_ORGANIZATION/$ORG/g" terraform.tfvars # This was originally looking in terraform.tfvars.example +sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" terraform.tfvars +# mv terraform.tfvars.example terraform.tfvars +# The above command will get rid of the terraform.tfvars.example file, but when +# we run the check script more than once, it cannot find that file bc it no longer +# exists. However, to keep the consistency between code blocks, we kept this the +# same as above where we search and replace in the remote_backend.tf file. + +# # Store the ORG in /root/.bashrc +# grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc + +# # Store the WORKSPACE in /root/.bashrc +# grep $WORKSPACE /root/.bashrc || echo "export WORKSPACE=\"$WORKSPACE\"" >> /root/.bashrc + +# Do we have a valid token +if [ -z "${TFC_TOKEN}" ]; then + fail-message "Unable to find Terraform Cloud Token, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/account/details 2>/dev/null) + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get account details, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Terraform Cloud Token is not valid, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +rm -f /tmp/.out.json +echo "We have a valid TFC token" + +# Is it a trial organization +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/organizations/"${ORG}" 2>/dev/null) # originally TFC_ORG + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get organization entitlements, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Unable to get TFC Organization Entitlements, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +TRIAL=$(jq -r '.data.attributes."plan-is-trial"' /tmp/.out.json 2>/dev/null) +if [ -z "${TRIAL}" ]; then + echo ".data.attributes.plan-is-trial was empty" + fail-message "Unable to determine TFC Trial Status, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +if [ "${TRIAL}" != "true" ]; then + echo ".data.attributes.plan-is-trial was '${TRIAL}' not 'true'" + fail-message "Your TFC Organization is not a trial one, please go back to the \"2- Terraform Cloud Trial Plan\" step" + exit 1 +fi + exit 0 diff --git a/instruqt-tracks/terraform-cloud-gcp-v2/02-terraform-cloud-setup/check-workstation b/instruqt-tracks/terraform-cloud-gcp-v2/02-terraform-cloud-setup/check-workstation index f76e40a8..b1c54482 100755 --- a/instruqt-tracks/terraform-cloud-gcp-v2/02-terraform-cloud-setup/check-workstation +++ b/instruqt-tracks/terraform-cloud-gcp-v2/02-terraform-cloud-setup/check-workstation @@ -1,15 +1,32 @@ #!/bin/bash -l +# Copyright (c) HashiCorp, Inc. +set -euxvo pipefail + +# Get TFC token and organization +# these jq commands may fail, that's okay, we account for +# that later, so temporarily disable set -e +set +e +# Check to make sure these are the right paths +TFC_TOKEN=$(jq -r '.credentials."app.terraform.io".token' /root/.terraform.d/credentials.tfrc.json 2>/dev/null) set -e # Create /tmp/skip-check to disable this check +# This /tmp/skip-check file is only necessary for the instruqt track test command +# When running this track as a customer/participant, skipping is disabled so it +# this code will not have an affect. if [ -f /tmp/skip-check ]; then rm /tmp/skip-check exit 0 fi +# Save the Terraform Org and Workspace name as env variables export ORG=$(grep organization /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) export WORKSPACE=$(grep workspace /root/terraform-cloud/terraform.tfvars | cut -d '"' -f2) +# These are considered runtime variables, which allow you to use dynamic content in the challenge +# assignments and lifecycle scripts. +# In order to register a runtime variable in a host's lifecycle script, use the following command: +# agent variable set {KEY} {VALUE} agent variable set TF_ORG $ORG agent variable set TF_WORKSPACE $WORKSPACE @@ -19,9 +36,17 @@ cd /root/hashicat-$CLOUD_ENV sed -i "s/YOUR_ORGANIZATION/$ORG/g" remote_backend.tf sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" remote_backend.tf -cd /root/terraform-api -sed -i "s/YOUR_ORGANIZATION/$ORG/g" terraform.tfvars.example -mv terraform.tfvars.example terraform.tfvars +cp /root/hashicat-$CLOUD_ENV/terraform.tfvars.example /root/hashicat-$CLOUD_ENV/terraform.tfvars + +# This was originally going into the terraform-api directory... might need to check on this in the API challenge +cd /root/terraform-cloud +sed -i "s/YOUR_ORGANIZATION/$ORG/g" terraform.tfvars # This was originally looking in terraform.tfvars.example +sed -i "s/YOUR_WORKSPACE/$WORKSPACE/g" terraform.tfvars +# mv terraform.tfvars.example terraform.tfvars +# The above command will get rid of the terraform.tfvars.example file, but when +# we run the check script more than once, it cannot find that file bc it no longer +# exists. However, to keep the consistency between code blocks, we kept this the +# same as above where we search and replace in the remote_backend.tf file. # Store the ORG in /root/.bashrc grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc @@ -29,4 +54,69 @@ grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc # Store the WORKSPACE in /root/.bashrc grep $WORKSPACE /root/.bashrc || echo "export WORKSPACE=\"$WORKSPACE\"" >> /root/.bashrc +# VCDL-103 +# Do we have a valid token +if [ -z "${TFC_TOKEN}" ]; then + fail-message "Unable to find Terraform Cloud Token, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/account/details 2>/dev/null) + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get account details, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Terraform Cloud Token is not valid, please double-check the \"3- Terraform Cloud Token\" steps" + exit 1 +fi + +rm -f /tmp/.out.json +echo "We have a valid TFC token" + +# VCDL-103 +# Is it a trial organization +STATUS=$(curl \ + --header "Authorization: Bearer ${TFC_TOKEN}" \ + --header "Content-Type: application/vnd.api+json" \ + --request GET \ + -w "%{response_code}" \ + -s \ + -o /tmp/.out.json \ + https://app.terraform.io/api/v2/organizations/"${ORG}" 2>/dev/null) # originally TFC_ORG + +if [ "${STATUS}" != "200" ]; then + echo "Failed to get organization entitlements, status ${STATUS}" + if [ -f /tmp/.out.json ]; then + echo "Output was:" + cat /tmp/.out.json + echo "End of output" + fi + fail-message "Unable to get TFC Organization Entitlements, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +TRIAL=$(jq -r '.data.attributes."plan-is-trial"' /tmp/.out.json 2>/dev/null) +if [ -z "${TRIAL}" ]; then + echo ".data.attributes.plan-is-trial was empty" + fail-message "Unable to determine TFC Trial Status, please go back to the \"2- Terraform Cloud Trial Plan\" steps" + exit 1 +fi + +if [ "${TRIAL}" != "true" ]; then + echo ".data.attributes.plan-is-trial was '${TRIAL}' not 'true'" + fail-message "Your TFC Organization is not a trial one, please go back to the \"2- Terraform Cloud Trial Plan\" step" + exit 1 +fi + exit 0 diff --git a/instruqt-tracks/terraform-cloud-gcp-v2/03-centralize-deployments/assignment.md b/instruqt-tracks/terraform-cloud-gcp-v2/03-centralize-deployments/assignment.md index 8b605614..0fbcac7e 100755 --- a/instruqt-tracks/terraform-cloud-gcp-v2/03-centralize-deployments/assignment.md +++ b/instruqt-tracks/terraform-cloud-gcp-v2/03-centralize-deployments/assignment.md @@ -1,5 +1,6 @@ --- slug: centralize-deployments +id: 1xxg9xarqcbi type: challenge title: Safekeeping Your Terraform State teaser: | @@ -108,7 +109,7 @@ The objective of this challenge is to configure remote state using your Terrafor * Set the `prefix` variable to your name or a prefered pseudonym. If you use multiple words, use hyphens or underscores between words, and keep it all lower case. - * Optionally modify the `region` to a valid Google Cloud region such as "us-east-1", "us-west-1", "eu-west-2", or "ap-southeast-1". + * Optionally modify the `region` to a valid Google Cloud region such as "us-east1", "us-west1", "europe-west2", or "asia-southeast1". 2- Deploy the hashicat application ===