Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf state file not updated if the terraform execution is interrupted #35386

Closed
divam20 opened this issue Jun 26, 2024 · 3 comments
Closed

tf state file not updated if the terraform execution is interrupted #35386

divam20 opened this issue Jun 26, 2024 · 3 comments
Labels
bug new new issue not yet triaged v0.12 Issues (primarily bugs) reported against v0.12 releases waiting-response An issue/pull request is waiting for a response from the community

Comments

@divam20
Copy link

divam20 commented Jun 26, 2024

Terraform Version

Terraform 0.12.29

Terraform Configuration Files

...terraform config...

Debug Output

NA

Expected Behavior

Since the terraform execution failed, the tfd plan should have shown the output that these resources need to be recreated or show only the resources which were not created in the previous execution of terraform.

Actual Behavior

Terraform was trying to create all the resources again and the state file was not updated

Steps to Reproduce

terraform init
terraform plan
terraform apply
Ctrl + C
terraform plan

Note: This is not happening everytime

Additional Context

No response

References

No response

@divam20 divam20 added bug new new issue not yet triaged labels Jun 26, 2024
@liamcervante
Copy link
Member

Hi @divam20, thanks for filing this. The version of Terraform you are using (v0.12.29) is nearing 4 years old, it is possible that the state file management story has been improved since then. Are you able to test this with the latest release (v1.8.5) and confirm that this is still a concern? Thanks!

@liamcervante liamcervante added the waiting-response An issue/pull request is waiting for a response from the community label Jun 26, 2024
@apparentlymart apparentlymart added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Jun 26, 2024
@apparentlymart
Copy link
Contributor

The intended behavior for current versions of Terraform is that the first interrupt during an apply causes Terraform to write a state snapshot as soon as possible, tell providers that they should safely cancel any active operations as an as possible, and then aggressively write new state snapshots each time one of the active operations completes in a way that would update the state. A second interrupt caused Terraform to quit immediately, which is likely to cause state data loss.

I don't remember when the above behaviors were each added. It is quite possible that Terraform v0.12 is too old to behave in this way.

@jbardin
Copy link
Member

jbardin commented Aug 5, 2024

Since we have not heard back in a while I'm going to close the issue. If you have any updates regarding the issue, feel free to open a new issue with the requested information. If you have more questions, you can also use the community forum where there are more people ready to help.

Thanks!

@jbardin jbardin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged v0.12 Issues (primarily bugs) reported against v0.12 releases waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

No branches or pull requests

4 participants