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.
Install
This resource is available in the Chef InSpec AWS resource pack.
For information on configuring your AWS environment for Chef InSpec and creating an InSpec profile that uses the InSpec AWS resource pack, see the Chef InSpec documentation on the AWS cloud platform.
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:
id
parent_id
- The parent resource’s identifier.
Field:
parent_id
path_part
- The last path segment for this resource.
Field:
path_part
path
- The full path for this resource.
Field:
path
resource_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 Principal will need the APIGateway:Client:Resource
action with Effect
set to Allow
.