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.

This lab serves as a companion piece to the Migrate State to Terraform Cloud Learn Tutorial.

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

  • Initialize a local Terraform configuration (using the random_pet provider) in your Katacoda session
  • 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!


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.

Migrate State to Terraform Cloud

Step 1 of 3

Initialize a Local Terraform Configuration

Initialize a Local Terraform Configuration

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 ~/learn-state-migration

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.


random_server_id = feasible-cougar

In the next step, you'll migrate this configuration to Terraform Cloud to leverage remote execution and remote state storage.