[英]Same CloudFormation template to parameterize DeletionPolicy?
As a DevOps guy I wanted to use the same template to provision both Dev and Prod stacks... Where dev stacks should not have any DeletionPolicy
but Prod stacks should utilize a DeletionPolicy
作为一个 DevOps 人员,我想使用相同的模板来配置 Dev 和 Prod 堆栈......其中 dev 堆栈不应该有任何
DeletionPolicy
但 Prod 堆栈应该使用DeletionPolicy
So, at first sight CFT gives an ok tooling for this but.... there is no possibility to parametrize S3 DeletionPolicy
(that I've been able to locate at least)...因此,乍一看,CFT 为此提供了一个不错的工具,但是.... 不可能对 S3
DeletionPolicy
进行参数化(至少我已经能够找到)...
Here's some threads I dug up这是我挖掘的一些线索
The suggested workaround from AWS was to make the whole resource conditional, which leads us duplicating the resource and create a „Deletable
and „Undeletable
versions of it and all the depending resources should handle that condition... AWS建议的解决方法是使整个资源有条件,这导致我们复制资源并创建它的
„Deletable
删除和„Undeletable
版本,所有依赖资源都应处理该条件......
This seems wonky and bloated, is there a way to parameterize this or a better methodology to accomplish my end goal?这看起来很奇怪而且很臃肿,有没有办法参数化这个或更好的方法来实现我的最终目标?
Doesn't seem like there's an option in CFT other than resource duplication.除了资源复制之外,CFT 中似乎没有其他选项。
What you can do is create a Lambda with a Python script that would setup the S3 deletion policy.您可以做的是使用 Python 脚本创建一个 Lambda,该脚本将设置 S3 删除策略。 That Lambda function can be triggered through SNS during CloudFormation stack creation.
该 Lambda 函数可以在 CloudFormation 堆栈创建期间通过 SNS 触发。 Here is described how this can be configured: Is it possible to trigger a lambda on creation from CloudFormation template
这里描述了如何配置: Is it possible to trigger a lambda on creation from CloudFormation template
But in your particular case I'd go with resource duplication in same CFT.但是在您的特定情况下,我会在同一个 CFT 中使用资源重复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.