How do I resolve "Model Validation Failed" errors in CloudFormation?

2 minute read
0

When I create a resource with AWS CloudFormation, I receive a "Model Validation Failed" error in my stack events.

Short description

Type, Allowed values, Minimum, Maximum, and Pattern values are the acceptance criteria for creating a resource property using a CloudFormation template. If one of these property values isn't correctly defined, then you receive one of the following "Model Validation Failed" errors:

  • Model Validation Failed (#PropertyName: Failed validation constraint for keyword [type])
  • Model Validation Failed (#PropertyName: Failed validation constraint for keyword [pattern])
  • Model validation failed (#PropertyName: expected type: Number, found: String)

Note: The preceding error messages are examples. In the error that you receive, PropertyName is specified.

Resolution

  1. In the CloudFormation stack event, identify the property of the resource type that failed. For example, Namespace is a property of the resource AWS::CloudWatch::Alarm.
  2. Identify the resource type that's experiencing the error. For example, AWS::CloudWatch::Alarm.
  3. Look up the properties of the resource.
  4. Compare the property values that are defined in the template with the correct property values that you found in step 3.
    Note: Some properties don't include minimum or maximum character limit values.
  5. If the property values of the resource don't meet the acceptance criteria, then edit the template with the required values.
  6. Update the CloudFormation stack with the new template.

The following is an example of acceptance criteria for the Namespace property for resource type AWS::CloudWatch:Alarm:

Required: No

Type: String

Minimum: 1

Maximum: 255

Pattern: [^:].*

Update requires: No interruption

Note: For the Namespace criteria to be accepted, the Type must be String, the character limit must be between 1 and 255, and the Pattern must be [^:].*.


AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago
No comments