英文:
Way in Pulumi to run a function only when pulumi up deploys resources and not during a preview?
问题
在Pulumi项目中,是否有一种方法可以在用户接受部署后,仅在pulumi up
实际部署资源到云上时运行函数?
我有一个场景,我需要像这样为AWS运行自定义代码:
myAwsModule.putResourcePolicy({policyName: "AWSLogDeliveryWrite20150319",/*...*/});
我认为我不能使用@pulumi/aws
来进行此更改,因为它是AWS有时会自动生成但有时可能尚不存在的特殊ResourcePolicy,并且Pulumi似乎要求对资源的存在或不存在具有确定性知识。
我希望避免在pulumi preview
期间或在用户不接受实际运行它的情况下,在pulumi up
期间运行上述示例中的代码,所以我希望有类似这样的东西:
if (!pulumi.isPreview) {
myAwsModule.putResourcePolicy({policyName: "AWSLogDeliveryWrite20150319",/*...*/});
}
是否有类似的东西或实现相同结果的其他方法?
英文:
Is there any way in a Pulumi project to run a function only when pulumi is actually deploying the resources to the cloud during the pulumi up
after the user accepts to deploy?
I have an scenario were I need to run a custom code for aws like this:
myAwsModule.putResourcePolicy({policyName: "AWSLogDeliveryWrite20150319",/*...*/});
I don't think I can make this change using @pulumi/aws
because it is a special ResourcePolicy that aws sometimes automatically generates but sometimes it could not exist yet, and pulumi seems to require to have a deterministic knowledge of the resource existing or not.
I want to avoid the code from above example to run during a pulumi preview
or during a pulumi up
if the user doesn't accept to actually run it, so I was hoping there would be something like this:
if (!pulumi.isPreview) {
myAwsModule.putResourcePolicy({policyName: "AWSLogDeliveryWrite20150319",/*...*/});
}
Is there something like that or any other way to achieve the same result?
答案1
得分: 1
pulumi.runtime.isDryRun
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun
Different casing for all SDKs, but it's available across all
英文:
pulumi.runtime.isDryRun
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun
Different casing for all SDKs, but it's available across all
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论