Skip to main content

aws_lambda_layer_version_permission resource

Use the aws_lambda_layer_version_permission InSpec audit resource to test properties of a single AWS Lambda layer version permission.

The AWS::Lambda::LayerVersionPermission resource adds permissions to the resource-based policy of a version of an Lambda layer.

For additional information, including details on parameters and properties, see the AWS documentation on AWS Lambda layer version permission.

Syntax

Ensure that the permission exists.

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
  it { should exist }
end

Parameters

layer_name (required)

The name or Amazon Resource Name (ARN) of the layer.

version_number (required)

The version number.

Properties

policy
The policy document.
revision_id
A unique identifier for the current revision of the policy.

Examples

Ensure a policy is available:

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
  its('policy') { should eq 'POLICY' }
end

Ensure a revision ID is available:

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
    its('revision_id') { should eq 'REVISION_ID' }
end

Matchers

For a full list of available matchers, see our Universal Matchers page.

This resource has the following special matchers.

exist

Use should to test that the entity exists.

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
  it { should exist }
end

Use should_not to test the entity does not exist.

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
  it { should_not exist }
end

be_available

Use should to check if the entity is available.

describe aws_lambda_layer_version_permission(layer_name: 'LAYER_NAME', version_number: 'VERSION_NUMBER') do
  it { should be_available }
end

AWS Permissions

Your AWS principal will need the Lambda:Client:GetLayerVersionPolicyResponse action with Effect set to Allow.

Thank you for your feedback!

×