-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Closed
Labels
Description
Current Terraform Version
Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
Proposal
I like the object
variable type and it would be nice to be able to define optional arguments which can carry null
value too, to use:
variable "network_rules" {
default = null
type = object({
bypass = optional(list(string))
ip_rules = optional(list(string))
virtual_network_subnet_ids = optional(list(string))
})
}
resource "azurerm_storage_account" "sa" {
name = random_string.name.result
location = var.location
resource_group_name = var.resource_group_name
account_replication_type = var.account_replication_type
account_tier = var.account_tier
dynamic "network_rules" {
for_each = var.network_rules == null ? [] : list(var.network_rules)
content {
bypass = network_rules.value.bypass
ip_rules = network_rules.value.ip_rules
virtual_network_subnet_ids = network_rules.value.virtual_network_subnet_ids
}
}
instead of:
variable "network_rules" {
default = null
type = map(string)
}
resource "azurerm_storage_account" "sa" {
name = random_string.name.result
location = var.location
resource_group_name = var.resource_group_name
account_replication_type = var.account_replication_type
account_tier = var.account_tier
dynamic "network_rules" {
for_each = var.network_rules == null ? [] : list(var.network_rules)
content {
bypass = lookup(network_rules, "bypass", null) == null ? null : split(",", lookup(network_rules, "bypass"))
ip_rules = lookup(network_rules, "ip_rules", null) == null ? null : split(",", lookup(network_rules, "ip_rules"))
virtual_network_subnet_ids = lookup(network_rules, "virtual_network_subnet_ids", null) == null ? null : split(",", lookup(network_rules, "virtual_network_subnet_ids"))
}
}
}
gordonbondon, mkeeler, LucaFilipozzi, jjaniec, pkrawiec8 and 1753 moreAlejandroSilva, nick4fake, dobber, bravo2zero, jbatchelor13 and 281 moreLukeCarrier, udondan, sandangel, jdj333, jconstance-amplify and 204 morekkishorekr, Djangoum, A30001546, bholzer, madsonic and 133 more