TA-002-P · Question #356
You have modified your Terraform configuration to fix a typo in the Terraform ID of a resource from aws_security_group.http to aws_security_group.http Which of the following commands would you run…
The correct answer is C. terraform mv aws-security-group.htp aws-security-group.http. The correct command is 'terraform state mv' (shown as 'terraform mv' in the choices), which renames a resource's address in the state file without destroying or recreating the underlying infrastructure. This is the right approach when you rename a Terraform resource label in…
Question
You have modified your Terraform configuration to fix a typo in the Terraform ID of a resource from aws_security_group.http to aws_security_group.http Which of the following commands would you run to update the ID in state without destroying the resource?
Options
- Aterraform refresh
- Bterraform apply
- Cterraform mv aws-security-group.htp aws-security-group.http
How the community answered
(29 responses)- A7% (2)
- B14% (4)
- C79% (23)
Explanation
The correct command is 'terraform state mv' (shown as 'terraform mv' in the choices), which renames a resource's address in the state file without destroying or recreating the underlying infrastructure. This is the right approach when you rename a Terraform resource label in your configuration - Terraform would otherwise see the old name as deleted and the new name as a new resource to create. Note: the actual CLI command is 'terraform state mv', and the resource type uses underscores (aws_security_group), not hyphens. The question contains minor typos but tests the correct concept. 'terraform refresh' and 'terraform apply' would not rename state entries; apply would destroy and recreate the resource.
Topics
Community Discussion
No community discussion yet for this question.