AWS > CloudFormation 模板 - 您可以在上传之前对其进行测试吗?

Posted

技术标签:

【中文标题】AWS > CloudFormation 模板 - 您可以在上传之前对其进行测试吗?【英文标题】:AWS > CloudFormation templates - can you test them before uploading? 【发布时间】:2017-06-14 03:00:07 【问题描述】:

当我将 CloudFormation 模板上传到 AWS 的管理控制台时,AWS 需要几分钟来处理该模板。

这样做 20 次迭代意味着大量时间只是在等待错误消息。

在将其上传到 AWS 的管理控制台之前是否有任何测试(最好不仅仅是“它是有效的 JSON”)吗?

例如一个贯穿始终的工具:

    它是有效的 JSON 吗? 每个资源/参数的输入是否正确? 等等……

【问题讨论】:

How can I quickly and effectively debug CloudFormation templates?的可能重复 【参考方案1】:

您可以使用 aws cli validate-template 命令

验证模板

aws cloudformation validate-template --template-body file://path/to/template

在我的工作流程中,我已将其集成到预提交 git 挂钩中以执行一些自动验证

cfn-lint

现在有一个名为 cfn-lint 的 awslabs 项目,它集成了各种编辑器,它对模板进行了更广泛的 linting。它可以从 Github 上的 awslabs 获得

https://github.com/awslabs/cfn-python-lint

这也可以作为您的 cloudformation 工作流程的预提交添加

【讨论】:

以上是关于AWS > CloudFormation 模板 - 您可以在上传之前对其进行测试吗?的主要内容,如果未能解决你的问题,请参考以下文章

AWS - 错误 - 更新 Auto Scaling 组、Amazon CloudFormation、无法部署配置

从 Lambda 函数内部访问 AWS CloudFormation ARN

AWS CloudFormation 可以调用 AWS API 吗?

AWS 批处理 cloudformation - “CannotPullContainerError”

将现有 AWS 资源整合到 CloudFormation 堆栈中

AWS Cloudformation的相关概念