Troubleshooting a Terraform Locked State File Issue

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

This lab will demonstrate how to troubleshoot a Terraform locked state file issue. We will attempt to go through the different stages of deployment to try and deploy our configuration and work through the locked state file 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 and 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 the Lock
  1. Now change to the terraform directory.
  2. In the terraform directory, edit the file and add in your ami ,subnet_id, and vpc 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 untill you get to the apply stage.
  7. Run the terraform apply command but DO NOT type yes to confirm. Leave it at this step.
Troubleshoot the Error and Deploy Your Resources
  1. In a new terminal session, log in to your lab instance.
  2. Go to the terraform directory.
  3. Run the terraform apply command.
  4. Fix the lock file error and deploy your resources to complete this lab.

Additional Resources

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 start to create a new dev environment to test out new features of the company's site. You have your configuration created, which will create the app servers for the dev site. You have your code ready and start the deployment process, but you have run into a locked state file issue. You are not the only one who is working on this configuration, but you know the other person has finished their deployment. You will need to 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?