Difficulty: Beginner
Estimated Time: 15 minutes

Terraform Cloud

In this hands-on lab, you'll use the free tier of the hosted Terraform Cloud service to securely save state and execute Terraform remotely. This is a great way to collaborate and secure your Terraform deployments.

In this demo, you'll perform three major tasks:

  • Initialize a local Terraform configuration (using the random_pet provider)
  • Configure a Terraform Cloud token on the local workstation
  • Migrate the existing Terraform workspace to Terraform Cloud

We've installed Terraform for you and have given you a small project, so it's ready to go. Let's get started!

Congratulations!

You've configured a project to run on Terraform Cloud.

Continue your education by reading more about Terraform and Terraform Cloud at HashiCorp Learn. Detailed documentation is available at terraform.io.

Terraform Cloud

Step 1 of 3

Initialize a Local Terraform Configuration

Initialize a Local Terraform Configuration

Start by running Terraform locally on a project we've created for you.

This Terraform config uses the random_pet provider to generate a random name like endless-mastodon or feasible-cougar. It doesn't require any credentials and it won't cost any money to run.

Change into the project directory:

cd ~/random-pet-demo

Initialize the project:

terraform init

Apply the configuration. You'll be asked to confirm by typing "yes", and then the name of an animal will be printed as an output.

terraform apply

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

random_pet.server: Creating...
random_pet.server: Creation complete after 0s [id=feasible-cougar]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

random_server_id = feasible-cougar

In the next step, you'll execute this configuration on Terraform Cloud.