Tuesday, May 23, 2023
HomeSoftware EngineeringThe right way to Refresh State in Terraform

The right way to Refresh State in Terraform


Typically your infrastructure could also be out of sync together with your Terraform state as a result of assets could have been amended or deleted manually.

For this you possibly can refresh the Terraform state.

Utilizing the refresh command

terraform refresh [options]

Why this command could seem unusual at first, not that it’s merely an alias for:

terraform apply -refresh-only -auto-approve

For those who don’t need to auto-approve the transaction, then you possibly can carry out a refresh as follows:

terraform apply -refresh-only

For those who use a var-file to specify atmosphere particular configuration, then you are able to do the next:

terraform apply -refresh-only -var-file ./path/to/dev.tfvars

And auto-approve as follows:

terraform apply -refresh-only -var-file ./path/to/dev.tfvars --auto-approve
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments