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.

Comments

No Comments Yet.
Be the first to tell us what you think.
Terraform CLI
Terraform CLI

Are you learning Terraform ? Try our test we designed to help you progress faster.

Test yourself