aws_lambda_alias Resource
Use the aws_lambda_alias
InSpec audit resource to test properties of a single AWS Lambda alias.
The AWS::Lambda::Alias
resource creates an alias for a Lambda function version. Use aliases to provide clients with a function identifier that you can update to invoke a different version.
For additional information, including details on parameters and properties, see the AWS documentation on AWS Lambda alias.
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 alias exists.
describe aws_lambda_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
it { should exist }
end
Parameters
function_name
(required)The name of the lambda function.
function_alias_name
(required)Name of the alias for which you want to retrieve information.
Properties
alias_arn
- Lambda function ARN that is qualified using the alias name as the suffix.
name
- The alias name.
function_version
- Function version to which the alias points.
description
- The alias description.
routing_config.additional_version_weights
- The name of the second alias, and the percentage of traffic that is routed to it.
revision_id
- Represents the latest updated revision of the function or alias.
Examples
Ensure an alias ARN is available.
describe aws_lambda_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
its('alias_arn') { should eq 'ALIAS_ARN' }
end
Ensure a alias name is available.
describe aws_lambda_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
its('name') { should eq 'FUNCTION_ALIAS_NAME' }
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_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
it { should exist }
end
Use should_not
to test the entity does not exist.
describe aws_lambda_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
it { should_not exist }
end
be_available
Use should
to check if the entity is available.
describe aws_lambda_alias(function_name: 'FUNCTION_NAME', function_alias_name: 'FUNCTION_ALIAS_NAME') do
it { should be_available }
end
AWS Permissions
Your Principal will need the Lambda:Client:AliasConfiguration
action with Effect
set to Allow
.