hands-on lab

Using Terraform Remote State

Beginner
Up to 45m
2,977
4.6/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Terraform state is a critical component of using Terraform. However, there are many risks involved when storing the state file locally on a computer. The state file can contain sensitive information about the infrastructure, such as keys and passwords. Saving them to an engineer's laptop is not a great long-term solution. Also, as teams start utilizing Terraform and managing resources, they need a way to centrally store the state file so that everyone has access to run Terraform commands against the same infrastructure.

Additionally, this centralized storage solution needs to have a system to prevent the same state file from being used simultaneously. This is why Terraform can be configured to use a remote state feature, where the state file is stored in a remote location, and a feature called state file locking is introduced. Remote state can be used with native AWS services like S3 and DynamoDB.

In this lab, you will create an S3 Bucket and DynamoDB Table and configure remote state for a Terraform Configuration.

Learning objectives

Upon completion of this beginner-level lab, you will be able to:

  • Understand how Terraform remote state works
  • Learn the benefits of remote state

Intended audience

This lab is intended for:

  • Individuals studying to take the HashiCorp Certified: Terraform Associate exam
  • Anyone interested in learning how to use Terraform to manage Cloud Service Providers

Prerequisites

You should be familiar with:

  • Cloud Services
  • DevOps
  • Basic understanding of Terraform state

The following course and lab can be used to fulfill the prerequisites:

Updates

March 11th, 2024 - Resolve validation check issue

Environment before

Environment after

About the author

Students
20,245
Labs
42
Courses
1
Learning paths
15

Luke is a Site Reliability Engineer at Microsoft. His background is infrastructure development using Terraform and in 2021 he was awarded the HashiCorp Ambassador award. He is an Azure DevOps Engineer Expert, Azure Administrator Associate, and HashiCorp Certified - Terraform Associate.

Covered topics

Lab steps

Configuring Remote State with Terraform