aws_api_gateway_resource resource
Use the aws_api_gateway_resource InSpec audit resource to test the properties of a single specific AWS API Gateway Resource.
For additional information, including parameters and properties, see the AWS documentation on AWS APIGateway Resource.
Syntax
Ensure that the resource exists.
describe aws_api_gateway_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
it { should exist }
end
Parameters
rest_api_id(required)The string identifier of the associated RestApi.
resource_id(required)The identifier for the Resource resource.
Properties
id- The resource’s identifier.
Field:
idparent_id- The parent resource’s identifier.
Field:
parent_idpath_part- The last path segment for this resource.
Field:
path_partpath- The full path for this resource.
Field:
pathresource_methods- Gets an API resource’s method of a given HTTP verb.
Field:
resource_methods
Examples
Test to ensure a resource ID is available
describe aws_api_gateway_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
its('id') { should eq 'RESOURCE_ID' }
end
Test to ensure a resource path is available
describe aws_api_gateway_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
its('path') { should eq '/' }
end
Test to ensure a resource parent ID is available
describe aws_api_gateway_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
its('parent_id') { should eq 'PARENT_ID' }
end
Matchers
For a full list of available matchers, see 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_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
it { should exist }
end
Use should_not to test that the entity does not exist.
describe aws_api_gateway_resource(rest_api_id: 'REST_API_ID', resource_id: 'RESOURCE_ID') do
it { should_not exist }
end
AWS Permissions
Your AWS principal will need the APIGateway:Client:Resource action with Effect set to Allow.