Skip to content

Lambda Functions

Serverless Inbox runs on a set of purpose-built Lambda functions. They are grouped below by functional area.

All Go lambdas support a shared LOG_LEVEL variable — see Logging configuration at the bottom of this page.


These Lambdas handle synchronous HTTP and authentication requests.

The core user-facing API. Implements the JMAP protocol for email read, write, thread, search, and submission. Sits behind API Gateway (HTTP API) and is used by the Webmail UI and any JMAP-capable email client.

Trigger: HTTP API Gateway
Key resources: Config table, Item table, Changelog table, Email bucket, submission queue

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
EMAIL_BUCKET_NAMES3 bucket for stored email
EMAIL_SUBMISSION_QUEUE_URLSQS queue URL for outbound submission
AUDIT_EVENTS_QUEUE_URLSQS queue URL for audit events
API_BASE_URLPublic base URL of the JMAP HTTP API
CDN_HOSTCDN host used for attachment URLs
WEBSOCKET_URLWebSocket endpoint URL returned in session response
USER_PROVISIONER_FUNCTION_NAMELambda function name for user-provisioner
OAUTH_HANDLER_CONFIGJSON config for the OAuth handler
WEBSOCKET_BROADCAST_FUNCTION_NAMELambda function name for websocket-broadcast
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread
Item tableread/write
Changelog tableread/write
Email bucketread/write
Email submission queuesend
Audit events queuesend
user-provisioner Lambdainvoke
websocket-broadcast Lambdainvoke

The administrative backend. Handles tenant management, user provisioning, domain and identity configuration, audit log queries, and suppression list management. Used exclusively by the Admin UI and programmatic admin tooling.

Trigger: HTTP API Gateway
Key resources: Config table, Item table, Audit log table, Mail feedback table, Email bucket

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
AUDIT_LOG_TABLE_NAMEDynamoDB audit log table
MAIL_FEEDBACK_TABLE_NAMEDynamoDB table for SES bounce/complaint feedback
EMAIL_BUCKET_NAMES3 bucket for stored email
EMAIL_SUBMISSION_QUEUE_URLSQS queue URL for outbound submission
AUDIT_EVENTS_QUEUE_URLSQS queue URL for audit events
WEBSOCKET_BROADCAST_FUNCTION_NAMELambda function name for websocket-broadcast
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread/write
Item tableread/write
Changelog tableread/write
Audit log tableread
Mail feedback tableread
Email bucketread/write
Email submission queuesend
Audit events queuesend
websocket-broadcast Lambdainvoke
SESGetAccount, CreateEmailIdentity, GetEmailIdentity, GetSendStatistics, ListEmailIdentities, DeleteEmailIdentity, PutEmailIdentityDkimSigningAttributes, SendEmail
Route 53ChangeResourceRecordSets, ListHostedZonesByName
Service QuotasListServiceQuotas, RequestServiceQuotaIncrease
LambdaGetAccountSettings
STSGetCallerIdentity

A shared JWT authorizer invoked by API Gateway before routing requests to jmap-api or admin-api. Validates the bearer token against the cached public keys, then enforces the audience, scope, and group requirements configured for each API.

Trigger: API Gateway Lambda Authorizer
Key resources: JWK cache table, Config table

Environment variables
VariableDescription
JWK_CACHE_TABLE_NAMEDynamoDB table holding the cached JWKS
CONFIG_TABLE_NAMEDynamoDB config table
USER_POOL_ISSUEROIDC issuer URL
AUTH_POLICY_NAMEAuth policy record to load from config for scope/group enforcement
ALLOW_ANONYMOUStrue to allow unauthenticated requests through; defaults to false
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
JWK cache tableread
Config tableread

Handles token federation scenarios — for example, exchanging a token issued by an external identity provider for one that satisfies internal audience or scope requirements. Used in advanced auth configurations where the Admin UI or other clients need to present a differently-scoped credential to an internal API.

Trigger: HTTP API Gateway
Key resources: Config table

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
AUTH_POLICY_NAMEAuth policy record to enforce on incoming tokens
OAUTH_CLIENT_NAMENamed OAuth client from config to use for token exchange
AUDIT_EVENTS_QUEUE_URLSQS queue URL for audit events; auditing disabled if not set
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread
Audit events queuesend (optional)

These Lambdas handle the inbound and outbound email flows. See the Email Processing Pipeline and Email Sending Pipeline for full flow details.

Processes raw incoming emails. Resolves the recipient to a tenant mailbox (handling plus-addressing and alias lookup), stores the message, and triggers real-time push notifications.

Trigger: SQS (fed by SNS from SES inbound receipt)
Key resources: Config table, Item table, Changelog table, Email bucket

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
EMAIL_BUCKET_NAMES3 bucket for stored email
WEBSOCKET_BROADCAST_FUNCTION_NAMELambda function name for websocket-broadcast
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread/write
Item tableread/write
Changelog tableread/write
Email bucketread/write
websocket-broadcast Lambdainvoke

Sends queued outbound email submissions. Fetches the stored MIME message, injects server-side signatures, tags the message, and dispatches it via SES.

Trigger: SQS (submission queue)
Key resources: Config table, Item table, Changelog table, Email bucket

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
EMAIL_BUCKET_NAMES3 bucket for stored email
SES_CONFIG_SET_NAMESES configuration set used for delivery tracking
WEBSOCKET_BROADCAST_FUNCTION_NAMELambda function name for websocket-broadcast
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread
Item tableread/write
Changelog tableread/write
Email bucketread
websocket-broadcast Lambdainvoke
SESSendRawEmail

Receives delivery feedback from SES — bounces, complaints, rejections, and delivery confirmations. Updates item state, records feedback, maintains the suppression list, and emits audit events.

Trigger: SQS (fed by SNS from SES event destination)
Key resources: Item table, Mail feedback table, Changelog table, Config table, Audit events queue

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
MAIL_FEEDBACK_TABLE_NAMEDynamoDB table for SES bounce/complaint feedback
EMAIL_BUCKET_NAMES3 bucket for stored email
AUDIT_EVENTS_QUEUE_URLSQS queue URL for audit events
WEBSOCKET_BROADCAST_FUNCTION_NAMELambda function name for websocket-broadcast
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread/write
Item tableread/write
Changelog tableread/write
Mail feedback tableread/write
Email bucketread/write
Audit events queuesend
websocket-broadcast Lambdainvoke

Maintains per-account full-text search indexes. Reads the changelog to identify changed email items, fetches updated content, and writes updated Tantivy index segments to S3. Runs with elevated memory and a longer timeout to handle batch indexing efficiently.

Trigger: SQS (indexing queue)
Key resources: Email bucket (indexes path), Item table, Config table, Changelog table

Environment variables
VariableDescription
ITEM_TABLE_NAMEDynamoDB item table
CONFIG_TABLE_NAMEDynamoDB config table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
INDEX_BUCKET_NAMES3 bucket where Tantivy index segments are stored
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread
Item tableread
Changelog tableread
Index bucketread/write

These four Lambdas together implement the real-time push channel. See the explanation pages for Email Processing and Email Sending for how push notifications are emitted.

Invoked when a client opens a WebSocket connection. Authenticates the client using the cached JWK keys, then stores the connection registration so the system can push to it.

Trigger: WebSocket API Gateway ($connect route)
Key resources: JWK cache table, Config table

Environment variables
VariableDescription
CONNECTIONS_TABLE_NAMEDynamoDB table for active WebSocket connection registrations
CONFIG_TABLE_NAMEDynamoDB config table
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Connections tablewrite
JWK cache tableread
Config tableread

Invoked when a WebSocket connection closes, either by the client or due to timeout. Removes the stored connection registration.

Trigger: WebSocket API Gateway ($disconnect route)
Key resources: Item table

Environment variables
VariableDescription
CONNECTIONS_TABLE_NAMEDynamoDB table for active WebSocket connection registrations
CONFIG_TABLE_NAMEDynamoDB config table
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Connections tableread/write
Config tableread

Handles messages sent by connected clients over the WebSocket channel. In the current implementation this is minimal — the push channel is server-initiated.

Trigger: WebSocket API Gateway (default route)
Key resources: Item table

Environment variables
VariableDescription
CONNECTIONS_TABLE_NAMEDynamoDB table for active WebSocket connection registrations
ITEM_TABLE_NAMEDynamoDB item table
CONFIG_TABLE_NAMEDynamoDB config table
WEBSOCKET_API_ENDPOINTWebSocket API endpoint URL for sending messages back to clients
MAX_SUBSCRIPTIONSMaximum number of concurrent subscriptions per connection
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Connections tableread/write
Config tableread
Item tableread
API Gateway Management APIexecute-api:ManageConnections

Pushes state-change notifications to all registered WebSocket connections for a given account. Invoked directly (not via API Gateway) by other Lambdas that record data changes — for example, after a new email arrives or a message is marked as read.

Trigger: Direct Lambda invocation (from email-processor, email-sender, sqs-ses-event-processor, jmap-api, admin-api)
Key resources: Item table (connection registrations), WebSocket API Gateway Management API

Environment variables
VariableDescription
CONNECTIONS_TABLE_NAMEDynamoDB table for active WebSocket connection registrations
CONFIG_TABLE_NAMEDynamoDB config table
WEBSOCKET_API_ENDPOINTWebSocket API endpoint URL for pushing messages to connected clients
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Connections tableread/write
Config tableread
API Gateway Management APIexecute-api:ManageConnections

These Lambdas handle deployment-time setup and background maintenance tasks.

A CloudFormation custom resource that runs during CDK deployment. Seeds the Config table with the platform configuration: OIDC provider settings, auth policies, OAuth client definitions, and API endpoint metadata. Runs on every deploy update; designed to be idempotent.

Trigger: CloudFormation custom resource
Key resources: Config table

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread/write
IAMCreateServiceLinkedRole (scoped to servicequotas.amazonaws.com)

Creates a user account when invoked by the Admin API or an identity provider webhook. Writes user records, provisions default mailboxes, and records the creation event for auditing.

Trigger: Direct invocation (from admin-api or IdP webhook)
Key resources: Config table, Item table, Changelog table, Audit events queue

Environment variables
VariableDescription
CONFIG_TABLE_NAMEDynamoDB config table
ITEM_TABLE_NAMEDynamoDB item table
CHANGELOG_TABLE_NAMEDynamoDB changelog table
AUDIT_EVENTS_QUEUE_URLSQS queue URL for audit events
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Config tableread/write
Item tableread/write
Changelog tableread/write
Audit events queuesend

Periodically fetches the JWKS (JSON Web Key Set) from the configured OIDC issuer and stores the public keys in DynamoDB. This lets the authorizer and websocket-connect Lambda validate JWTs locally without making an outbound call to the IdP on every request.

Trigger: EventBridge scheduled rule
Key resources: JWK cache table

Environment variables
VariableDescription
TABLE_NAMEDynamoDB table for storing cached JWK entries
ISSUERSComma-separated list of OIDC issuer URLs to fetch keys from
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
JWK cache tableread/write
OIDC provider (internet)outbound HTTPS — fetches JWKS from each issuer’s discovery endpoint

Consumes audit events from the shared audit SQS queue and writes them to the Audit log table. By routing audit writes through a queue, business-logic Lambdas can emit audit events fire-and-forget without blocking on persistence.

Trigger: SQS (audit events queue)
Key resources: Audit log table

Environment variables
VariableDescription
AUDIT_LOG_TABLE_NAMEDynamoDB audit log table
LOG_LEVELSee Logging configuration
AWS resource access
ResourceAccess
Audit log tableread/write

All Go lambdas use a buffered logging strategy designed to keep CloudWatch Logs quiet during normal operation while retaining full diagnostic context for failures.

Default behaviour (no LOG_LEVEL set): the emit level defaults to error. Debug, info, and warn messages are written into a 1000-entry in-memory ring buffer instead of CloudWatch. Only error-level messages are emitted immediately. When an error occurs and the lambda calls Flush(), the entire ring buffer is dumped retroactively — giving you the debug trail leading up to the failure without paying the CloudWatch cost on every successful invocation. If the buffer fills (more than 1000 entries), the oldest entries are silently dropped to make room.

LOG_LEVEL values:

ValueBehaviour
(unset)Equivalent to error — only errors emitted immediately; everything else buffered
errorSame as above
warnWarn and error emitted immediately; debug and info buffered
infoInfo, warn, and error emitted immediately; debug buffered
debugAll messages emitted immediately; buffering disabled

Setting LOG_LEVEL=debug or LOG_LEVEL=info disables buffering for the corresponding levels, which is useful during development or active incident investigation but increases CloudWatch volume in production.