rvn-lambda · Latest version: 0.3.1
Dependencies and consumers
Every dependency input can be specified manually to reference existing external infrastructure rather than a Ravion module.Readme
AWS Lambda function with zip or container image deployments, alias-based releases, IAM, logs, and optional function URLs.Overview
The Lambda Function module creates an AWS Lambda function, execution role, CloudWatch log group, optional artifact bucket, and a live alias that Ravion updates during deployments. Terraform provisions the long-lived function infrastructure with either a bootstrap zip package or a bootstrap container image. Deployments publish a new function version and move the live alias. Terraform source: flightcontrolhq/modules/compute/lambdaUse cases
Build and deployment
Lambda type and package type are immutable after creation. Lambda@Edge functions must be created in us-east-1, and AWS Lambda does not support changing an existing function between zip packages and container images. For zip package functions, builds use a Dockerfile to produce Lambda package contents from the selected Git repository. The build uploads a zip file to the module-managed code bucket. Deployments take an S3 object key, update the Lambda function code, publish a new version, and move the live alias to that version. If Build source is Pull from S3 for zip packages, Ravion skips the build step and you provide an existing S3 object key at deploy time. For container image functions, Nixpacks and Dockerfile builds produce a Lambda-compatible container image, push it to a module-managed ECR repository, and deployments promote a tag or digest from that repository. Pull from image registry skips the build step and promotes a tag or digest from the ECR repository configured on the module. Image start command, entry point, and working directory overrides are optional; leave them empty to use the image defaults. Terraform creates image package functions by pushing a small Lambda-compatible bootstrap image into a module-managed ECR repository during the same apply. For Pull from image registry, that bootstrap image lets the function be created before the first deployment promotes the configured ECR image tag or digest.Function configuration
Runtime, handler, memory, timeout, architecture, environment variables, layers, tracing, image config, and ephemeral storage are managed by the stack. Handler, runtime, layers, code signing, SnapStart, Lambda@Edge constraints, and the code bucket apply only to zip package functions. Change these settings through a stack change so Terraform remains the source of truth for function configuration. The deploy step focuses on code promotion.Networking and integrations
Connect to a VPC when the function needs private subnet access to databases, caches, or internal services. Invoke permissions let AWS services or accounts call the function. Event source mappings connect queues and streams directly to the function. File systems mount EFS access points under /mnt paths.Configuration
Design decisions
- Lambda type is immutable. Create a new Lambda module/function to migrate between Regional Lambda and CloudFront Lambda@Edge, especially when the existing function is outside us-east-1.
- Package type is immutable. Create a new Lambda module/function to migrate between zip packages and container images.
- Zip package functions use the Lambda build pipeline to upload zip packages to S3 and the Lambda deploy manager to promote those packages.
- Container image functions use the image build pipeline to push Dockerfile or Nixpacks builds to ECR. Pull from image registry promotes tags or digests from an existing ECR repository.
- Terraform creates a bootstrap zip package for zip functions and creates image package functions with a bootstrap image in the module-managed ECR repository.
- Runtime configuration stays in Terraform to avoid deploy-time configuration drift.
- The zip code bucket is versioned, but the build output currently passes the S3 key as the primary deploy input.
Learn more
- AWS Lambda developer guide
- Configuring Lambda functions
- Lambda function URLs
- Lambda event source mappings
Inputs reference
All inputs forrvn-lambda version 0.3.1. Use the name shown for each field as the input key in module config.
AWS account & region
AWS account.
- Immutable after creation
Region.
- Immutable after creation
Lambda function
Lambda type.
- Default:
regional - Allowed values:
regional(Regional Lambda),edge(CloudFront Lambda@Edge) - Immutable after creation
Function name. Name for the Lambda function and related resources.
- Default:
<<project.given_id>>-<<environment.given_id>>-<<module.given_id>> - Immutable after creation
- Pattern:
^[A-Za-z0-9_-]{1,64}$— 1-64 letters, numbers, underscores, or hyphens.
Function description. Description shown for the Lambda function in AWS.
Package type.
- Default:
Zip - Allowed values:
Zip(Zip package),Image(Container image) - Immutable after creation
Architecture. CPU architecture used by the function.
- Default:
x86_64 - Allowed values:
x86_64,arm64 - Shown when:
{"lambda_type":"regional"}
Version publishing. Publish a new immutable Lambda version on function updates. Required for Lambda@Edge and aliases that target published versions.
- Default:
false - Shown when:
{"lambda_type":"regional"}
Zip package
Runtime. Lambda runtime for Zip packages.
- Default:
$values:first - Allowed values:
nodejs22.x(Node.js 22.x),nodejs20.x(Node.js 20.x),python3.13(Python 3.13),python3.12(Python 3.12),python3.11(Python 3.11),ruby3.4(Ruby 3.4),ruby3.3(Ruby 3.3),java21(Java 21),java17(Java 17),dotnet8(.NET 8),provided.al2023(Go provided AL2023) - Shown when:
{"package_type":"Zip"}
Handler. Function entrypoint for the zip package, such as index.handler.
- Shown when:
{"package_type":"Zip"}
Package S3 bucket. S3 bucket containing the deployment package. Leave empty to create a managed code bucket.
- Shown when:
{"package_type":"Zip"}
Package S3 key. S3 key of the deployment package. Required when Package S3 bucket is set.
- Shown when:
{"package_type":"Zip"}
Code bucket name. Name for the s3 bucket used for Lambda zip artifacts. Must be globally unique. Defaults to <function-name>-code-<account-id>.
- Immutable after creation
- Pattern:
^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$— Use a valid S3 bucket name: lowercase letters, numbers, hyphens, and periods; start and end with a letter or number. - Shown when:
{"package_type":"Zip"}
Force destroy code bucket. Delete the code bucket even when it contains package objects during stack destroy.
- Default:
true - Shown when:
{"package_type":"Zip"}
Bootstrap object key. S3 key for the initial bootstrap deployment package in the managed code bucket.
- Default:
bootstrap-package.zip - Shown when:
{"package_type":"Zip"}
Build config
Build source.
- Default:
dockerfile - Allowed values:
dockerfile(Dockerfile),s3_package(Pull from S3),image_registry(Pull from image registry)
Git repository.
- Shown when:
{"build_source":["nixpacks","dockerfile"]}
Source base path. Repository-relative source and build root.
- Default:
. - Shown when:
{"build_source":["nixpacks","dockerfile"]}
Package output directory. Directory inside the built image that contains the Lambda package files.
- Default:
/app - Shown when:
{"build_source":["nixpacks","dockerfile"],"package_type":"Zip"}
Image repository. ECR repository URI without a tag or digest, such as 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-function. Lambda requires an ECR repository in the same AWS account.
- Shown when:
{"build_source":"image_registry","package_type":"Image"}
Start command. Optional command arguments that override the image default command (CMD). Leave empty to use the image default.
- Default:
[] - Shown when:
{"build_source":"image_registry","lambda_type":"regional","package_type":"Image"}
Entry point. Optional entry point arguments that override the image default ENTRYPOINT.
- Default:
[] - Shown when:
{"build_source":"image_registry","lambda_type":"regional","package_type":"Image"}
Working directory. Optional working directory override inside the image.
- Shown when:
{"build_source":"image_registry","lambda_type":"regional","package_type":"Image"}
Docker
Dockerfile path. Path to the Dockerfile to use for the build, relative to the repository root or configured source base path.
- Shown when:
{"build_source":"dockerfile"}
Docker build context path. Directory to use as the Docker build context, relative to the repository root or configured source base path.
- Shown when:
{"build_source":"dockerfile"}
Nixpacks
Install command.
- Shown when:
{"build_source":"nixpacks"}
Build command.
- Shown when:
{"build_source":"nixpacks"}
Start command.
- Shown when:
{"build_source":"nixpacks","package_type":"Image"}
Nixpacks config file path. Path to a custom Nixpacks config file, relative to the repository root or configured source base path.
- Shown when:
{"build_source":"nixpacks"}
Nixpacks build path. Application path for Nixpacks to build, relative to the repository root or configured source base path.
- Shown when:
{"build_source":"nixpacks"}
Nixpacks version. Optional Nixpacks version to use for the build. Leave blank to use the default version.
- Shown when:
{"build_source":"nixpacks"}
Nix packages. Additional Nix packages to install during the Nixpacks build.
- Shown when:
{"build_source":"nixpacks"}
APT packages. Additional APT packages to install during the Nixpacks build.
- Shown when:
{"build_source":"nixpacks"}
Nix libraries. Additional Nix libraries to make available during the Nixpacks build.
- Shown when:
{"build_source":"nixpacks"}
Runtime configuration
Memory (MB). Memory allocated to the function. Lambda CPU scales with memory.
- Default:
128 - Min:
128 - Max:
10240 - Shown when:
{"lambda_type":"regional"}
Timeout (secs). Maximum runtime for a single invocation.
- Default:
5 - Min:
1 - Max:
900 - Shown when:
{"lambda_type":"regional"}
Ephemeral storage (MB). Size of the function’s /tmp directory.
- Default:
512 - Min:
512 - Max:
10240 - Shown when:
{"lambda_type":"regional"}
Lambda layers. Versioned Lambda layer ARNs to attach to the function.
- Default:
[] - Shown when:
{"lambda_type":"regional","package_type":"Zip"}
Reserved concurrency. Reserved concurrent executions for this function. Use -1 to remove limits.
- Min:
-1 - Shown when:
{"lambda_type":"regional"}
Environment KMS key ARN. Optional customer-managed KMS key ARN used to encrypt environment variables.
- Shown when:
{"lambda_type":"regional"}
X-Ray tracing. Choose whether Lambda actively traces invocations with AWS X-Ray.
- Default:
PassThrough - Allowed values:
PassThrough(Pass through),Active - Shown when:
{"lambda_type":"regional"}
Code signing config ARN. Optional Lambda code signing configuration ARN.
- Shown when:
{"lambda_type":"regional","package_type":"Zip"}
Dead-letter target ARN. Optional SQS queue or SNS topic ARN for asynchronous invocation failures.
- Shown when:
{"lambda_type":"regional"}
File systems. EFS access points mounted into the function.
- Default:
[] - Shown when:
{"lambda_type":"regional"}
Environment variables
Build environment variables. Environment variables available during builds. Values can be plain strings or references loaded from Parameter Store or Secrets Manager.
- Shown when:
{"build_source":["nixpacks","dockerfile"]}
Inject environment variables in Dockerfile. Pass build environment variables into Dockerfile builds as build arguments.
- Default:
false - Shown when:
{"build_source":"dockerfile"}
Runtime environment variables. Environment variables passed to the Lambda function.
- Default:
{} - Shown when:
{"lambda_type":"regional"}
VPC config
VPC access. Optional. Attach the Lambda function to a VPC only when it needs private network access.
- Default:
false - Shown when:
{"lambda_type":"regional"}
VPC network. Optional VPC network for Lambda VPC access. Leave empty for a Lambda function that does not attach to a VPC.
- Immutable after creation
- Shown when:
{"lambda_type":"regional","vpc_config_enabled":true}
Run in private subnets. Use private subnets from the selected VPC network. Turn off to use public subnets.
- Default:
true - Shown when:
{"lambda_type":"regional","vpc_config_enabled":true}
Security group IDs. Security group IDs to attach to the Lambda function ENIs.
- Shown when:
{"lambda_type":"regional","vpc_config_enabled":true}
IPv6 allowed for dual stack. Allow outbound IPv6 for dual-stack subnets.
- Default:
false - Shown when:
{"lambda_type":"regional","vpc_config_enabled":true}
IAM permissions
Create IAM role. Create and manage the Lambda execution role in this module.
- Default:
true - Immutable after creation
Existing role ARN. IAM role ARN to use when this module should not create the role.
- Shown when:
{"role_creation_enabled":false}
Role name. Custom IAM role name. Defaults to <function-name>-lambda-role.
- Immutable after creation
- Shown when:
{"role_creation_enabled":true}
Role path. IAM path for the created role.
- Default:
/ - Immutable after creation
- Shown when:
{"role_creation_enabled":true}
Permissions boundary ARN. Optional IAM permissions boundary for the created role.
- Shown when:
{"role_creation_enabled":true}
Basic execution policy. Attach AWSLambdaBasicExecutionRole to the created role.
- Default:
true - Shown when:
{"role_creation_enabled":true}
VPC execution policy. Attach AWSLambdaVPCAccessExecutionRole to the created role when VPC config is set.
- Default:
true - Shown when:
{"lambda_type":"regional","role_creation_enabled":true}
Managed policy ARNs. Additional managed policies to attach to the created role.
- Default:
[] - Shown when:
{"role_creation_enabled":true}
Inline role policies. Map of inline policy name to JSON policy document for the created role.
- Default:
{} - Shown when:
{"role_creation_enabled":true}
Invoke permissions. Permission statements for services or accounts that invoke this function.
- Default:
[] - Shown when:
{"lambda_type":"regional"}
Logs
Create log group. Create and manage the CloudWatch log group for this function.
- Default:
true
Log group name. Custom CloudWatch log group name. Defaults to /aws/lambda/{function name}.
- Shown when:
{"log_group_creation_enabled":true}
Log retention days. Days to retain CloudWatch logs. Use 0 to retain indefinitely.
- Default:
30 - Allowed values:
0(Never expire),1(1 day),3(3 days),5(5 days),7(7 days),14(14 days),30(30 days),60(60 days),90(90 days),180(180 days),365(1 year) - Shown when:
{"log_group_creation_enabled":true}
Log KMS key ID. Optional KMS key ID or ARN for log group encryption.
- Shown when:
{"log_group_creation_enabled":true}
Function URL
Function URL. Create an HTTPS endpoint for the function.
- Default:
false - Shown when:
{"lambda_type":"regional"}
Function URL auth type. Choose whether the function URL requires AWS IAM authorization.
- Default:
AWS_IAM - Allowed values:
AWS_IAM(AWS IAM),NONE(None) - Shown when:
{"function_url_enabled":true,"lambda_type":"regional"}
Function URL invoke mode. Choose buffered responses or response streaming.
- Default:
BUFFERED - Allowed values:
BUFFERED(Buffered),RESPONSE_STREAM(Response stream) - Shown when:
{"function_url_enabled":true,"lambda_type":"regional"}
Function URL CORS. Configure CORS headers for the function URL.
- Default:
false - Shown when:
{"function_url_enabled":true,"lambda_type":"regional"}
Allowed origins. Origins allowed to call the function URL.
- Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Allowed methods. HTTP methods allowed by function URL CORS.
- Default:
["GET","POST"] - Allowed values:
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS - Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Allowed headers. HTTP headers allowed in CORS requests.
- Default:
[] - Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Allow credentials. Allow browsers to include credentials in CORS requests.
- Default:
false - Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Exposed headers. Response headers browsers may expose to client code.
- Default:
[] - Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Max age (secs). Seconds browsers can cache the CORS preflight response.
- Min:
0 - Shown when:
{"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
Event sources and aliases
Event source mappings. Event source mappings for streams, queues, and self-managed sources. Use advanced Terraform variables for uncommon nested mapping options.
- Default:
[] - Shown when:
{"lambda_type":"regional"}
Aliases. Lambda aliases keyed by alias name. Use aliases when callers need a stable function ARN, when routing traffic between published versions, or when integrating with services that should not point directly at $LATEST.
- Default:
{} - Shown when:
{"lambda_type":"regional"}
Advanced Lambda settings
SnapStart. Enable Lambda SnapStart for published versions. AWS currently supports this for Java runtimes.
- Allowed values:
PublishedVersions(Published versions) - Shown when:
{"lambda_type":"regional","package_type":"Zip"}
Builder config
Builder instance type. Use EC2 for quick start or EC2 spot for cheaper, but potentially delayed builds.
- Default:
ec2 - Allowed values:
ec2(EC2),ec2-spot(EC2 spot) - Shown when:
{"build_source":["dockerfile","railpack","nixpacks"]}
Builder instance size. EC2 instance type for builds. Start with the default value, then increase or decrease it based on the resource usage report at the end of builds.
- Default:
c7a.4xlarge - Shown when:
{"build_source":["dockerfile","railpack","nixpacks"]}
Builder execution environment. Optional execution environment ID or given ID for builds. Defaults to the module Terraform execution environment.
- Shown when:
{"build_source":["dockerfile","railpack","nixpacks"]}
Builder AMI. Optional AMI ID for build runners. Leave empty to use the default runner image.
- Shown when:
{"build_source":["dockerfile","railpack","nixpacks"]}
Image registry lifecycle
Scan images on push. Ask ECR to run its basic vulnerability scan whenever a new image is pushed. Keep this on for early dependency and OS package findings; disable only if another scanner owns image scanning or duplicate findings are noisy.
- Default:
true - Shown when:
{"lambda_type":"regional","package_type":"Image"}
Force delete image repository. Allow the ECR repository to be deleted even when it contains images. Use with care.
- Default:
false - Shown when:
{"lambda_type":"regional","package_type":"Image"}
Misc
Tags. A map of tags to assign to all resources. Default tags are
Owner, ProjectGivenId, EnvironmentGivenId, ModuleGivenId, ModuleIdTerraform settings
OpenTofu version override. Override the environment’s default version for this module
Ravion Terraform workspace name. Override Terraform state backend workspace name. Defaults to project + environment + module given ids.
- Immutable after creation
Advanced Terraform variables. Optional raw Terraform variable overrides for advanced module inputs or one-off overrides. Values here override the generated variables above.
- Default:
{}
Terraform execution environment. Override the execution environment for Terraform runners. Must use the same AWS account as selected above.