Slavik  Muz
Slavik Muz

Reputation: 1217

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

I want to validate cloud formation template from shell script.

I use aws cloudformation validate-tempate command:

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. How can I confirm it and check the status code of a command?

I tried yes command but it did not work:

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

Upvotes: 0

Views: 1588

Answers (2)

Pat Myron
Pat Myron

Reputation: 4628

aws cloudformation validate-template doesn't validate much. I'd recommend trying the CloudFormation Linter, which will catch many more issues before deploying. The Visual Studio Code extension can show all of those errors inline while authoring templates as well

Upvotes: 1

Anton
Anton

Reputation: 4052

I can't reproduce the column (:) behavior you describing. Here is the expected output and status code check.

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

Upvotes: 1

Related Questions