hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Bug]: aws_ebs_volume tags attribute is empty map of strings #37736

Closed antm-pp closed 2 months ago

antm-pp commented 4 months ago

Terraform Core Version

1.8.4

AWS Provider Version

5.49.0, 5.50.0, 5.51.0, 5.51.1

Affected Resource(s)

Expected Behavior

In 5.48 our existing config works fine.

data.aws_ebs_volume.asm[""] is used in a for loop to create a local variable that contains the contents of a particular tag:

asm_data_devices = [for v in data.aws_ebs_volume.asm : v.tags["Device"] if v.tags["Function"] == "ASM:DATA"]

This should create a list of device ids.

Actual Behavior

For each iteration of the for loop:

Error: Invalid index, v.tags is empty map of string. So somehow the for loop can't read the tags attribute of the data source.

Relevant Error/Panic Output Snippet

Error: Invalid index
│ 
│   on storage.tf line 65, in locals:
│   65:   asm_data_devices = [for v in data.aws_ebs_volume.asm : v.tags["Device"] if v.tags["Function"] == "ASM:DATA"]
│     ├────────────────
│     │ v.tags is empty map of string
│ 
│ The given key does not identify an element in this collection value.

Terraform Configuration Files

Working constraints prevent further sharing of data

Steps to Reproduce

Working constraints prevent further sharing of data

Debug Output

Working constraints prevent further sharing of data

Panic Output

No response

Important Factoids

Appreciate I haven't provided much context for the error, but it seems quite specific to a resource that should be producing an output and isn't. The physical AWS resources are constant ie have tags.

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 4 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 4 months ago

Hey @antm-pp 👋 Thank you for taking the time to raise this! Can you inspect what data.aws_ebs_volume.asm.tags looks like during the plan? Does that change when reverting to version 5.48?

If you're able to supply debug logging, that may also be extra helpful to whoever picks this up, since this is likely very resource-specific.

justinretzolk commented 2 months ago

Since we haven't heard back, I'm going to close this issue. If you're still having trouble, please feel free to open a new issue, referencing this one for context as needed.

For what it's worth, it looks like this may have been fixed in #37966, which was included in 5.54.0.

github-actions[bot] commented 2 months ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 1 month ago

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.