AWS::ApiGateway::RequestValidator - AWS CloudFormation

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 RequestValidator

Required: No

Type: String

Update requires: Replacement

RestApiId

The string identifier of the associated RestApi.

Required: Yes

Type: String

Update requires: Replacement

ValidateRequestBody

A Boolean flag to indicate whether to validate a request body according to the configured Model schema.

Required: No

Type: Boolean

Update requires: No interruption

ValidateRequestParameters

A Boolean flag to indicate whether to validate request parameters (true) or not (false).

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.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

RequestValidatorId

The ID for the request validator. For example: abc123.

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