Using Terraform CLI, how do you update the state file of your infrastructure with metadata that matches the physical resources they are tracking?
Experience Level: Junior
Tags: Terraform
Answer
Run the following command:
terraform refresh
The refresh is also executed when you run terraform plan or terraform apply.
This will not modify your infrastructure, but it can modify your state file to update metadata. This metadata might cause new changes to occur when you generate a plan or call apply next.
Related Terraform job interview questions
Using Terraform CLI, how do you create a new workspace?
Terraform JuniorUsing Terraform CLI, how do you display list of Terraform workspaces?
Terraform JuniorUsing Terraform CLI, how do you remove locally-stored credentials for specified hostname of Terraform Enterprise?
Terraform JuniorUsing Terraform CLI, how do you retrieve authentication token for the given hostname to Terraform Enterprise?
Terraform JuniorUsing Terraform CLI, how do you check what files need to be reformatted to standard formatting without rewriting the files?
Terraform Junior