Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Migrate an Existing Terraform Project into Terraform Cloud

In this hands-on lab, we will take an existing Terraform configuration and convert it to run the code using Terraform Cloud. We will use the CLI-driven method to deploy our resources to AWS with Terraform Cloud doing the bulk of the work.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 0m
Published
Clock icon Dec 15, 2022

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Prepare the Environment

    1. Log in to the lab instance.

    2. Clone the lab repo to your lab machine:

      git clone https://github.com/ACloudGuru-Resources/content-introduction-terraform-cloud-lab.git
      
    3. Create the terraform-guru organization.

    4. Select CLI-driven workflow.

    5. Create the terraform-cloud-guru workspace.

    6. Create a variable set by going to your workspace settings and then Variable sets. Click Create variable set.

    7. Use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

    8. In the AWS Management Console, create an access key for the cloud_user and secret access key, and use those values for the variable set.

    9. In the user settings, create a token for the CLI to use with Terraform Cloud called terraform-cloud. You must copy the key, run terraform login in your terminal, and follow the prompts.

  2. Challenge

    Migrate the Existing Terraform Project into Terraform Cloud

    1. Modify the main.tf file, and add the Terraform Cloud config.
    2. Add the Terraform variables in Terraform Cloud for your workspace for the ami, instance_count,instance_type, and subnet

      Note: You will need to look this up from the console or CLI. All other variables will be in the variables.tf file.

    3. Modify the variables so they use the Terraform Cloud variables.
  3. Challenge

    Deploy the EC2 Instances with Terraform Cloud

    1. Initialize your working directory.
    2. Validate your code.
    3. Apply your configuration, and view it in your terminal and Terraform Cloud Runs section.
    4. Check the AWS Management Console to verify the instances were created.
  4. Challenge

    Create a Terraform Module from Existing Code

    1. Create a GitHub repo called terraform-as-ec2-psacg.
    2. Add the Terraform Cloud application, and configure it.
    3. Add the module configuration to your repo called main.tf.
    4. Add a tag to the repo of 1.0.0.
    5. Add the module to Terraform Cloud Registry.
  5. Challenge

    Modify the Terraform Configuration to use the Module and Redeploy

    1. Edit the main Terraform configuration to use the module.
    2. Initialize the Terraform working directory.
    3. Validate the syntax.
    4. Apply your new configuration.
    5. Confirm the changes.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans