Troubleshooting a Terraform State Sync Issue

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Hey there, Gurus! Welcome to the lab! This lab will demonstrate how to troubleshoot a Terraform state sync issue. We will attempt to go through the different stages of deployment by trying to deploy our configuration and work through the state sync issue until we have successfully deployed our resources.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Deploy Your Backend Resources

1) In the terminal, once logged into your instance, change to the s3 directory.
2) In the s3 directory, edit the file to either append a number or rename the bucket name in the file.
3) Run the terraform fmt command.
4) Now initialize your working directory.
5) If initialization is successful, then apply your code and deploy your resources.

Create Your Resources

1) Now change to the terraform directory.
2) In the terraform directory, edit the file and add in subnet_id from the resource_ids.txt file.
3) Run the terraform fmt command.
4) Edit the file and change the bucket name to the bucket name you used in the file.
5) Now initialize your working directory.
6) If initialization is successful, then move step by step until you create your resources.

Troubleshoot Error

1) Now edit the terraform.tfvars file and uncomment the region value.
2) Run the terraform plan -refresh-only command.
3) Fix the error and run the terraform plan -refresh-only command again.
4) Lab is complete when your resources are deployed and the sync error is gone.

Additional Resources

Here is the scenario:

You are an admin who supports one of the largest online comic book retailers in the world. You are one of a handful of admins who have been assigned to use Terraform to manage the company's cloud deployments. You are being asked to create a new dev environment to test out new features of the company's site. You have your configuration that will create the app servers for the dev site. You have your code ready and started the deployment process, but you have run into a state sync issue. You are not the only one who is working on this configuration, and there is a possibility that you could have an issue with your backend or another admin added a resource to your dev cloud environment manually. You will need fix the error and successfully deploy your app servers in AWS using Terraform to complete this lab. Let’s get started!

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?