azurerm_subscription

Manages an Alias for a Subscription - which adds an Alias to an existing Subscription, allowing it to be managed in Terraform - or create a new Subscription with a new Alias.

Example Usage - creating a new Alias and Subscription for an Enrollment Account

data "azurerm_billing_enrollment_account_scope" "example" {
  billing_account_name    = "1234567890"
  enrollment_account_name = "0123456"
}

resource "azurerm_subscription" "example" {
  subscription_name = "My Example EA Subscription"
  billing_scope_id  = data.azurerm_billing_enrollment_account_scope.example.id
}

Example Usage - creating a new Alias and Subscription for a Microsoft Customer Account

data "azurerm_billing_mca_account_scope" "example" {
  billing_account_name = "e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31"
  billing_profile_name = "PE2Q-NOIT-BG7-TGB"
  invoice_section_name = "MTT4-OBS7-PJA-TGB"
}

resource "azurerm_subscription" "example" {
  subscription_name = "My Example MCA Subscription"
  billing_scope_id  = data.azurerm_billing_mca_account_scope.example.id
}

Example Usage - creating a new Alias and Subscription for a Microsoft Partner Account

data "azurerm_billing_mpa_account_scope" "example" {
  billing_account_name = "e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31"
  customer_name        = "2281f543-7321-4cf9-1e23-edb4Oc31a31c"
}

resource "azurerm_subscription" "example" {
  subscription_name = "My Example MPA Subscription"
  billing_scope_id  = data.azurerm_billing_mpa_account_scope.example.id
}

Example Usage - adding an Alias to an existing Subscription

resource "azurerm_subscription" "example" {
  alias             = "examplesub"
  subscription_name = "My Example Subscription"
  subscription_id   = "12345678-12234-5678-9012-123456789012"
}

Arguments Reference

The following arguments are supported:


Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Subscriptions can be imported using the resource id, e.g.

terraform import azurerm_subscription.example "/providers/Microsoft.Subscription/aliases/subscription1"