aws_api_gateway_response Resource
Use the aws_api_gateway_response
Chef InSpec audit resource to test properties of a single AWS API Gateway gateway response.
The AWS::ApiGateway::GatewayResponse
resource creates a gateway response for your API.
For additional information, including details on parameters and properties, see the AWS documentation on the AWS::APIGateway::GatewayResponse resource.
Installation
This resource is available in the Chef InSpec AWS resource pack.
See the Chef InSpec documentation on cloud platforms for information on configuring your AWS environment for InSpec and creating an InSpec profile that uses the InSpec AWS resource pack.
Syntax
Ensure that the response exists.
describe aws_api_gateway_response(rest_api_id: 'REST_API_ID', response_type: 'RESPONSE_TYPE') do
it { should exist }
end
Parameters
rest_api_id
(required)The string identifier of the associated REST API.
response_type
(required)The response type of the associated gateway response.
Properties
response_type
- The response type of the associated GatewayResponse.
status_code
- The HTTP status code for this GatewayResponse.
response_parameters
- Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.
response_templates
- Response templates of the GatewayResponse as a string-to-string map of key-value pairs.
default_response
- A Boolean flag to indicate whether this GatewayResponse is the default gateway response (true ) or not (false ).
Examples
Ensure a response type is ‘DEFAULT_4XX’.
describe aws_api_gateway_response(rest_api_id: 'REST_API_ID', response_type: 'DEFAULT_4XX') do
its('response_type') { should eq 'DEFAULT_4XX' }
end
Ensure a status code is 200
.
describe aws_api_gateway_response(rest_api_id: 'REST_API_ID', response_type: 'RESPONSE_TYPE') do
its('status_code') { should eq '200' }
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 controls will pass if the get
method returns at least one result.
exist
Use should
to test that the entity exists.
describe aws_api_gateway_response(rest_api_id: 'REST_API_ID', response_type: 'RESPONSE_TYPE') do
it { should exist }
end
Use should_not
to test the entity does not exist.
describe aws_api_gateway_response(rest_api_id: 'REST_API_ID', response_type: 'RESPONSE_TYPE') do
it { should_not exist }
end
AWS Permissions
Your Principal will need the APIGateway:Client:GatewayResponse
action with Effect
set to Allow
.
Was this page helpful?