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).
Regards.
Aditya
apply
ordestroy
which is when Terraform is actually making changes. As you've noticed, you can runterraform refresh
to force a refresh and update the state file but this isn't normally required. – ydaetskcoR-refresh=true
flag, which is the same as runningtf refresh
before the plan. I agree that this shouldn't be necessary unless you've got something else wrong but it is possible. – Software EngineerThis command is a convenient way to check whether the execution plan for a set of changes matches your expectations without making any changes to real resources or to the state
. It does run a refresh, but it doesn't say that it updates the state file, it explicitly states that it doesn't. – Software Engineer