aws_api_gateway_request_validator Resource
Use the aws_api_gateway_request_validator
InSpec audit resource to test the properties of a single API Gateway request validator.
The AWS::ApiGateway::RequestValidator resource sets up basic validation rules for incoming integration requests to your API.
For additional information, including details on parameters and properties, see the AWS APIGateway RequestValidator documentation.
Syntax
Ensure that an API Gateway request validator exists.
describe aws_api_gateway_request_validator(rest_api_id: 'API_ID', request_validator_id: 'API_REQUEST_ID') do
it { should exist }
end
Parameters
rest_api_id
(required)The string identifier of the associated RestApi entity.
request_validator_id
(required)The identifier of the RequestValidator to be retrieved.
Properties
id
- The identifier of this RequestValidator.
name
- The name of this RequestValidator.
validate_request_body
- A Boolean flag to indicate whether to validate a request body according to the configured model schema for the method (
true
) or not (false
). validate_request_parameters
- A Boolean flag to indicate whether to validate request parameters (
true
) or not (false
).
Examples
Test to ensure a request validator ID is present
describe aws_api_gateway_request_validator(rest_api_id: 'API_ID', request_validator_id: 'API_REQUEST_ID') do
its('id') { should eq 'REQUEST_ID' }
end
Test to ensure that the request body is ’true'
describe aws_api_gateway_request_validator(rest_api_id: 'API_ID', request_validator_id: 'API_REQUEST_ID') do
its('validate_request_body') { should eq true }
end
Matchers
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.
The control passes if the get
method returns at least one result.
exist
Use should
to test that the entity exists.
describe aws_api_gateway_request_validator(rest_api_id: 'API_ID', request_validator_id: 'API_REQUEST_ID') do
it { should exist }
end
Use should_not
to test the entity does not exist.
describe aws_api_gateway_request_validator(rest_api_id: 'API_ID', request_validator_id: 'API_REQUEST_ID') do
it { should_not exist }
end
AWS Permissions
Your Principal will need the APIGateway:Client:RequestValidator
action with Effect
set to Allow
.
Was this page helpful?