0
0
Terraformcloud~10 mins

Terraform state mv for refactoring - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to move a Terraform resource state from old to new address.

Terraform
terraform state mv [1] new_resource_name
Drag options to blanks, or click blank then click option'
Aterraform plan
Bterraform apply
Cold_resource_name
Dterraform init
Attempts:
3 left
💡 Hint
Common Mistakes
Using Terraform commands like apply or plan instead of resource names.
Forgetting to specify the current resource address.
2fill in blank
medium

Complete the code to move the resource state to a new module path.

Terraform
terraform state mv old_resource_name [1]
Drag options to blanks, or click blank then click option'
Aterraform init
Bterraform apply
Cterraform plan
Dmodule.new_module.aws_resource.new_resource_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using Terraform commands instead of resource addresses.
Omitting the module path when moving resources into modules.
3fill in blank
hard

Fix the error in the command to move a resource state to a new name.

Terraform
terraform state mv [1] new_resource_name
Drag options to blanks, or click blank then click option'
Aold_resource_name
Bterraform plan
Cterraform apply
Dterraform state mv
Attempts:
3 left
💡 Hint
Common Mistakes
Using Terraform commands like apply or plan as arguments.
Missing the current resource address.
4fill in blank
hard

Fill both blanks to move a resource from root to a nested module.

Terraform
terraform state mv [1] [2]
Drag options to blanks, or click blank then click option'
Aaws_instance.old_name
Bmodule.nested_module.aws_instance.new_name
Cterraform apply
Dterraform plan
Attempts:
3 left
💡 Hint
Common Mistakes
Using Terraform commands as resource addresses.
Not including the module path in the new address.
5fill in blank
hard

Fill both blanks to move and rename a resource inside a module.

Terraform
terraform state mv [1] [2]
Drag options to blanks, or click blank then click option'
Amodule.old_module.aws_s3_bucket.old_bucket
Bmodule.new_module.aws_s3_bucket.new_bucket
C-state=terraform.tfstate
D-backup=backup.tfstate
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing resource addresses with Terraform commands.
Using command flags like -state instead of resource addresses.