Hi all,
I’m looking for a piece of advice about my issue.
today my CI is using terragrunt & terraform image version 0.12.x,
I started to upgrade our IaC to the latest version of Terraform 1.0.0.
step 1 was to upgrade all my modules to version 0.13 via terraform 0.13upgrade then terraform plan && terraform apply, the state file was updated successfully to the latest version of 0.13.x
step 2 continue to update plan & apply even if there were no changes in the IaC until the latest version.
what I have noticed is that some of my state files were updated to the latest version of 1.0.0, and other state files were not updated at all and stay in version 0.13.x, or 0.14.x, or 0.15.x
also, I have noticed that the S3 bucket state file timestamp did not change.
question:
- if there are no changes in the infrastructure himself self does apply still update the state file with the new terraform execution version?
Thanks,
Hi @mfinkelstine,
Terraform will typically not create a new state snapshot unless it’s taken some actions itself that would change what’s recorded in there. If you run terraform apply
and it reports “No changes” then it will not create a new state snapshot in that case, and so the latest snapshot in your bucket would still reflect the version of Terraform which created that snapshot.
There are some other commands that can create state snapshots even though Terraform itself hasn’t taken any actions. For example, if you run terraform apply -refresh-only
then Terraform might detect that values have changed in your real infrastructure and offer to create a new state snapshot reflecting those. Separately, state-manipulation commands like terraform import
and terraform state rm
will create new state snapshots as part of their work, even though they don’t make any changes to your real infrastructure objects.
Hi @apparentlymart ,
first thank you for your reply,
let be clear in what you say, terraform does not update the state file if there are no changes in my IaC even if I run it with a new version of terrafrom.
also, I have some cases that I have Infra changes and the state still did not updated the changes with the new terraform version that was applied with the command.
THanks