lgallard / terraform-aws-route53-resolver-rules

Terraform module to create AWS Route53 Resolver Rules.
Apache License 2.0
9 stars 12 forks source link

Issue: "Call to function "index" failed: item not found." #10

Open olhrabar opened 3 years ago

olhrabar commented 3 years ago

I am trying to use this module but faced with a problem:

Code

AWS Route 53 Resolver rules
module "r53-resolver-rules" {
  source               = "git::https://github.com/lgallard/terraform-aws-route53-resolver-rules.git"
  resolver_endpoint_id = module.r53-outboud.endpoint_ids

  rules = [
    { rule_name   = "r53r-rule-1"
      domain_name = "bar.foo."
      ram_name    = "ram-r53r-1"
      vpc_ids     = ["vpc-0fffff0123456789"]
      ips         = ["192.168.10.10", "192.168.10.11:54"]
      principals  = ["123456789101", "101987654321"]
    },

Error: Error in function call

  on main.tf line 25, in resource "aws_route53_resolver_rule_association" "ra":
  25:   resolver_rule_id = element(aws_route53_resolver_rule.r.*.id, index(aws_route53_resolver_rule.r.*.domain_name, lookup(element(local.vpcs_associations, count.index), "domain_name")))
    |----------------
    | aws_route53_resolver_rule.r is tuple with 1 element
    | count.index is 0
    | local.vpcs_associations is tuple with 1 element

Call to function "index" failed: item not found.

Terraform version: 0.13.5

astephanh commented 3 years ago

Hello,

i've run into the same problem. Loose the dot at the end of the domain_name definition.

Regards

lgallard commented 3 years ago

@astephanh @olhrabar First off, sorry about the delay. I hadn't seen this issue before.

Are you still facing the issue?

jmartinttgt commented 7 months ago

Hi, I'm seeing this issue using Terraform 1.7 and module version 0.1.5:

│ Error: Error in function call
│ 
│   on .terraform/modules/upstream_dns_rules/main.tf line 26, in resource "aws_route53_resolver_rule_association" "ra":
│   26:     index(aws_route53_resolver_rule.r.*.domain_name, lookup(element(local.vpcs_associations, count.index), "domain_name")
│   27:   ))
│     ├────────────────
│     │ while calling index(list, value)
│     │ aws_route53_resolver_rule.r is tuple with 1 element
│     │ count.index is 0
│     │ local.vpcs_associations is tuple with 1 element
│ 
│ Call to function "index" failed: item not found.

Code snippet:

module "upstream_dns_rules" {
  source               = "lgallard/route53-resolver-rules/aws"
  version              = "0.1.5"

  resolver_endpoint_id = module.upstream_dns.endpoint_id

  rules = [
    {
      rule_name        = "upstream_forwarder"
      domain_name      = "REDACTED.com."
      vpc_ids          = [module.vpc.vpc_id]
      ips              = local.upstream_dns
    }
  ]
}