AWS::ApiGateway::RequestValidator
The AWS::ApiGateway::RequestValidator resource sets up basic validation rules for incoming
requests to your API Gateway API.
For more information, see
Enable Basic Request Validation for an API in API Gateway in the API Gateway Developer Guide.
Topics
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::ApiGateway::RequestValidator", "Properties" : { "Name" :String, "RestApiId" :String, "ValidateRequestBody" :Boolean, "ValidateRequestParameters" :Boolean} }
YAML
Type: AWS::ApiGateway::RequestValidator Properties: Name:StringRestApiId:StringValidateRequestBody:BooleanValidateRequestParameters:Boolean
Properties
Note
For more information about each property, see RequestValidator in the Amazon API Gateway REST API Reference.
Name-
The name of this request validator.
Required: Yes
Type: String
Update requires: Replacement
RestApiId-
The identifier of the targeted API entity.
Required: Yes
Type: String
Update requires: Replacement
ValidateRequestBody-
Indicates whether to validate the request body according to the configured schema for the targeted API and method.
Required: No
Type: Boolean
Update requires: No interruption
ValidateRequestParameters-
Indicates whether to validate request parameters.
Required: No
Type: Boolean
Update requires: No interruption
Return Value
Ref
When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns
the ID of the request validator, such as abc123.
For more information about using the Ref function, see Ref.
Example
The following example creates an API Gateway API with an associated request validator, based on the supplied parameters.
JSON
{ "Parameters": { "apiName": { "Type": "String" }, "validatorName": { "Type": "String" }, "validateRequestBody": { "Type": "String" }, "validateRequestParameters": { "Type": "String" } }, "Resources": { "RestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Name": { "Ref": "apiName" } } }, "RequestValidator": { "Type": "AWS::ApiGateway::RequestValidator", "Properties": { "Name": { "Ref": "validatorName" }, "RestApiId": { "Ref": "RestApi" }, "ValidateRequestBody": { "Ref": "validateRequestBody" }, "ValidateRequestParameters": { "Ref": "validateRequestParameters" } } } } }
YAML
Parameters: apiName: Type: String validatorName: Type: String validateRequestBody: Type: String validateRequestParameters: Type: String Resources: RestApi: Type: AWS::ApiGateway::RestApi Properties: Name: !Ref apiName RequestValidator: Type: AWS::ApiGateway::RequestValidator Properties: Name: !Ref validatorName RestApiId: !Ref RestApi ValidateRequestBody: !Ref validateRequestBody ValidateRequestParameters: !Ref validateRequestParameters
