I have a resource on my stack that can be created ...
# general
I have a resource on my stack that can be created only on my build server (a blob). On my desktop, the file does not exists and Pulumi wants to delete this resource. What I want on my build machine, is to query the StackReference and see if the resource is present. If yes then I want to keep it.
Copy code
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}`);
    // How do I tell pulumi keep the resource from the stack reference
    const srblob = stackRef.getOutput("zipblob");

export const zipblob = blob;
@microscopic-florist-22719 is the right person to help you here. Let me give it a shot, however. I think you can use
and that, by doing so, it will read the resource from the existing state and leave it be.
Copy code
} else {
    const stackRef = new pulumi.StackReference(...)
    const blob = azure.storage.Blob.get(
That said, I had never considered using
to reference the current stack being deployed, and I don't know if the read will prevent the delete, so @microscopic-florist-22719 should definitely weigh in before I lead you down the wrong path 🙂