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 thes3
directory, edit theS3.tf
file to either append a number or rename the bucket name in the file.
3) Run theterraform 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 theterraform
directory, edit themain.tf
file and add insubnet_id
from theresource_ids.txt
file.
3) Run theterraform fmt
command.
4) Edit thebackend.tf
file and change the bucket name to the bucket name you used in theS3.tf
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 theregion
value.
2) Run theterraform plan -refresh-only
command.
3) Fix the error and run theterraform plan -refresh-only
command again.
4) Lab is complete when your resources are deployed and the sync error is gone.