import * as pulumi from "@pulumi/pulumi"; /** * Manages an Alias for a Subscription - which adds an Alias to an existing Subscription, allowing it to be managed in the provider - or create a new Subscription with a new Alias. * * > **NOTE:** Destroying a Subscription controlled by this resource will place the Subscription into a cancelled state. It is possible to re-activate a subscription within 90-days of cancellation, after which time the Subscription is irrevocably deleted, and the Subscription ID cannot be re-used. For further information see [here](https://docs.microsoft.com/azure/cost-management-billing/manage/cancel-azure-subscription#what-happens-after-subscription-cancellation). Users can optionally delete a Subscription once 72 hours have passed, however, this functionality is not suitable for this provider. A `Deleted` subscription cannot be reactivated. * * > **NOTE:** It is not possible to destroy (cancel) a subscription if it contains resources. If resources are present that are not managed by the provider then these will need to be removed before the Subscription can be destroyed. * * > **Note:** This resource will automatically attempt to cancel a subscription when it is deleted. This behavior can be disabled in the provider `features` block by setting the `preventCancellationOnDestroy` field to `true` within the `subscription` block. * * > **NOTE:** Azure supports Multiple Aliases per Subscription, however, to reliably manage this resource in Terraform only a single Alias is supported. * * > **NOTE:** Subscription Aliases have their own RBAC scope, separate from the underlying Subscription. If an Alias already exists and the Service Principal lacks read/write permissions on that Alias, you may encounter a `401 Unauthorized` error. To resolve this, the Alias creator or a Global Administrator must assign the `Owner` role on the Alias scope to the Service Principal. Global Administrators may need to [elevate access](https://learn.microsoft.com/en-us/azure/role-based-access-control/elevate-access-global-admin) to gain visibility over all subscriptions before performing the role assignment. * * > **NOTE:** When using this resource across tenants the `clientId` and `tenantId` of the `provider` config block should be for the home tenant details for the SPN / User or a permissions error will likely be encountered. See [the official documentation](https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/programmatically-create-subscription) for more details. * * ## Example Usage * * ### Creating A New Alias And Subscription For An Enrollment Account * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = azure.billing.getEnrollmentAccountScope({ * billingAccountName: "1234567890", * enrollmentAccountName: "0123456", * }); * const exampleSubscription = new azure.core.Subscription("example", { * subscriptionName: "My Example EA Subscription", * billingScopeId: example.then(example => example.id), * }); * ``` * * ### Creating A New Alias And Subscription For A Microsoft Customer Account * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = azure.billing.getMcaAccountScope({ * billingAccountName: "e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31", * billingProfileName: "PE2Q-NOIT-BG7-TGB", * invoiceSectionName: "MTT4-OBS7-PJA-TGB", * }); * const exampleSubscription = new azure.core.Subscription("example", { * subscriptionName: "My Example MCA Subscription", * billingScopeId: example.then(example => example.id), * }); * ``` * * ### Creating A New Alias And Subscription For A Microsoft Partner Account * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = azure.billing.getMpaAccountScope({ * billingAccountName: "e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31", * customerName: "2281f543-7321-4cf9-1e23-edb4Oc31a31c", * }); * const exampleSubscription = new azure.core.Subscription("example", { * subscriptionName: "My Example MPA Subscription", * billingScopeId: example.then(example => example.id), * }); * ``` * * ### Adding An Alias To An Existing Subscription * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = new azure.core.Subscription("example", { * alias: "examplesub", * subscriptionName: "My Example Subscription", * subscriptionId: "12345678-12234-5678-9012-123456789012", * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Resources` - 2023-07-01 * * ## Import * * Subscriptions can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:core/subscription:Subscription example "/providers/Microsoft.Subscription/aliases/subscription1" * ``` * * !> **Note:** When importing a Subscription that was not created programmatically, either via this resource or using the Alias API, it will have no Alias ID to import via `pulumi import`. In this scenario, the `subscriptionId` property can be completed and the resource will assume control of the existing subscription by creating an Alias. See the `adding an Alias to an existing Subscription` above. An alias is required to correctly manage Subscription resources due to Azure Subscription API design. */ export declare class Subscription extends pulumi.CustomResource { /** * Get an existing Subscription resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: SubscriptionState, opts?: pulumi.CustomResourceOptions): Subscription; /** * Returns true if the given object is an instance of Subscription. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Subscription; /** * The Alias name for the subscription. This provider will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created. */ readonly alias: pulumi.Output; /** * 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. */ readonly billingScopeId: pulumi.Output; /** * The ID of the Subscription. Changing this forces a new Subscription to be created. * * > **NOTE:** This value can be specified only for adopting control of an existing Subscription, it cannot be used to provide a custom Subscription ID. * * > **NOTE:** Either `billingScopeId` or `subscriptionId` has to be specified. */ readonly subscriptionId: pulumi.Output; /** * The Name of the Subscription. This is the Display Name in the portal. */ readonly subscriptionName: pulumi.Output; /** * A mapping of tags to assign to the Subscription. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The ID of the Tenant to which the subscription belongs. */ readonly tenantId: pulumi.Output; /** * The workload type of the Subscription. Possible values are `Production` (default) and `DevTest`. Changing this forces a new Subscription to be created. */ readonly workload: pulumi.Output; /** * Create a Subscription resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: SubscriptionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Subscription resources. */ export interface SubscriptionState { /** * The Alias name for the subscription. This provider will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created. */ alias?: pulumi.Input; /** * 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. */ billingScopeId?: pulumi.Input; /** * The ID of the Subscription. Changing this forces a new Subscription to be created. * * > **NOTE:** This value can be specified only for adopting control of an existing Subscription, it cannot be used to provide a custom Subscription ID. * * > **NOTE:** Either `billingScopeId` or `subscriptionId` has to be specified. */ subscriptionId?: pulumi.Input; /** * The Name of the Subscription. This is the Display Name in the portal. */ subscriptionName?: pulumi.Input; /** * A mapping of tags to assign to the Subscription. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The ID of the Tenant to which the subscription belongs. */ tenantId?: pulumi.Input; /** * The workload type of the Subscription. Possible values are `Production` (default) and `DevTest`. Changing this forces a new Subscription to be created. */ workload?: pulumi.Input; } /** * The set of arguments for constructing a Subscription resource. */ export interface SubscriptionArgs { /** * The Alias name for the subscription. This provider will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created. */ alias?: pulumi.Input; /** * 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. */ billingScopeId?: pulumi.Input; /** * The ID of the Subscription. Changing this forces a new Subscription to be created. * * > **NOTE:** This value can be specified only for adopting control of an existing Subscription, it cannot be used to provide a custom Subscription ID. * * > **NOTE:** Either `billingScopeId` or `subscriptionId` has to be specified. */ subscriptionId?: pulumi.Input; /** * The Name of the Subscription. This is the Display Name in the portal. */ subscriptionName: pulumi.Input; /** * A mapping of tags to assign to the Subscription. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The workload type of the Subscription. Possible values are `Production` (default) and `DevTest`. Changing this forces a new Subscription to be created. */ workload?: pulumi.Input; }