2

I use the following (standard)-Pulumi - Code to create a simple resource:

  public MyStack()
    {

        var current = Output.Create(GetSubscription.InvokeAsync());
        this.CurrentSubscriptionDisplayName = current.Apply(current => current.DisplayName);


        // Create an Azure Resource Group
        var resourceGroup = new ResourceGroup("dingdongdiehexisttot");  // TODO: Conf


        // Create an Azure Storage Account
        var storageAccount = new Account("storage", new AccountArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AccountReplicationType = "LRS",
            AccountTier = "Standard"
        });

        // Export the connection string for the storage account
        this.ConnectionString = storageAccount.PrimaryConnectionString;
    }

this fails with a 403 because it is created in a subscription where I am not allowed to create resources into. I have multiple subscriptions and want to define WHICH subscription to be used. I can retrieve the current using "GetSubscription" but did not find any method to actually SET which subscription to use.

How can I define the subscription to be used

(I successfully logged in using az login before runnung pulumi up)

1 Answer 1

6

Several options here:

  1. Select your target subscription with the Azure CLI: az account set --subscription SUBSCRIPTION

  2. Use pulumi config set azure:subscriptionId SUBSCRIPTION.

  3. Set the environment variable ARM_SUBSCRIPTION_ID.

  4. Use Explicit Providers and configure it in the provider's properties.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.