File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ resource "azurerm_subnet" "this" {
21
21
}
22
22
23
23
resource "azurerm_subnet_network_security_group_association" "this" {
24
- for_each = var. nsg_id
24
+ count = var. nsg_association_enabled ? 1 : 0
25
25
26
26
subnet_id = var. export_subnet_id == null ? azurerm_subnet. this [0 ]. id : var. export_subnet_id
27
- network_security_group_id = each . value
27
+ network_security_group_id = var . nsg_id
28
28
}
Original file line number Diff line number Diff line change @@ -44,10 +44,16 @@ variable "delegations" {
44
44
default = []
45
45
}
46
46
47
+ variable "nsg_association_enabled" {
48
+ type = bool
49
+ description = " Boolean flag that determines if NSG association would be created"
50
+ default = false
51
+ }
52
+
47
53
variable "nsg_id" {
48
- type = map ( string )
54
+ type = string
49
55
description = " The ID of the Network Security Group which should be associated with the Subnet"
50
- default = {}
56
+ default = null
51
57
}
52
58
53
59
variable "export_subnet_id" {
You can’t perform that action at this time.
0 commit comments