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.
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
}
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
}
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
}
resource "azurerm_subscription" "example" {
alias = "examplesub"
subscription_name = "My Example Subscription"
subscription_id = "12345678-12234-5678-9012-123456789012"
}
The following arguments are supported:
subscription_name
- (Required) The Name of the Subscription. This is the Display Name in the portal.alias
- (Optional) The Alias name for the subscription. Terraform will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created.
billing_scope_id
- (Optional) The Azure Billing Scope ID. Can be a Microsoft Customer Account Billing Scope ID, a Microsoft Partner Account Billing Scope ID or an Enrollment Billing Scope ID.
subscription_id
- (Optional) The ID of the Subscription. Changing this forces a new Subscription to be created.
workload
- (Optional) The workload type of the Subscription. Possible values are Production
(default) and DevTest
. Changing this forces a new Subscription to be created.
tags
- (Optional) A mapping of tags to assign to the Subscription.
In addition to the Arguments listed above - the following Attributes are exported:
id
- The Resource ID of the Alias.
tenant_id
- The ID of the Tenant to which the subscription belongs.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Subscription.read
- (Defaults to 5 minutes) Used when retrieving the Subscription.update
- (Defaults to 30 minutes) Used when updating the Subscription.delete
- (Defaults to 30 minutes) Used when deleting the Subscription.Subscriptions can be imported using the resource id
, e.g.
terraform import azurerm_subscription.example "/providers/Microsoft.Subscription/aliases/subscription1"