Subscription has a policy that subnet should be associated with NSG during creation
Below code we have created but no working for us -
resource “azurerm_subnet” “my_subnet” {
name = “test_subnet”
resource_group_name = “terraformtestrg”
virtual_network_name = “TestVnet”
address_prefixes = [“10.93.234.240/28”]
depends_on = [ azurerm_subnet_network_security_group_association.subnet_association ]
}
resource “azurerm_subnet_network_security_group_association” “subnet_association” {
network_security_group_id = var.nsg_id
subnet_id = azurerm_subnet.my_subnet.id
}