-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Moving a module with "terraform state mv" loses "data." prefix for aws_caller_identity address #9996
Comments
Hi @nickrw. Thanks for reporting this! The state commands and data source code were being worked on concurrently, so my bet is that this was missed because the extra attribute we added to distinguish data resources from managed resources wasn't around when the In some quick spelunking in the code I wasn't able to track it down exactly, but this problem suggests that somewhere inside the module-moving code we're copying and rewriting |
Aha... I think I found it: terraform/terraform/state_add.go Line 113 in 0e6e206
I don't have a Go compiler handy to test right now but I expect adding an additional line to copy the |
Set proper Mode when moving a data source in state
Hi, I used terraform state mv for all the resources in a module (I renamed the module and didn't want to delete/recreate all the resources in it). When running plan I get
I'm using the new state backend Here is the relevant part of
The data has been dropped from the resource as @nickrw reported Using terraform state show works fine
|
Fixed the issue with
|
Having the exact same problem with aws_availability_zones and did exactly what hamstah did to fix it. |
Same with aws_iam_policy_document |
Happened with every single data source in a + provider.aws v1.10.0``` |
Hi all, Given that Terraform has changed a lot since this issue was opened and addressed, it's likely that new problems have different causes even if the symptoms look similar. For those of you who are seeing what appears to be a regression of this issue, it'd be great if you could open a fresh issue and fill out the requested information in the issue template so we can have the best chance of understanding what's going on. Thanks! |
@apparentlymart new issue: #18978 |
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. |
Terraform Version
Terraform v0.7.9
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
I created a reproduction case with this simple layout
./sourcemod/test.tf
./root.tf
Expected Behavior
With the above module layout, after running
terraform apply
you should be able to rename a module, e.g.Actual Behavior
Subsequent plan/apply operations result in
Examining the diff between the state and the backup file shows that "data." is being dropped from the resource address:
Manually adding the missing "data." back to the address in the state file fixes the issue, and subsequent plan/apply operations succeed.
The text was updated successfully, but these errors were encountered: