Skip to main content

aws_api_gateway_resources Resource

Use the aws_api_gateway_resources Chef InSpec audit resource to test the properties of multiple AWS API Gateway Resources.

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_resources(rest_api_id: 'REST_API_ID') do
  it { should exist }
end

Parameters

rest_api_id (required)

The string identifier of the associated RestApi.

Properties

ids
The resource’s identifier.

Field: id

parent_ids
The parent resource’s identifier.

Field: parent_id

path_parts
The last path segment for this resource.

Field: path_part

paths
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 the resource is present

describe aws_api_gateway_resources(rest_api_id: 'REST_API_ID') do
  its('ids') { should include 'RESOURCE_ID' }
end

Test to ensure the parent ID is present

describe aws_api_gateway_resources(rest_api_id: 'REST_API_ID') do
  its('parent_ids') { should include 'PARENT_ID' }
end

Test to ensure the path includes /

describe aws_api_gateway_resources(rest_api_id: 'REST_API_ID') do
    its('paths') { should include "/" }
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_resources(rest_api_id: 'REST_API_ID') do
  it { should exist }
end

Use should_not to test that the entity does not exist.

describe aws_api_gateway_resources(rest_api_id: 'REST_API_ID') do
  it { should_not exist }
end

AWS Permissions

Your Principal will need the APIGateway:Client:Resources action with Effect set to Allow.

Edit this page on GitHub

Thank you for your feedback!

×