Skip to main content
Type: 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/lambda

Use 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

Inputs reference

All inputs for rvn-lambda version 0.3.1. Use the name shown for each field as the input key in module config.

AWS account & region

aws_account_id
string
required
AWS account.
  • Immutable after creation
aws_region
string
required
Region.
  • Immutable after creation

Lambda function

lambda_type
string
required
Lambda type.
  • Default: regional
  • Allowed values: regional (Regional Lambda), edge (CloudFront Lambda@Edge)
  • Immutable after creation
name
string
required
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.
description
string
Function description. Description shown for the Lambda function in AWS.
package_type
string
required
Package type.
  • Default: Zip
  • Allowed values: Zip (Zip package), Image (Container image)
  • Immutable after creation
architecture
string
required
Architecture. CPU architecture used by the function.
  • Default: x86_64
  • Allowed values: x86_64, arm64
  • Shown when: {"lambda_type":"regional"}
version_publishing_enabled
boolean
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
string
required
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
string
required
Handler. Function entrypoint for the zip package, such as index.handler.
  • Shown when: {"package_type":"Zip"}
s3_bucket
string
Package S3 bucket. S3 bucket containing the deployment package. Leave empty to create a managed code bucket.
  • Shown when: {"package_type":"Zip"}
s3_key
string
Package S3 key. S3 key of the deployment package. Required when Package S3 bucket is set.
  • Shown when: {"package_type":"Zip"}
code_bucket_name
string
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"}
code_bucket_force_destroy_enabled
boolean
Force destroy code bucket. Delete the code bucket even when it contains package objects during stack destroy.
  • Default: true
  • Shown when: {"package_type":"Zip"}
placeholder_object_key
string
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
string
required
Build source.
  • Default: dockerfile
  • Allowed values: dockerfile (Dockerfile), s3_package (Pull from S3), image_registry (Pull from image registry)
source_repo
gitrepo
required
Git repository.
  • Shown when: {"build_source":["nixpacks","dockerfile"]}
source_base_path
string
Source base path. Repository-relative source and build root.
  • Default: .
  • Shown when: {"build_source":["nixpacks","dockerfile"]}
output_directory
string
required
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
string
required
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"}
image_start_command
string_array
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"}
image_entry_point
string_array
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"}
image_working_directory
string
Working directory. Optional working directory override inside the image.
  • Shown when: {"build_source":"image_registry","lambda_type":"regional","package_type":"Image"}

Docker

dockerfile
string
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"}
dockerfile_context
string
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

nixpacks_install_cmd
string
Install command.
  • Shown when: {"build_source":"nixpacks"}
nixpacks_build_cmd
string
Build command.
  • Shown when: {"build_source":"nixpacks"}
nixpacks_start_cmd
string
Start command.
  • Shown when: {"build_source":"nixpacks","package_type":"Image"}
nixpacks_config_file_path
string
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
string
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
string
Nixpacks version. Optional Nixpacks version to use for the build. Leave blank to use the default version.
  • Shown when: {"build_source":"nixpacks"}
nixpacks_nix_pkgs
string_array
Nix packages. Additional Nix packages to install during the Nixpacks build.
  • Shown when: {"build_source":"nixpacks"}
nixpacks_apt_pkgs
string_array
APT packages. Additional APT packages to install during the Nixpacks build.
  • Shown when: {"build_source":"nixpacks"}
nixpacks_nix_libs
string_array
Nix libraries. Additional Nix libraries to make available during the Nixpacks build.
  • Shown when: {"build_source":"nixpacks"}

Runtime configuration

memory_size
number
required
Memory (MB). Memory allocated to the function. Lambda CPU scales with memory.
  • Default: 128
  • Min: 128
  • Max: 10240
  • Shown when: {"lambda_type":"regional"}
timeout
number
required
Timeout (secs). Maximum runtime for a single invocation.
  • Default: 5
  • Min: 1
  • Max: 900
  • Shown when: {"lambda_type":"regional"}
ephemeral_storage_size
number
Ephemeral storage (MB). Size of the function’s /tmp directory.
  • Default: 512
  • Min: 512
  • Max: 10240
  • Shown when: {"lambda_type":"regional"}
layers
string_array
Lambda layers. Versioned Lambda layer ARNs to attach to the function.
  • Default: []
  • Shown when: {"lambda_type":"regional","package_type":"Zip"}
reserved_concurrent_executions
number
Reserved concurrency. Reserved concurrent executions for this function. Use -1 to remove limits.
  • Min: -1
  • Shown when: {"lambda_type":"regional"}
kms_key_arn
string
Environment KMS key ARN. Optional customer-managed KMS key ARN used to encrypt environment variables.
  • Shown when: {"lambda_type":"regional"}
tracing_mode
string
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
string
Code signing config ARN. Optional Lambda code signing configuration ARN.
  • Shown when: {"lambda_type":"regional","package_type":"Zip"}
dead_letter_target_arn
string
Dead-letter target ARN. Optional SQS queue or SNS topic ARN for asynchronous invocation failures.
  • Shown when: {"lambda_type":"regional"}
file_system_configs
object_array
File systems. EFS access points mounted into the function.
  • Default: []
  • Shown when: {"lambda_type":"regional"}

Environment variables

build_environment_variables
object
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"]}
dockerfile_inject_env_variables
boolean
Inject environment variables in Dockerfile. Pass build environment variables into Dockerfile builds as build arguments.
  • Default: false
  • Shown when: {"build_source":"dockerfile"}
environment_variables
object
Runtime environment variables. Environment variables passed to the Lambda function.
  • Default: {}
  • Shown when: {"lambda_type":"regional"}

VPC config

vpc_config_enabled
boolean
VPC access. Optional. Attach the Lambda function to a VPC only when it needs private network access.
  • Default: false
  • Shown when: {"lambda_type":"regional"}
network
$ref:rvn-aws-network
required
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}
private_subnet_placement_enabled
boolean
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}
vpc_security_group_ids
string_array
required
Security group IDs. Security group IDs to attach to the Lambda function ENIs.
  • Shown when: {"lambda_type":"regional","vpc_config_enabled":true}
vpc_ipv6_allowed_for_dual_stack
boolean
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

role_creation_enabled
boolean
Create IAM role. Create and manage the Lambda execution role in this module.
  • Default: true
  • Immutable after creation
role_arn
string
required
Existing role ARN. IAM role ARN to use when this module should not create the role.
  • Shown when: {"role_creation_enabled":false}
role_name
string
Role name. Custom IAM role name. Defaults to <function-name>-lambda-role.
  • Immutable after creation
  • Shown when: {"role_creation_enabled":true}
role_path
string
Role path. IAM path for the created role.
  • Default: /
  • Immutable after creation
  • Shown when: {"role_creation_enabled":true}
role_permissions_boundary
string
Permissions boundary ARN. Optional IAM permissions boundary for the created role.
  • Shown when: {"role_creation_enabled":true}
basic_execution_policy_enabled
boolean
Basic execution policy. Attach AWSLambdaBasicExecutionRole to the created role.
  • Default: true
  • Shown when: {"role_creation_enabled":true}
vpc_execution_policy_enabled
boolean
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}
role_managed_policy_arns
string_array
Managed policy ARNs. Additional managed policies to attach to the created role.
  • Default: []
  • Shown when: {"role_creation_enabled":true}
role_inline_policies
object
Inline role policies. Map of inline policy name to JSON policy document for the created role.
  • Default: {}
  • Shown when: {"role_creation_enabled":true}
permissions
object_array
Invoke permissions. Permission statements for services or accounts that invoke this function.
  • Default: []
  • Shown when: {"lambda_type":"regional"}

Logs

log_group_creation_enabled
boolean
Create log group. Create and manage the CloudWatch log group for this function.
  • Default: true
log_group_name
string
Log group name. Custom CloudWatch log group name. Defaults to /aws/lambda/{function name}.
  • Shown when: {"log_group_creation_enabled":true}
log_retention_days
number
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
string
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_enabled
boolean
Function URL. Create an HTTPS endpoint for the function.
  • Default: false
  • Shown when: {"lambda_type":"regional"}
function_url_auth_type
string
required
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
string
required
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_enabled
boolean
Function URL CORS. Configure CORS headers for the function URL.
  • Default: false
  • Shown when: {"function_url_enabled":true,"lambda_type":"regional"}
function_url_cors_allow_origins
string_array
required
Allowed origins. Origins allowed to call the function URL.
  • Shown when: {"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
function_url_cors_allow_methods
string_array
required
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"}
function_url_cors_allow_headers
string_array
Allowed headers. HTTP headers allowed in CORS requests.
  • Default: []
  • Shown when: {"function_url_cors_enabled":true,"function_url_enabled":true,"lambda_type":"regional"}
function_url_cors_allow_credentials
boolean
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"}
function_url_cors_expose_headers
string_array
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"}
function_url_cors_max_age
number
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
object_array
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
object_map
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

snap_start_apply_on
string
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

build_infrastructure_type
string
required
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"]}
build_instance_size
string
required
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"]}
build_execution_environment_id
string
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"]}
build_ami
string
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

ecr_scan_on_push_enabled
boolean
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"}
ecr_force_deletion_enabled
boolean
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
keyvalue
Tags. A map of tags to assign to all resources. Default tags are Owner, ProjectGivenId, EnvironmentGivenId, ModuleGivenId, ModuleId

Terraform settings

opentofu_version
string
OpenTofu version override. Override the environment’s default version for this module
ravion_state_backend_workspace
string
Ravion Terraform workspace name. Override Terraform state backend workspace name. Defaults to project + environment + module given ids.
  • Immutable after creation
advanced_terraform_variables
object
Advanced Terraform variables. Optional raw Terraform variable overrides for advanced module inputs or one-off overrides. Values here override the generated variables above.
  • Default: {}
execution_environment_id
string
Terraform execution environment. Override the execution environment for Terraform runners. Must use the same AWS account as selected above.