0
0
Terraformcloud~20 mins

Terraform state mv for refactoring - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform State Refactoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does the Terraform command terraform state mv do?
Choose the best description of what terraform state mv accomplishes during infrastructure refactoring.
AIt refreshes the Terraform state to match the current real infrastructure without changing resource addresses.
BIt deletes resources from the cloud provider and removes them from the Terraform state.
CIt moves resources in the Terraform state file from one address to another without changing the real infrastructure.
DIt creates new resources in the cloud provider and adds them to the Terraform state.
Attempts:
2 left
💡 Hint
Think about how Terraform tracks resources internally versus what happens in the cloud.
Configuration
intermediate
2:00remaining
Which terraform state mv command correctly renames a resource?
You have a resource named aws_instance.old_name and want to rename it to aws_instance.new_name in the Terraform state. Which command will do this correctly?
Aterraform state mv aws_instance.old_name aws_instance.new_name
Bterraform state mv aws_instance.new_name aws_instance.old_name
Cterraform state mv aws_instance.old_name new_name
Dterraform state mv old_name aws_instance.new_name
Attempts:
2 left
💡 Hint
The first argument is the current resource address, the second is the new address.
Architecture
advanced
2:00remaining
What is the impact of using terraform state mv on the actual cloud infrastructure?
After running terraform state mv to rename a resource in the state file, what happens to the real resource in the cloud provider?
AThe real resource is renamed or recreated in the cloud provider to match the new state address.
BThe real resource remains unchanged; only the Terraform state file is updated.
CThe real resource is deleted and a new one is created with the new name.
DTerraform pauses and waits for manual confirmation before changing the real resource.
Attempts:
2 left
💡 Hint
Consider what Terraform state represents versus actual cloud resources.
security
advanced
2:00remaining
What security risk can arise if terraform state mv is used incorrectly during refactoring?
If you move a resource in the Terraform state to a wrong address or to a resource managed by another team, what security risk might occur?
ATerraform might overwrite or destroy resources managed by others, causing data loss or service disruption.
BTerraform will encrypt the state file automatically, preventing any risk.
CTerraform will block any state move that affects resources outside your account.
DThere is no security risk because state moves only affect local files.
Attempts:
2 left
💡 Hint
Think about what happens if Terraform thinks it owns resources it does not.
Best Practice
expert
2:00remaining
What is the recommended best practice before running terraform state mv in a team environment?
Before moving resources in the Terraform state file during refactoring, what should you do to avoid conflicts and errors?
ARun <code>terraform apply</code> immediately after <code>terraform state mv</code> without informing anyone.
BIgnore state locking because <code>terraform state mv</code> only changes local files.
CDelete the remote state file and recreate it after the move.
DLock the Terraform state to prevent concurrent changes and communicate the change to the team.
Attempts:
2 left
💡 Hint
Think about how teams share Terraform state and avoid race conditions.