SAP-C02 Question 161
Single answerYour company is using AWS CloudFormation to deploy a multi-tier web application. During deployment, you notice that the stack creation failed due to a syntax error in the template. The application is critical, and you must ensure that such errors do not affect future deployments. Which approach should you take to prevent syntax errors in the CloudFormation template?
- A
Use AWS CloudFormation Change Sets to preview changes before deployment.
- B
Enable AWS Config to validate the syntax of the CloudFormation template.
- C
Use the AWS CloudFormation Designer tool to visually edit and validate the template.
- D
Run the template through the AWS CloudFormation ValidateTemplate API before creating or updating a stack.
Show answer and explanation
Correct answer: D
Explanation
The AWS CloudFormation ValidateTemplate API is designed specifically to validate the syntax of CloudFormation templates before deployment. By using this API, you can catch syntax errors early in the development lifecycle and ensure that only valid templates are used for stack creation or updates. This approach minimizes the risk of deployment issues caused by template errors.
- A. Incorrect.
AWS CloudFormation Change Sets allow you to preview changes to resources but do not validate the syntax of the template. This option does not prevent syntax errors.
- B. Incorrect.
AWS Config is used for compliance auditing and monitoring configuration changes to AWS resources. It does not validate CloudFormation templates.
- C. Incorrect.
The AWS CloudFormation Designer tool allows visual editing but does not guarantee template validation for syntax errors.
- D. Correct.
The AWS CloudFormation ValidateTemplate API validates the syntax of a CloudFormation template without requiring stack creation. This is the correct choice to prevent syntax errors.