I am able to create a subscription under our EA enrollment but can’t figure out how to add resources to that subscription once it is created. It seems there is a delay between the subscritpion being created and showing up. So far, I have tried to the following code:
provider "azurerm" {
features {}
alias = "createSub"
}
data "azurerm_billing_enrollment_account_scope" "bill01" {
provider = azurerm.createSub
billing_account_name = "123456"
enrollment_account_name = "654321"
}
resource "azurerm_subscription" "sub01" {
provider = azurerm.createSub
alias = "${var.SubscriptionName}"
subscription_name = "${var.SubscriptionName}"
billing_scope_id = data.azurerm_billing_enrollment_account_scope.bill01.id
tags = local.tags
}
provider "azurerm" {
features {}
subscription_id = azurerm_subscription.sub01.id
}
But I get:
building AzureRM Client: obtain subscription(/providers/Microsoft.Subscription/aliases/*SubscriptionName*) from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Subscription '/providers/Microsoft.Subscription/aliases/*SubscriptioName*' not found. Check the spelling and casing and try again.
Is there a way to create a subscription and then add resources to that subscription in Terraform?