unable to attach service_endpoint_policy_ids to the subnet
service_endpoints created successfully but storage policy unable to attach to subnet
Ended up with below error
Error: Cycle: azurerm_subnet_service_endpoint_storage_policy.stg, azurerm_subnet.backend, module.storage_bsai.var.vnet_subnet_id (expand), module.storage_bsai.azurerm_storage_account.storageaccount_name, module.storage_bsai.output.id (expand)
provider azurerm version = "2.65.0"
Terraform resource for storage policy and subnet
resource "azurerm_subnet_service_endpoint_storage_policy" "stg" {
name = "storage-policy-bsai"
resource_group_name = "${var.env}-bsai"
location = var.region
definition {
name = "storage"
#description = "definition1"
service_resources = [
module.resource_group.id,
module.storage_bsai.id
]
}
}
resource "azurerm_subnet" "backend" {
depends_on = [module.vnet]
name = "backend"
virtual_network_name = "${var.env}-${var.region}-bsai"
resource_group_name = "${var.env}-bsai"
address_prefixes = ["10.0.0.0/24"]
service_endpoints = ["Microsoft.Storage", "Microsoft.AzureCosmosDB", "Microsoft.ServiceBus", "Microsoft.Web", "Microsoft.ContainerRegistry"]
service_endpoint_policy_ids = [azurerm_subnet_service_endpoint_storage_policy.stg.id]
delegation {
name = "delegation"
service_delegation {
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}