You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The outputs of the resource should still be available, i.e. the state of the resource should be correct.
Actual Behavior
The state of the resource seems incorrect and the only way forward is to manually edit the state file or move the resource back to its original place.
Steps to Reproduce
Made a bucket
Changed the s3_bucket module's aws_s3_bucket to no longer be counted. did a terraform state mv 'module.bucket.aws_s3_bucket.b[0]' module.bucket.aws_s3_bucket.b
a subsequent apply or plan will show:
Error: Unsupported attribute
on s3_bucket/main.tf line 15, in output "id":
15: value = aws_s3_bucket.b.id
|----------------
| aws_s3_bucket.b is empty tuple
This value does not have any attributes.
In the second state file after I changed the module and moved the aws_S3_bucket resource, I think the problem is that even though I removed the count and it removed the "index_key": 0, entry from resources[0]{"instances"}[0]{"attributes"} it did not remove "each": "list" from resources[0]
I hit this problem via a similar mechanism. Given a list of resources created via count, when I terraform state mv them to use for_each, the "each":"list" field does not change to "each":"map". I manually edited my state file and this seemed to work, although I don't have a deep enough understanding of why.
Steps to reproduce:
Given a collection of elements created with count and a valid state file derived from that, change the source code to use for_each instead, using a map as a the for_each variable.
Run terraform state mv path.to.collection[0] path.to.collection["first"] terraform state mv path.to.collection[1] path.to.collection["second"]
Observe that "each":"list" is still in the state file.
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.
ghost
locked and limited conversation to collaborators
Apr 4, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Terraform Version
Terraform Configuration Files
https://gist.github.com/grimm26/e973a686526f9d054224d251b713aae6
Expected Behavior
The outputs of the resource should still be available, i.e. the state of the resource should be correct.
Actual Behavior
The state of the resource seems incorrect and the only way forward is to manually edit the state file or move the resource back to its original place.
Steps to Reproduce
In the second state file after I changed the module and moved the aws_S3_bucket resource, I think the problem is that even though I removed the count and it removed the
"index_key": 0,
entry fromresources[0]{"instances"}[0]{"attributes"}
it did not remove"each": "list"
fromresources[0]
Additional Context
References
#23582 seems to have introduced this.
The text was updated successfully, but these errors were encountered: