Maintain Infrastructure with Terraform
Import existing resources, inspect state, and troubleshoot Terraform operations.
Maintaining infrastructure with Terraform involves ongoing management of your deployed resources throughout their lifecycle. This process encompasses several key practices that ensure your infrastructure remains consistent, secure, and aligned with your desired state. State Management is fundament…
Concepts covered: The terraform import command, Import blocks in configuration, Writing configuration for imported resources, Import workflow and best practices, The terraform state command, terraform state list and show, terraform state mv and rm, terraform output command, TF_LOG environment variable, Log levels and debugging, Troubleshooting provider issues
TA-004 - Maintain Infrastructure with Terraform Example Questions
Test your knowledge of Maintain Infrastructure with Terraform
Question 1
You are managing a multi-environment Terraform setup for a healthcare organization. After a recent deployment, you discovered that a Lambda function resource 'aws_lambda_function.patient_processor' was imported into the wrong workspace state file. The resource currently exists in the 'staging' workspace state but should be managed by the 'production' workspace. The Lambda function is actively processing patient data and must remain operational throughout the transition. Your team needs to transfer this resource's state entry between workspaces while maintaining the existing infrastructure. What sequence of terraform state commands should you use to accomplish this transfer?
Question 2
A DevOps engineer at a logistics company is using Terraform 1.5+ to import several existing AWS Security Groups into infrastructure-as-code management. The engineer creates import blocks for three security groups and runs terraform plan. The plan output shows that two security groups will be imported successfully, but one security group displays an error stating 'Resource instance not found' even though the security group ID in the import block has been copied from the AWS console. The engineer has verified network connectivity and AWS credentials are working correctly for the other two imports. What is the most likely cause of this import failure?
Question 3
What is the primary purpose of the TF_LOG environment variable when troubleshooting Terraform provider issues?