There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ValidateTemplate with a CLI
The following code examples show how to use ValidateTemplate.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- CLI
-
- AWS CLI
-
To validate an AWS CloudFormation template
The following
validate-templatecommand validates thesampletemplate.jsontemplate:aws cloudformation validate-template --template-bodyfile://sampletemplate.jsonOutput:
{ "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters": [], "Capabilities": [] }For more information, see Working with AWS CloudFormation Templates in the AWS CloudFormation User Guide.
-
For API details, see ValidateTemplate
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: Validates the specified template content. The output details the capabilities, description and parameters of the template.
Test-CFNTemplate -TemplateBody "{TEMPLATE CONTENT HERE}"Example 2: Validates the specified template accessed via an Amazon S3 URL. The output details the capabilities, description and parameters of the template.
Test-CFNTemplate -TemplateURL https://s3.amazonaws.com/amzn-s3-demo-bucket/templatefile.template-
For API details, see ValidateTemplate in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: Validates the specified template content. The output details the capabilities, description and parameters of the template.
Test-CFNTemplate -TemplateBody "{TEMPLATE CONTENT HERE}"Example 2: Validates the specified template accessed via an Amazon S3 URL. The output details the capabilities, description and parameters of the template.
Test-CFNTemplate -TemplateURL https://s3.amazonaws.com/amzn-s3-demo-bucket/templatefile.template-
For API details, see ValidateTemplate in AWS Tools for PowerShell Cmdlet Reference (V5).
-