Search code examples
terraform

'terraform plan' NOT updating state file


Tried the following:

Resource creation(ec2) using terraform>>manually edit a resource(changed type) from AWS console>>run 'terraform plan'>>shows changes required after doing 'terraform refresh' internally BUT state file is not getting updated?

Looks like some bug.

(article states refresh is done automatically, it should affect the state file?- https://www.terraform.io/docs/cli/commands/plan.html)

I note that Manually running 'terraform refresh' updates the state file to reflect present state of infrastructure(which then would be compared with config file ie desired state).


Solution

  • Thanks @Software Engineer

    The second para explicitly mentions that 'state' is not affected. So in summary, its not treated like a normal 'terraform refresh'. IMAGE

    https://www.terraform.io/docs/cli/commands/plan.html