Loading...
Loading...
### Terraform Version ```shell Terraform v1.6.3 ``` ### Terraform Configuration Files ``` resource "digitalocean_firewall" "challenge_firewall" { name = "${var.challenge_name}-firewall" droplet_ids = [digitalocean_droplet.challenge_droplet.id] dynamic "inbound_rule" { for_each = var.ingress_rules iterator = "rules" content { protocol = rules.value["protocol"] port_range = rules.value["port_range"] source_addresses = rules.value["source_addresses"] } } } ``` The variable ingress_rules looks like this ``` variable "ingress_rules" { description = "The ingress rule for the challenges" type = map(object({ protocol = string port_range = string source_addresses = list(string) })) default = { "HTTP" = { protocol = "tcp", port_range = "80", source_addresses = ["0.0.0.0/0", "::/0"] }, "SSH" = { protocol = "tcp", port_range = "22", source_addresses = ["0.0.0.0/0", "::/0"] }, "ICMP" = { protocol = "icmp", port_range = "1-65535", source_addresses = ["0.0.0.0/0", "::/0"] } } } ``` ### Debug Output Terraform v1.6.3 on linux_amd64 Initializing plugins and modules... ╷ │ Error: Unknown variable │ │ on resources.tf line 37, in resource "digitalocean_firewall" "challenge_firewall": │ 37: for_each = var.ingress_rules ? [1] : [] │ │ There is no variable named "var". ╵ Operation failed: failed running terraform plan (exit 1) ### Expected Behavior The dynamic block should be able to run smoothly without any problems ### Actual Behavior The terraform crashed giving the above error which is really ambigous ### Steps to Reproduce 1. `terraform init` 2. `terraform plan` ### Additional Context So I am trying to create multiple firewall rules for a machine, and to do that I am using a dynamic block so that the rules are easily customizable and not fixed. However, when I run the snippet, I get the error `There is no variable named "var".`. Obviously, I have searched for any clues to solve the error, but nothing I tried worked so far. The error is really ambigous and not helpful. Please help ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.