ValidateTemplateCommand

Validates a specified template. CloudFormation first checks if the template is valid JSON. If it isn't, CloudFormation checks if the template is valid YAML. If both these checks fail, CloudFormation returns a template validation error.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CloudFormationClient, ValidateTemplateCommand } from "@aws-sdk/client-cloudformation"; // ES Modules import
// const { CloudFormationClient, ValidateTemplateCommand } = require("@aws-sdk/client-cloudformation"); // CommonJS import
const client = new CloudFormationClient(config);
const input = { // ValidateTemplateInput
  TemplateBody: "STRING_VALUE",
  TemplateURL: "STRING_VALUE",
};
const command = new ValidateTemplateCommand(input);
const response = await client.send(command);
// { // ValidateTemplateOutput
//   Parameters: [ // TemplateParameters
//     { // TemplateParameter
//       ParameterKey: "STRING_VALUE",
//       DefaultValue: "STRING_VALUE",
//       NoEcho: true || false,
//       Description: "STRING_VALUE",
//     },
//   ],
//   Description: "STRING_VALUE",
//   Capabilities: [ // Capabilities
//     "CAPABILITY_IAM" || "CAPABILITY_NAMED_IAM" || "CAPABILITY_AUTO_EXPAND",
//   ],
//   CapabilitiesReason: "STRING_VALUE",
//   DeclaredTransforms: [ // TransformsList
//     "STRING_VALUE",
//   ],
// };

ValidateTemplateCommand Input

See ValidateTemplateCommandInput for more details

Parameter
Type
Description
TemplateBody
string | undefined

Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes.

Conditional: You must pass TemplateURL or TemplateBody. If both are passed, only TemplateBody is used.

TemplateURL
string | undefined

The URL of a file containing the template body. The URL must point to a template (max size: 1 MB) that is located in an Amazon S3 bucket or a Systems Manager document. The location for an Amazon S3 bucket must start with https://.

Conditional: You must pass TemplateURL or TemplateBody. If both are passed, only TemplateBody is used.

ValidateTemplateCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
Capabilities
Capability[] | undefined

The capabilities found within the template. If your template contains IAM resources, you must specify the CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or UpdateStack actions with your template; otherwise, those actions return an InsufficientCapabilities error.

CapabilitiesReason
string | undefined

The list of resources that generated the values in the Capabilities response element.

DeclaredTransforms
string[] | undefined

A list of the transforms that are declared in the template.

Description
string | undefined

The description found within the template.

Parameters
TemplateParameter[] | undefined

A list of TemplateParameter structures.

Throws

Name
Fault
Details
CloudFormationServiceException
Base exception class for all service exceptions from CloudFormation service.