Skip to content
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

Output complains about missing attribute when it is shurely present #23245

Closed
yurykar opened this issue Oct 31, 2019 · 2 comments
Closed

Output complains about missing attribute when it is shurely present #23245

yurykar opened this issue Oct 31, 2019 · 2 comments

Comments

@yurykar
Copy link

yurykar commented Oct 31, 2019

After switching to new terraform version 0.12.12 we experince some issues, specifically route53 module output seems to be working with errors, it complains about missing attribute, thought the resource created is obviously has name and fqdn attributes.

Terraform Version

0.12.12

Terraform Configuration Files

output "fqdn" {
  description = "List of created non-alias record FQDNs."
  value       = aws_route53_record.record[*].fqdn
}

Expected Behavior

0.12.9

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

alias_record_fqdn = [
  "app-test4.test.io",
]
record_fqdn = [
  "app1.test.io",
]

Actual Behavior

0.12.12

Error: Unsupported attribute

  on ../../resource_modules/route53_record/outputs.tf line 3, in output "fqdn":
   3:   value       = aws_route53_record.record[*].fqdn

This object does not have an attribute named "fqdn".

Additional Context

when use without .fqdn the output is expected

output "fqdn" {
 description = "List of created non-alias record FQDNs."
 value       = aws_route53_record.record[*]
}
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

alias_record_fqdn = [
  {
    "app-test4.test.io" = {
      "alias" = [
        {
          "evaluate_target_health" = false
          "name" = "xxx"
          "zone_id" = "xxx"
        },
      ]
      "failover_routing_policy" = []
      "fqdn" = "app-test4.test.io"
      "geolocation_routing_policy" = []
      "health_check_id" = ""
      "id" = "xxx"
      "latency_routing_policy" = []
      "name" = "xxx"
      "records" = []
      "set_identifier" = ""
      "ttl" = 0
      "type" = "A"
      "weighted_routing_policy" = []
      "zone_id" = "xxx"
    }
  },
]
record_fqdn = [
  {
    "app1.test.io" = {
      "alias" = []
      "failover_routing_policy" = []
      "fqdn" = "app1.test.io"
      "geolocation_routing_policy" = []
      "health_check_id" = ""
      "id" = "xxx"
      "latency_routing_policy" = []
      "name" = "xxx"
      "records" = [
        "xxx",
      ]
      "set_identifier" = ""
      "ttl" = 3600
      "type" = "CNAME"
      "weighted_routing_policy" = []
      "zone_id" = "xxx"
    }
  },
]

@pselle
Copy link
Contributor

pselle commented Oct 31, 2019

The issue is that you're using a splat operator to refer to try and get something out of a map, but splat has wrapped that map in a list. More details at #22476. The short answer is that if you were to modify your code to values(aws_route53_record.record)[*].fqdn it will work as you're expecting it to.

I suggest reading through the linked issue for more insight as to why this happens, and that the splat operator operates on lists, or it will wrap anything not a list into one, as a matter of convenience.

@pselle pselle closed this as completed Oct 31, 2019
@ghost
Copy link

ghost commented Mar 29, 2020

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 ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants