|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
This section shows you how to validate a AWS CloudFormation template.
To check your template file for syntax errors, you can use the
cfn-validate-template command is designed to check only the syntax of your template. It
does not ensure that the property values you have specified for a resource are valid for that resource. Nor does
it determine the number of resources that will exist when the stack is created.
To check the operational validity, you need to attempt to create the stack. There is no sandbox or test area for AWS CloudFormation stacks, so you are charged for the resources you create during testing.
validate templates locally (using the
--template-file parameter), or with the
--template-url parameter. For example, the following command validates a sample
template, from its remote location:
PROMPT> cfn-validate-template --template-url https://www.fictitious.us/templates/sample.template --region US-West-1 PARAMETERS PARAMETER_NAME DEFAULT_VALUE NOECHO PARAMETERS Email false PARAMETERS AccessKey true PARAMETERS VolumeSize 1 false PARAMETERS SnapshotId snap-91f774fb false PARAMETERS SecretKey true PARAMETERS AvailabilityZone us-east-1a false PARAMETERS ServerPort 9418 false PARAMETERS KeyName false PARAMETERS InstanceType m1.small false
The expected result is no error message, with information about all parameters listed.
Suppose you were editing a local copy of the sample, and you accidentally removed the comma after the
ServerPort parameter. Trying to validate it again would result in the following
cfn-validate-template: Malformed input-Template format error: JSON not well-formed. (line 11, column 6)