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

Exploring Terraform State Functionality

Understanding and being comfortable with Terraform state is crucial to mastering it. In this hands-on lab, we will deploy resources using Kubernetes, a container orchestration tool, and see how Terraform maintains a state file to track changes and deploy containers declaratively.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon Mar 29, 2021

Contact sales

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

Table of Contents

  1. Challenge

    Check Terraform and Minikube Status

    1. Check that Terraform is installed and functioning properly using the terraform version command.
    2. Check that the Kubernetes backedn process minikube is running properly using the minikube status command.
  2. Challenge

    Clone Terraform Code and Switch to the Proper Directory

    1. The Terraform code required for this lab has already been cloned onto the provided VM.
    2. Switch to the directory where the code is located to perform the remaining tasks:
    lab_code/section2-hol1
    
    1. View the code in the main.tf file to see what has been configured for deployment.
  3. Challenge

    Deploy Terraform Code And Observe the State File

    1. Initialize the working directory and download the required providers.
    2. Review the actions that will be performed when code is deployed using the terraform plan command.
    3. Deploy the code with the terraform apply command.
    4. List the files and verify that the state file was created.
    5. List all the resources being tracked by the Terraform state file using the terraform state command.
    6. View the replicas being tracked by the Terraform state file and note the number.
    7. Modify the replicas attribute in the Terraform code and deploy the code again.
    8. View the replicas being tracked by the Terraform state file and verify that the number has changed.
    9. Remove the infrastructure you created using the terraform destroy command. However, note that Terraform leaves behind a terraform.tfstate.backup file in case you need to recover to the last deployed Terraform state.

    As you make your way through this objective, you may also choose to verify that the number of pods configured in the code were created and that this number changes as you modify the replicas attribute in your code using the kubectl command.

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