【问题标题】:Pulumi: query pulumi stack value if not givenpulumi:如果没有给出,查询pulumi堆栈值
【发布时间】:2019-07-15 14:26:28
【问题描述】:

这是我的用例:

我有一个仅当我的构建机器上存在文件(来自我的 CI 服务器的工件)时才创建的 blob 资源。

现在,我可能必须在文件不存在的本地机器上运行 pulumi。但我不想删除 blob 资源。该 blob 仍然存在于 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;

【问题讨论】:

  • 不确定你想从哪里获取值,pulumi 配置值还是???
  • 其实Pulumi会检测到如果我没有设置它的值是否发生了变化,这很好。当前值存储在堆栈中。有办法找回吗?

标签: azure pulumi


【解决方案1】:

好吧,我对此不够聪明,pulumi slack 上的人帮助了我。基本上你可以使用StackReference。特别是getOutput 方法。

【讨论】:

  • 谢谢,我快完成了,我错过了使用 getOuput 后​​的最后一步。我导出了 blob 资源,getOutput 将其返回,但我仍然无法告诉 Pulumi 不要删除该资源。
  • 我确定你的意思是什么,也许你应该开始一个新问题;)
猜你喜欢
  • 2020-09-09
  • 2022-11-11
  • 2020-06-29
  • 2020-10-19
  • 2021-11-14
  • 1970-01-01
  • 2021-06-08
  • 2022-11-21
  • 2022-07-08
相关资源
最近更新 更多