terraform
terraform copied to clipboard
Not able to refresh state for existing aw resource
Terraform v0.15.4 on darwin_amd64
- provider registry.terraform.io/hashicorp/aws v3.47.0
- provider registry.terraform.io/hashicorp/template v2.2.0
I am trying to transfer the state from one git repo to another one. So in the old one I did
terraform st rm ADDRESS
which was successful
When trying to refresh the state in the target repository I have the following issue:
terraform plan -refresh-only
╷
│ Error: Invalid refresh-only plan
│
│ Terraform generated planned resource changes in a refresh-only plan. This is a bug in Terraform.
here is a link with logs
Hi @novtor! Thanks for reporting this.
The behavior you described here seems similar to another bug we fixed in a later version of Terraform than the one you are currently using. Could you try again with the latest Terraform v1.0.x release and see if you get a better result?
(Note that Terraform v1.0.x is the continuation of v0.15.x so in spite of the numbering change it is effectively only a minor release update compared to your current v0.15.4, with no intentional breaking changes.)
thank you for your reply, @apparentlymart . I upgraded to Terraform v1.0.1 but still have the same issue
Thanks for confirming, @novtor!
Unfortunately when I tried to access the logs link you included in your comment I got a 404 error. Have you deleted the gist that you shared? :thinking:
Hopefully the logs will be enough to understand what happened here but we might well need to see your configuration in order to construct a reproduction case so we can debug locally, and so if you could include that too that will hopefully avoid another round-trip if we find that the logs haven't captured enough detail. Thanks!
I am working with the azurerm provider. I am aware of it happening in terraform versions 1.0.0 and 1.0.1. And azurerm provider since the last version 1 of terraform came out.
I have tried the following possibilities to refresh the tfstate and none of them work:
- terraform refresh
- terraform plan
- terraform plan -refresh-only
- terraform apply
I also ran into this today with an aws_elasticache_cluster that had been deleted outside of TF. Workaround is to use terraform state rm <item>.
Tested with latest modules from aws and TF 1.0.3
I am having the same problem on Terraform 1.0.3
@apparentlymart I think this bug is a larger issue than is being realized. I do not think Terraform is acting properly when the tfstate file is empty (e.g. in a new workspace). When I try to do refresh-only I get the referenced error message ("Terraform generated planned resource changes in a refresh-only plan. This is a bug in Terraform."). HOWEVER, it appears that even if a regular terraform apply is done, the state is not refreshing correctly. Most notably, I get errors that IAM roles already exist and therefore cannot be created, and some infrastructure is duplicated. I am on the latest version of Terraform (1.0.3).
Same problem with Terraform 1.0.5 and vSphere.
Hello all,
Overall this does sound like an issue being triggered by some unexpected provider behavior, but without a way to reproduce it it's going to prove very difficult to track down. If anyone can supply the information requested in the issue template it would help greatly.
Thanks!
Hello all,
Overall this does sound like an issue being triggered by some unexpected provider behavior, but without a way to reproduce it it's going to prove very difficult to track down. If anyone can supply the information requested in the issue template it would help greatly.
Thanks! @jbardin
So I think the issue really stems from Terraform just not being able to properly handle resources it did not itself create, and also specifically requiring an unaltered statefile from the workspace that created those resources.
I think this might be related to https://github.com/hashicorp/terraform/issues/28939#issuecomment-863611466
I'm hitting the same in Terraform Cloud. Workspace is using Terraform 1.2.9

Hi guys.
Any new information regarding this issue? I'm facing the same problem and I'm using Terraform v1.3.0 on windows_386
- provider registry.terraform.io/hashicorp/archive v2.2.0
- provider registry.terraform.io/hashicorp/aws v4.29.0
- provider registry.terraform.io/hashicorp/random v3.4.3
Thanks
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.