A collection of AWS Security controls for AWS Lambda. Controls include templates to create Lambda Functions, AWS Config rules for monitoring compliance, and Service Control Policies. Configuration templates are available in AWS CloudFormation, AWS CLI and Terraform

Lambda
Lambda Function

Configuration template to create a Lambda Function. The template includes options to customize the function's settings such as name, runtime, code location (inline, ZIP or S3), memory size, timeout and more

CloudFormationTerraformAWS CLI
Example Lambda Function Version Configuration

This template creates a version from the current code and configuration of a Lambda function. It includes a Lambda function resource with a specified handler, role, code, runtime, and tracing configuration. The version resource is associated with the Lambda function and has a description and provisioned concurrency configuration.

CloudFormationTerraform
Permissions to Allow Amazon S3 to Invoke Lambda Function

This template grants Amazon S3 permission to invoke a function resource named `my-lambda-function` created in the same template, to process notifications for a bucket resource named `Bucket`.

CloudFormationTerraform
Permission for Public Function URL Invoke

This template grants public, unauthenticated access to invoke your function named `my-lambda-function` via its function URL.

CloudFormationTerraform
Cross Account Invoke Lambda Permission

This template grants account 123456789012 permission to invoke a Lambda function created in the same template. The Lambda function stores its code `function.zip` on an S3 bucket `my-bucket` and uses the IAM role `lambda-role`

CloudFormationTerraform
Example Layer Version Permission

This template creates an `AWS::Lambda::LayerVersionPermission` resource to grant layer usage permission to accounts in organization `o-t194hfs8cz`. The `Action` property is set to `lambda:GetLayerVersion`, the `LayerVersionArn` property is set to `arn:aws:lambda:us-west-2:123456789012:layer:my-layer:1`, the `OrganizationId` property is set to `o-t194hfs8cz`, and the `Principal` property is set to `*`.

CloudFormationTerraform
Example Lambda Layer Version

This template creates a Lambda layer named `my-layer` with the following properties: CompatibleRuntimes: [python3.6, python3.7], Content: {S3Bucket: my-bucket-us-west-2-123456789012, S3Key: layer.zip}, Description: My layer, LayerName: my-layer, LicenseInfo: MIT

CloudFormationTerraform
Lambda Function in a VPC

This template creates an AWS Lambda function connected to a VPC. The function is associated with an execution role and has a deployment package stored in an S3 bucket. The function has a timeout of 5 seconds and active tracing configuration. It is also configured with a VPC, with specified security group IDs and subnet IDs.

CloudFormationTerraform
Lambda Function with Inline Code

This template creates an inline AWS Lambda function using Node.js runtime. The function lists Amazon S3 buckets in the `us-east-1` region. The function is associated with an execution role

CloudFormationTerraform
Node.js Function with Code on S3

This template creates an AWS Lambda function using Node.js runtime. The function is associated with an execution role and has a deployment package stored in an S3 bucket. The function has a timeout of 25 seconds and active tracing configuration.

CloudFormationTerraform
Event Source Mapping to Read from Kinesis Stream

This template creates an event source mapping that reads events from Amazon Kinesis and invokes a Lambda function in the same template.

CloudFormationTerraform
Lambda Asynchronous Invocation Configuration

This template creates a Lambda function with error handling and destination configuration. It also creates a version of the function and configures an event invoke configuration for asynchronous invocation. The function is written in Node.js and has a tracing configuration set to active. The event invoke configuration specifies a destination for both success and failure cases, sets a maximum event age of 300 seconds, a maximum retry attempts of 1, and uses the version as the qualifier.

CloudFormationTerraform
Lambda Function with Weighted Alias

This template creates a Lambda function with two versions and an alias. The function code is provided as a zip file. The alias is used to provide clients with a function identifier that can be updated to invoke a different version. The alias has a routing configuration that routes requests to both versions, with a weight of 0.5 for the first version and 0.5 for the second version. The function has an active tracing configuration.

CloudFormationTerraform
Lambda Function with Alias and Version

This template creates a Node.js Lambda function with a version and alias. The function code is provided as a zip file. The alias is used to provide clients with a function identifier that can be updated to invoke a different version. The function has an active tracing configuration.

CloudFormationTerraform
Invoke AWS Lambda Function

This template invokes an AWS Lambda function and retrieves a specific value from the JSON result.

Terraform
AWS Lambda Alias Creation

Creates an alias named 'my_alias' for a specified AWS Lambda function version, with routing configuration to another version.

Terraform
Lambda Code Signing Configuration

Creates a Lambda code signing configuration with specified allowed publishers and deployment policies.

Terraform
Self Managed Apache Kafka to Lambda Event Source Mapping

Maps a self-managed Apache Kafka topic to a Lambda function, including VPC configuration for secure access.

Terraform
SQS with Event Filter to Lambda Mapping

Maps an SQS queue to a Lambda function with a filter to process messages based on specific criteria.

Terraform
Amazon MQ (ActiveMQ) to Lambda Event Source Mapping

Maps an Amazon MQ (ActiveMQ) broker to a Lambda function, including authentication configuration.

Terraform
Amazon MQ (RabbitMQ) to Lambda Event Source Mapping

Maps an Amazon MQ (RabbitMQ) broker to a Lambda function, including virtual host and authentication configuration.

Terraform
Lambda Function Event Invoke with Destination Configuration

Configures a Lambda function to send invocation results to specific AWS services on success or failure.

Terraform
Lambda Function URL Configuration

Defines two Lambda function URLs with different authorization settings and CORS configurations.

Terraform
Basic Lambda Invocation

Invokes an AWS Lambda function with static input values and outputs a specific result entry.

Terraform
Dynamic Lambda Invocation Using Triggers

Invokes an AWS Lambda function dynamically based on changes to the environment, using triggers to detect changes.

Terraform
Lambda Layer Version Permission Example

This Terraform template grants permission to a specific AWS account to access a Lambda Layer version.

Terraform
Lambda Permission for CloudWatch Events

Grants permission for CloudWatch Events to invoke a specific Lambda function.

Terraform
Lambda Permission for SNS Topic Invocation

Allows an SNS topic to invoke a Lambda function.

Terraform
Lambda Permission for API Gateway REST API

Configures permissions for an API Gateway to invoke a Lambda function.

Terraform
Lambda Permission for CloudWatch Log Group

Allows a CloudWatch Log Group to invoke a Lambda function for logging purposes.

Terraform
Lambda Permission for Cross-Account Function URL Invocation

Sets up a Lambda function URL to be invoked by a specific IAM role from a different AWS account.

Terraform
Lambda Permission with Lifecycle Configuration

Ensures Lambda permissions are re-applied when the underlying function changes, using a lifecycle configuration.

Terraform
Basic Lambda Function Setup

This template sets up a basic AWS Lambda function with an IAM role and a zipped source file.

Terraform
Lambda Function with Ephemeral Storage

This template configures a Lambda function with increased ephemeral storage up to 10 GB.

Terraform
Config Rule
Lambda Public Access Prohibited Check

Checks whether the AWS Lambda function policy attached to the Lambda resource prohibits public access. If the Lambda function policy allows public access it is noncompliant.

CloudFormationTerraformAWS CLI
Lambda Function Settings Check

A Config rule that checks that the lambda function settings for runtime, role, timeout, and memory size match the expected values.

CloudFormationTerraformAWS CLI
Lambda Code is Versioned Check

A config rule that checks that all the lambda functions have at least one defined version and alias, also ensure that no alias pointing to $LATEST version

CloudFormationTerraformAWS CLI
Lambda Concurrency Limit is Configured Check

A config rule that checks whether the AWS Lambda function is configured for function-level concurrent execution limit.

CloudFormationTerraformAWS CLI
Lambda Inside a VPC Check

A config rule that checks whether the AWS Lambda function is in a VPC or not

CloudFormationTerraformAWS CLI
Lambda Logging Allowed by IAM Role

A config rule that checks whether each Lambda function has the permission for logging. Each Lambda functions should have an IAM role with appropriate IAM permissions to publish its Lambda function logs to CloudWatch.

CloudFormationTerraformAWS CLI
Lambda Dead Letter Queue (DLQ) Enabled Check

A Config rule that checks whether an AWS Lambda function is configured with a dead-letter queue. The rule is NON_COMPLIANT if the Lambda function is not configured with a dead-letter queue

CloudFormationTerraformAWS CLI
Lambda VPC Multiple AZ Check

A Config rule that checks if Lambda has more than 1 availability zone associated. The rule is NON_COMPLIANT if only 1 availability zone is associated with the Lambda or the number of availability zones associated is less than number specified in the optional parameter.

CloudFormationTerraformAWS CLI