Loading...
Loading...
<!-- Hi there, Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html. If your issue relates to a specific Terraform provider, please open it in the provider's own repository. The index of providers is at https://github.com/terraform-providers . --> ### Terraform Version <!--- Run `terraform -v` to show the version, and paste the result between the ``` marks below. If you are not running the latest version of Terraform, please try upgrading because your issue may have already been fixed. --> ``` v.0.12.10 ``` ### Terraform Configuration Files <!-- Paste the relevant parts of your Terraform configuration between the ``` marks below. For large Terraform configs, please use a service like Dropbox and share a link to the ZIP file. For security, you can also encrypt the files using our GPG public key. --> main.tf ```hcl resource "azurerm_network_security_rule" "predefined_rules" { count = length(var.predefined_rules) name = lookup(var.predefined_rules[count.index], "name") source_address_prefix = join(",", lookup(var.predefined_rules[count.index], "source_address_prefix", var.source_address_prefix)) destination_address_prefix = join(",", lookup(var.predefined_rules[count.index], "destination_address_prefix", var.destination_address_prefix)) resource_group_name = azurerm_resource_group.nsg.name network_security_group_name = azurerm_network_security_group.nsg.name } ``` variable.tf ``` # Predefined rules variable "predefined_rules" { type = list(any) default = [] } # source address prefix to be applied to all rules variable "source_address_prefix" { type = list(string) default = ["*"] # Example ["10.0.3.0/24"] or ["VirtualNetwork"] } # Destination address prefix to be applied to all rules variable "destination_address_prefix" { type = list(string) default = ["*"] # Example ["10.0.3.0/32","10.0.3.128/32"] or ["VirtualNetwork"] } ``` ### Debug Output <!-- Full debug output can be obtained by running Terraform with the environment variable `TF_LOG=trace`. Please create a GitHub Gist containing the debug output. Please do _not_ paste the debug output in the issue, since debug output is long. Debug output may contain sensitive information. Please review it before posting publicly, and if you are concerned feel free to encrypt the files using the HashiCorp security public key. --> ### Crash Output <!-- If the console output indicates that Terraform crashed, please share a link to a GitHub Gist containing the output of the `crash.log` file. --> ``` Error: Invalid function argument TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: on ../../main.tf line 27, in resource "azurerm_network_security_rule" "predefined_rules": TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: 27: source_address_prefix = join(",", lookup(var.predefined_rules[count.index], "source_address_prefix", var.source_address_prefix)) TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: |---------------- TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: | var.source_address_prefix is list of string with 1 element TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: Invalid value for "default" parameter: the default value must have the same TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: type as the map elements. TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: Error: Invalid function argument TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: on ../../main.tf line 28, in resource "azurerm_network_security_rule" "predefined_rules": TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: 28: destination_address_prefix = join(",", lookup(var.predefined_rules[count.index], "destination_address_prefix", var.destination_address_prefix)) TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: |---------------- TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: | var.destination_address_prefix is list of string with 1 element TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: Invalid value for "default" parameter: the default value must have the same TestTerraformNSG 2019-11-13T06:42:00Z command.go:100: type as the map elements. ``` ### Expected Behavior <!-- --> I want to lookup the key `source_address_prefix` in `predefined_rules[index]` map,it's a list, if the key is not included in the map, I'd like to return a list(string) `var.source_address_prefix`, which isn't supported ### Actual Behavior <!-- --> error raised ### Steps to Reproduce <!-- Please list the full steps required to reproduce the issue, for example: 1. `terraform init` 2. `terraform apply` --> ### Additional Context <!-- Are there anything atypical about your situation that we should know? For example: is Terraform running in a wrapper script or in a CI system? Are you passing any unusual command line options or environment variables to opt-in to non-default behavior? --> ### References <!-- Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example: - #6017 -->
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.