When I create a resource with AWS CloudFormation, I receive a "Model Validation Failed" error in my stack events.
Short description
CloudFormation uses Type, Allowed, Minimum, Maximum, and Pattern values as the acceptance criteria when you use its template to create a resource property. 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
To resolve model validation errors, complete the following steps:
-
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.
-
Identify the resource type that's experiencing the error. For example, AWS::CloudWatch::Alarm.
-
Look up the properties of the resource.
-
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.
-
If the property values of the resource don't meet the acceptance criteria, then edit the template with the required values.
For example, to edit the template with the Namespace property for resource type AWS::CloudWatch:Alarm, use the following acceptance criteria:
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 [^:].* (with no other characters).
-
Update the CloudFormation stack with the new template.