简体   繁体   English

如何从 shell 脚本中确认 aws cloudformation validate-template 命令?

[英]How to confirm the aws cloudformation validate-template command from shell script?

I want to validate cloud formation template from shell script.我想从 shell 脚本验证云形成模板。

I use aws cloudformation validate-tempate command:我使用 aws cloudformation validate-tempate 命令:

aws cloudformation validate-template --template-body file://template.yaml

But the output of the command is a colon (:) that wait for a confirmation after execution.但是命令的output是一个冒号(:),执行后等待确认。 How can I confirm it and check the status code of a command?我如何确认它并检查命令的状态代码?

I tried yes command but it did not work:我尝试了yes命令,但它没有用:

yes q | aws cloudformation validate-template --template-body file://template.yaml

I can't reproduce the column (:) behavior you describing.我无法重现您描述的列 (:) 行为。 Here is the expected output and status code check.这是预期的 output 和状态代码检查。

aws cloudformation validate-template --template-body file://good-template.yaml
... dump of the template
echo $?
0 //status is OK

aws cloudformation validate-template --template-body file://bad-template.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: JSON not well-formed. (line 615, column 1)
echo $?
255 //status is error

aws cloudformation validate-template doesn't validate much. aws cloudformation validate-template验证不多。 I'd recommend trying the CloudFormation Linter , which will catch many more issues before deploying.我建议尝试CloudFormation Linter ,它会在部署前发现更多问题。 The Visual Studio Code extension can show all of those errors inline while authoring templates as well Visual Studio Code 扩展可以在编写模板时内联显示所有这些错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 aws cloudformation 脚本中不支持的格式错误 - How can I resolve non supported format error in aws cloudformation script AWS CloudFormation:如何从另一个 AWS 账户为 Lambda 代码指定一个存储桶? - AWS CloudFormation: How to specify a bucket from another AWS account for Lambda code? 如何使用 CloudFormation 模板连接到现有 EC2 实例并执行 shell 文件 - How to connect to an existing EC2 Instance and execute a shell file using CloudFormation Template AWS IAM Cloudformation YAML 模板错误:不允许使用“空”值 - AWS IAM Cloudformation YAML template errror: 'null' values are not allowed 如何读取 aws 数据管道中 shell 脚本中的 ssm 参数? - How to read ssm parameters in a shell script in aws data pipeline? 将 AWS Data Pipeline 导出为 CloudFormation 模板以在 Terraform 中使用它 - Exporting AWS Data Pipeline as CloudFormation template to use it in Terraform 从 CloudFormation 模板中的 DropDownList 选择多个值 - Selecting multiple values from DropDownList in CloudFormation Template 如何从 AWS Glue Python Shell 连接到 RDS 实例? - How to Connect to RDS Instance from AWS Glue Python Shell? 如何使用 AWS CloudFormation 创建 Amazon VPC? - How to create an Amazon VPC using AWS CloudFormation? 如何将“手动创建”的资源添加到 cloudformation 模板 - how to add "manually created" resources to the cloudformation template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM