Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCDL-208 changing region names valid in GCP #400

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/slides/aws/terraform-cloud-v2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/slides/azure/terraform-cloud-v2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/slides/gcp/terraform-cloud-v2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -19,14 +36,85 @@ 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

# 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
Original file line number Diff line number Diff line change
@@ -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
Loading