AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS::ApiGateway::RequestValidator

The AWS::ApiGateway::RequestValidator resource sets up basic validation rules for incoming requests to your API. For more information, see Enable Basic Request Validation for an API in API Gateway in the API Gateway Developer Guide.

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: String RestApiId: String ValidateRequestBody: Boolean ValidateRequestParameters: Boolean

Properties

Name

The name of this request validator.

Required: No

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 Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ID of the request validator, such as abc123.

For more information about using the Ref function, see Ref.

Examples

Create request validator

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

See Also