gpt4 book ai didi

amazon-web-services - CloudFormation 参数最佳实践

转载 作者:行者123 更新时间:2023-12-03 07:40:17 25 4
gpt4 key购买 nike

我想建立一个包含 VPC、子网、IGW 等内容的 Cloudformation 堆栈...

我在网上找到的模板已经预先填充了这些内容并采用 YAML 表示法。在 YAML 中,我设置了默认值,例如CIDR block 为“x.x.x.x/16”(作为示例),并且我保存了 YAML 文件。

我将 YAML 文件上传到 s3 存储桶,并使用 Azure DevOps 运行管道并在我的 AWS 账户上执行作业。堆栈创建成功。

在这种情况下,我被告知在 YAML 文件中“硬编码”参数并不好。那么最佳实践是什么?

其次,有没有一种方法可以将参数从 azure devops 管道传递到模板文件,而不必将参数插入文件中(如果有意义的话)?

最佳答案

I was told that its not good to "hardcode" the parameters in the YAML file. What is the best practice then?

这确实取决于上下文。

模板是否用于在 CI/CD 环境中进行测试并且不需要人工干预?那么,为 VPC、子网等提供硬编码变量就完全没问题了。事实上,在这种情况下,您可能一开始就不想使用参数。

该模板是否供可能想要在不同 AWS 账户中部署该模板的不同用户使用?那么模板不应做出任何假设,您可以让用户根据堆栈需要选择每个参数。

Secondly, is there a way I can pass parameters from azure devops pipeline to the template file instead of having to insert the parameters IN the file, if that makes sense?

我想象在您的管道中,您通过运行 aws cloudformation create-stack... 来部署模板,在这种情况下,您可以使用 --parameters 来指定参数。请参阅documentation了解更多信息。

关于amazon-web-services - CloudFormation 参数最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70756091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com