Create New Subscription and add the subscription in management group and add RBAC

After Subscription creation , Add management group is not working as its not getting correct Subscription ID from reference.

parsing “/providers/Microsoft.Subscription/aliases/######################”: parsing segment “subscriptions”: expected the segment “providers” to be “subscriptions”

I just ran into this. For some reason the resource of azure_rmsubscription doesn’t export all needed items. To create the management group association you will have to pre-pend the subscription id with /subscriptions/ as so below

resource "azurerm_management_group_subscription_association" "example" {
  management_group_id = resource.azurerm_management_group.mg_group.id
  subscription_id = "/subscriptions/${resource.azurerm_subscription.example.subscription_id}"
}
2 Likes