JuChom
JuChom

Reputation: 5999

Pulumi: query pulumi stack value if not given

Here is my use case:

I have a blob resource that is created only if a file (artifcat from my CI server) is present on my build machine.

Now, I may have to run pulumi on my local machine where the file does not exist. But I don't want to delete the blob resource. The blob is still present on Azure.

if (fs.existsSync(fullFileName)) {
    // On the build server, I update the blob with the new artifact
    const blob = new azure.storage.Blob("myblob-b", {
                    name: fileName,
                    source: fullFileName,
                    resourceGroupName: resourceGroup.name,
                    storageAccountName: storageAccount.name,
                    storageContainerName: zipDeployContainer.name,
                    type: "block"
                })
} else {
    // On my local machine, the artifact does not exists but I want to keep it
    const stackRef = new pulumi.StackReference(`${organization}/${projectName}/${stackName}`);
    const srblob = stackRef.getOutput("zipblob");
    // How do I tell pulumi keep the resource from the stack reference
}

export const zipblob = blob;

Upvotes: 0

Views: 800

Answers (1)

4c74356b41
4c74356b41

Reputation: 72191

Ok, i'm not smart enough for this, people on pulumi slack helped me out. Basically you can use StackReference. Specifically the getOutput method.

Upvotes: 1

Related Questions