# Subscription has a policy that subnet should be associated with NSG during creation

**URL:** <https://discuss.hashicorp.com/t/subscription-has-a-policy-that-subnet-should-be-associated-with-nsg-during-creation/73173>\
**Category:** Terraform\
**Created:** [February 12, 2025, 11:40am UTC](https://discuss.hashicorp.com/t/subscription-has-a-policy-that-subnet-should-be-associated-with-nsg-during-creation/73173 "2025-02-12T11:40:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saikat.das](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/saikat.das/32/44161_2.png) [@saikat.das](https://discuss.hashicorp.com/u/saikat.das)\
**Post date:** [February 12, 2025, 11:40am UTC](https://discuss.hashicorp.com/t/subscription-has-a-policy-that-subnet-should-be-associated-with-nsg-during-creation/73173/1 "2025-02-12T11:40:15Z")

</div>

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  
}

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/4/0/401e47187ae5c7c71e0aa39977f318c0c4bfc8e4.png)

---

<div class="post-metadata">

**Author:** ![brucelok](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/brucelok/32/40570_2.png) [@brucelok](https://discuss.hashicorp.com/u/brucelok)\
**Post date:** [February 14, 2025, 3:10am UTC](https://discuss.hashicorp.com/t/subscription-has-a-policy-that-subnet-should-be-associated-with-nsg-during-creation/73173/2 "2025-02-14T03:10:31Z")

</div>

it looks like you’ve missed a NSG. Try to specify the `network_security_group_id` argument directly in the `azurerm_subnet` resource.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [August 13, 2025, 3:10am UTC](https://discuss.hashicorp.com/t/subscription-has-a-policy-that-subnet-should-be-associated-with-nsg-during-creation/73173/3 "2025-08-13T03:10:48Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
