0

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;
JuChom
  • 5,717
  • 5
  • 45
  • 78
  • not sure where you want to retrieve the value from, pulumi config value or ??? – 4c74356b41 Feb 21 '19 at 15:59
  • Actually Pulumi detects if the value has changed if I don't set it which is fine. The current value is stored in the stack. Is the a way to retrieve it? – JuChom Feb 21 '19 at 16:04

1 Answers1

1

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

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thanks, I'm almost done, I'm missing the the last step after using getOuput. I exported the blob resource, and getOutput gives it back but I still can't tell Pulumi to not delete the resource. – JuChom Feb 22 '19 at 19:25
  • i'm sure what you mean exactly, perhaps you should start a new question ;) – 4c74356b41 Feb 22 '19 at 19:32