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

Issue: "Cannot use a null value in for_each" when not specifying "ips" #11

Open
nnt opened this issue Nov 26, 2020 · 1 comment
Open

Comments

@nnt
Copy link

nnt commented Nov 26, 2020

Source code

module "resolver_rule_name" {
  source               = "git::https://github.com/lgallard/terraform-aws-route53-resolver-rules.git"
  resolver_endpoint_id = aws_route53_resolver_endpoint.inbound_endpoint_name.id

  rules = [
    {
      domain_name = "example.com"
      vpc_ids     = [ids-go-here]
      principals  = [account-ids-go-here]
    }
  ]
}

Error

Error: Invalid dynamic for_each value

  on .terraform/modules/resolver_rule_name/main.tf line 12, in resource "aws_route53_resolver_rule" "r":
  12:     for_each = lookup(element(local.rules, count.index), "ips", [])
    |----------------
    | count.index is 1
    | local.rules is tuple with 2 elements

Cannot use a null value in for_each.

More information

My guess is that the error is caused by the lack of ips in each rule, which I am not sure why is required in this module (the resource route53_resolver_rule makes this optional). Maybe the author wrote this module with external/on-prem DNS in mind?

@lgallard
Copy link
Owner

lgallard commented Jul 1, 2021

@nnt first off, sorry about the delay. I hadn't' seen this issue before.

Nw regarding the issue, you could seth ips has empty list and it should work:

module "resolver_rule_name" {
  source               = "git::https://github.com/lgallard/terraform-aws-route53-resolver-rules.git"
  resolver_endpoint_id = aws_route53_resolver_endpoint.inbound_endpoint_name.id

  rules = [
    {
      domain_name = "example.com"
      vpc_ids     = [ids-go-here]
      principals  = [account-ids-go-here]
      ips         = []
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants