0

For some unknown reason, the removed items remain in the state file after I remove from the .tfstate file.

CASE:

  1. downloaded my state file(my_statefile.tfstate) from cloud_bucket where it's stored
  2. In the application cloned repo, I placed the file in the folder that contains the items I want to remove from the state
  3. ran terraform init
  4. ran terraform state list -state=my_statefile.tfstate
output:
item 1
item 2
item 3
  1. ran terraform state rm -state=my_statefile.tfstate item1
  2. ran terraform state list -state=my_statefile.tfstate
output:
item 2
item 3

However when I inspect the file with cat my_statefile.tfstate

the item 1 is still there..

I even created a empty file called empty.tfstate and tried the flow described above and got the same results which is kind of odd.

Does anyone have any clues on what can be happening here?

3
  • 2
    Presumably because you are still interacting with the remote state, the local file simply does not matter and is entirely ignored. Commented Nov 21, 2024 at 18:09
  • good point it can be true, so why the remote state file in the cloud_bucket is also not getting changed? what would trigger that change Commented Nov 21, 2024 at 18:14
  • 1
    Evidently the state is changed based on the changed state list output. Wherever that state is stored it got updated. If the file in the bucket is not changing then it is not the actual state file, simple as that. Commented Nov 21, 2024 at 18:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.