Search code examples
azure-devopsazure-pipelinespulumi

Pulumi Azure Pipeline task


I'm new to Pulumi so I'm struggling at the moment trying to run it in my Azure release pipeline in order to create my infrastructure. During development I've used the local storage to store my pulumi state (pulumi login --local), I've created my stacks (dev being one of them) and I was able to easily test my deployment script against my azure subscription. Now I've pushed my code to source control, created by build pipeline (which works) and I'm trying to create my infrastructure from the release pipeline by using the Pulumi Azure Pipelines Task. I've managed to configure it to use the blob storage for the state file, but when running pulumi up --yes --skip-preview for the dev stack I get an error that the dev stack does not exist.

Do I need to do a pulumi stack init dev on every "store" that I use? Aren't the Pulumi.stack_name.yaml files enough?

Any advice on how to proceed is welcomed as the documentation on this is non existent or not clear.

Thank you!


Solution

  • The error is probably caused by the stack not existing in your blob storage.

    If you use pulumi login --local. The stack will be managed in your local machine and is not synced to azure blob storage. Check here for more login options.

    In my test pipeline. I got error: no stack named 'dev' found. If dev does not exist on app.pulumi.com. If i created the dev on app.pulumi.com(i use pulumi.com for storage), it worked as expected.

    So please go to azure blob to check if the dev stack exists. You need to create one on azure blob for your account if not exist.

    If you want to migrate you local endpoints to azure blob. Please check the steps here.

    Once the stack exists in your azure blob. You can run pulumi up --yes --skip-preview directly in pulumi task of azure devopline. No need to run pulumi stack init dev Please make sure the login args is empty to use the online stack. If you specify --local, you will get the error too, for the stack does not exist in agent machine.

    enter image description here

    You can also enable the option Create the stack if it does not exist to let the pulumi task create the stack if it is not found on your azure blob.

    enter image description here

    Here is the an example from Pulumi official documents to integrate with azure devops. Hope it helps!