Skip to content

Commit a98e8e4

Browse files
authored
Merge pull request #7 from data-platform-hq/fix_nsg_count
fix: nsg count
2 parents 1eed0cc + 31a028a commit a98e8e4

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ No modules.
3636
| <a name="input_delegations"></a> [delegations](#input\_delegations) | (optional) subnet delegation | <pre>list(object({<br> name = string<br> actions = list(string)<br> }))</pre> | `[]` | no |
3737
| <a name="input_name"></a> [name](#input\_name) | The name of the subnet | `string` | n/a | yes |
3838
| <a name="input_network"></a> [network](#input\_network) | The name of the virtual network in which the subnet is created in | `string` | n/a | yes |
39-
| <a name="input_nsg_id"></a> [nsg\_id](#input\_nsg\_id) | The ID of the Network Security Group which should be associated with the Subnet | `string` | null | no |
39+
| <a name="input_nsg_id"></a> [nsg\_id](#input\_nsg\_id) | The ID of the Network Security Group which should be associated with the Subnet | `map(string)` | {} | no |
4040
| <a name="input_private_endpoint_network_policies_enabled"></a> [private\_endpoint\_network\_policies\_enabled](#input\_private\_endpoint\_network\_policies\_enabled) | Enable or Disable network policies for the private link endpoint on the subnet. Setting this to true will Disable the policy and setting this to false will Enable the policy: [true\|false] | `bool` | `true` | no |
4141
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The name of the resource group in which to create the storage account | `string` | n/a | yes |
4242
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The list of Service endpoints to associate with the subnet: Microsoft.AzureActiveDirectory, Microsoft.AzureCosmosDB, Microsoft.ContainerRegistry, Microsoft.EventHub, Microsoft.KeyVault, Microsoft.ServiceBus, Microsoft.Sql, Microsoft.Storage, Microsoft.Web | `list(string)` | <pre>[<br> "Microsoft.Storage",<br> "Microsoft.KeyVault",<br> "Microsoft.Sql"<br>]</pre> | no |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ resource "azurerm_subnet" "this" {
2121
}
2222

2323
resource "azurerm_subnet_network_security_group_association" "this" {
24-
count = var.nsg_id == null ? 0 : 1
24+
for_each = var.nsg_id
2525

2626
subnet_id = var.export_subnet_id == null ? azurerm_subnet.this[0].id : var.export_subnet_id
27-
network_security_group_id = var.nsg_id
27+
network_security_group_id = each.value
2828
}

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ output "address_prefixes" {
1414
}
1515

1616
output "nsg_association_id" {
17-
value = var.nsg_id == null ? null : azurerm_subnet_network_security_group_association.this[0].id
17+
value = try(azurerm_subnet_network_security_group_association.this[keys(var.nsg_id)[0]].id, null)
1818
description = "The ID of the Network Security Group Association"
1919
}
2020

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ variable "delegations" {
4545
}
4646

4747
variable "nsg_id" {
48-
type = string
48+
type = map(string)
4949
description = "The ID of the Network Security Group which should be associated with the Subnet"
50-
default = null
50+
default = {}
5151
}
5252

5353
variable "export_subnet_id" {

0 commit comments

Comments
 (0)