Azure rm subnet delegation to sql managed instance

Hi All,

Wondering if someone could help with this azurerm subnet delegation.

One my requirements is to delegate an existing subnet to sql managed instance.

The subnet is provisioned as service for us so I don’t have access to terraform state file to refer in below code block.

Is there anyway I could overcome this issue, Have tried options such as data source and variables etc…but haven’t had much luck.

resource "azurerm_subnet" "example" {
  name                 = "subnet-mi"
  resource_group_name  =
  virtual_network_name =
  address_prefix       = ""

  delegation {
    name = "managedinstancedelegation"

    service_delegation {
      name    = "Microsoft.Sql/managedInstances"
      actions = ["Microsoft.Network/virtualNetworks/subnets/join/action", "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action", "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"]

Any pointers is greatly appreciated

Kind Regards