azure - pulumi:如果没有给出,查询pulumi堆栈值
问题描述
这是我的用例:
我有一个 blob 资源,仅当我的构建机器上存在文件(来自我的 CI 服务器的 artifcat)时才会创建。
现在,我可能必须在文件不存在的本地机器上运行 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 slack 上的人帮助了我。基本上你可以使用StackReference。特别是getOutput方法。
推荐阅读
- scrapy - 为什么启动浏览器无法呈现 youtube 主页?
- python - 如果 DataFrame 中的其他行值相同,如何聚合行值?
- python - 自行更新发布在 github 上的 python 脚本
- python - 对 Pandas DataFrame Describe 输出进行排序(早期解决方案不起作用)
- docker - 如果我需要在 docker 映像中运行 npm install 并希望在 gitlab ci yml 文件中运行脚本。但是,gitlab-ci yml 文件没有找到包
- python - Python 子进程——如何忽略退出代码警告?
- reactjs - 使用 react-18next 翻译反应组件外部的字符串
- python - 使用 Writer.close/save 保存 Excel 的 Python 文件损坏
- python - Python文本文件到xml的转换
- python - pytorch:GRU 无法就地更新 hidden_state