-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
crash when passing invalid value to object attribute with defaults #32752
Comments
Hi @merecogroup, Thanks for filing the issue. The error here seems to be originating when applying the variable defaults. Can you show the variable type definition for the module? Thanks! |
Hi @jbardin, the variable type is:
I tested some further and I only get the crash with terraform version 1.3.9, if I use 1.3.2 I get the validation error:
What is expected behaviour for me. Thank you for your help |
Are you certain the Thanks! |
I'm certain it is The code is: data "azurerm_dns_a_record" "mysql_server_ip" {
name = "some_name"
zone_name = "mysql.database.azure.com"
resource_group_name = azurerm_resource_group.rg.name
}
module "firewall_rule" {
depends_on = [module.firewall]
source = "git::ssh://git-url"
firewall_name = module.firewall.firewall_name
firewall_resource_group_name = azurerm_resource_group.rg.name
nat_rules = {
mysql = {
priority = 1000
rules = {
description = "Port forward"
destination_ports = ["3306"]
destination_addresses = [module.firewall.public_ip]
translated_address = tolist(data.azurerm_dns_a_record.mysql_server_ip.records)[0]
translated_port = "3306"
}
}
}
} And the code from the module is: variable "firewall_resource_group_name" {
type = string
}
variable "firewall_name" {
type = string
}
variable "nat_rules" {
type = map(object({
priority = number
action = optional(string, "Dnat")
rules = map(object({
description = string
protocols = optional(list(string), ["TCP"])
source_addresses = optional(list(string), [])
source_ip_groups = optional(list(string), [])
destination_ports = list(string)
destination_addresses = optional(list(string), [])
translated_address = string
translated_port = string
}))
}))
default = {}
}
resource "azurerm_firewall_nat_rule_collection" "dnat_rules" {
for_each = var.nat_rules
name = each.key
azure_firewall_name = var.firewall_name
resource_group_name = var.firewall_resource_group_name
priority = each.value.priority
action = each.value.action
dynamic "rule" {
for_each = each.value.rules
content {
name = rule.key
description = rule.value.description
protocols = rule.value.protocols
destination_addresses = rule.value.destination_addresses
destination_ports = rule.value.destination_ports
source_addresses = rule.value.source_addresses
source_ip_groups = rule.value.source_ip_groups
translated_address = rule.value.translated_address
translated_port = rule.value.translated_port
}
}
} How can I get the sample data you need? |
Oh, actually piecing these together I can get a reproducible crash now. The problem here is that the type for If you change Thanks! |
The fix for this should be merged in time for the v1.4.1 release. |
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. |
Terraform Version
Terraform Configuration Files
Debug Output
error.log
Expected Behavior
Either passing validate or outputting a validation error
Actual Behavior
Terraform crashes
Steps to Reproduce
terraform init
terraform validate
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: