Lambda Function
Runs your code without managing servers, from a container image or a zip package. Lambda functions can respond to SQS or SNS messages, run on a schedule, or be exposed directly through a function URL.
Byks guides
-
Deploy a Lambda Function
Deploy a Lambda Function
-
Setting Up an API Gateway with a Lambda Integration
Expose a Lambda function as an HTTP API with API Gateway.
-
S3-triggered Lambda Function
A Lambda function that is triggered when new files arrive in an S3 bucket.
-
SQS-triggered Lambda Function
A Lambda function that is triggered by incoming messages from an SQS queue.
-
Scheduled Lambda Function
A Lambda function that runs on a schedule with EventBridge Scheduler.
-
Continuous Delivery with Lambda
Set up a continuous delivery pipeline for a Lambda function.
-
Continuous Deployment with Lambda
Set up a continuous deployment pipeline for a Lambda function.
-
Instrumenting Lambda Functions
Instrument a Lambda function to send traces, metrics, and logs to Datadog.
GitHub actions
Terraform configuration
Each entry in the lambda_functions map deploys one Lambda function. The map key becomes the function name.
module "application" {
source = "git@github.com:BYM-IKT/terraform-byks-module.git?ref=v12"
# ...
lambda_functions = {
kattehotell-booking = {
# options go here
}
}
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
memory_size |
number |
128 |
Memory, in MB, allocated to the function. Also determines the allocated vCPU. |
function_timeout |
number |
30 |
Seconds before the function times out. Must be between 1 and 900. |
package_type |
string |
"Image" |
Either Image or Zip. |
image_tag |
string |
"latest" |
Tag of the image to deploy. |
ecr_uri |
string |
null |
URI of the ECR repository the function image is pulled from, when package_type is Image. |
package_uri |
string |
null |
URI of the deployment package. Defaults to ecr_uri when package_type is Image. Required for Zip. |
lambda_handler |
string |
null |
Function handler. Required when package_type is Zip. |
lambda_runtime |
string |
null |
Lambda runtime. Required when package_type is Zip. |
environment_variables |
map(string) |
{} |
Plain-text environment variables passed to the function. |
enable_observability |
bool |
false |
Send traces, metrics, and logs to Datadog. See Instrumenting Lambda Functions. |
function_url_config |
object |
null |
Expose the function through a Lambda function URL. See Function URL configuration object. |
vpc_config |
object |
null |
Place the function inside the VPC. See VPC configuration object. |
sqs_triggers |
map(object) |
{} |
Trigger the function from SQS queues defined in sqs_queues. See SQS trigger object. |
sns_triggers |
map(object) |
{} |
Trigger the function from SNS topics defined in sns_topics. See SNS trigger object. |
schedules |
map(object) |
{} |
Run the function on an EventBridge schedule. See Schedule object. |
override_name |
string |
null |
Custom function name, instead of the generated default. |
Function URL configuration object
Used in function_url_config.
| Option | Type | Default | Description |
|---|---|---|---|
authorization_type |
string |
"AWS_IAM" |
Either AWS_IAM or NONE. |
invoke_mode |
string |
"BUFFERED" |
Either BUFFERED or RESPONSE_STREAM. |
cors_config |
object |
null |
Cross-origin resource sharing settings. See CORS configuration object. |
CORS configuration object
Used in function_url_config.cors_config.
| Option | Type | Default | Description |
|---|---|---|---|
allow_credentials |
bool |
null |
Allow requests to include credentials. |
allow_headers |
list(string) |
null |
Headers allowed in a request. |
allow_methods |
list(string) |
null |
HTTP methods allowed in a request. |
allow_origins |
list(string) |
null |
Origins allowed to call the function URL. |
expose_headers |
list(string) |
null |
Headers exposed to the caller. |
max_age |
number |
null |
Seconds browsers cache the preflight response. |
VPC configuration object
Used in vpc_config.
| Option | Type | Default | Description |
|---|---|---|---|
rds_access |
bool |
false |
Attach the security group that allows access to the discovered RDS instance. |
subnet_type |
string |
"private" |
Either private or public. |
additional_sg_ids |
list(string) |
[] |
Extra security group IDs attached to the function. |
SQS trigger object
Used in sqs_triggers. The map key must match a queue defined in sqs_queues, unless overridden.
| Option | Type | Default | Description |
|---|---|---|---|
override_sqs_queue_arn |
string |
null |
ARN of an existing SQS queue, instead of one defined in sqs_queues. |
SNS trigger object
Used in sns_triggers. The map key must match a topic defined in sns_topics, unless overridden.
| Option | Type | Default | Description |
|---|---|---|---|
override_sns_topic_arn |
string |
null |
ARN of an existing SNS topic, instead of one defined in sns_topics. |
sns_filter_json |
string |
null |
SNS subscription filter policy, as JSON. |
sns_dlq_arn |
string |
null |
ARN of the dead-letter queue for failed deliveries. |
Schedule object
Used in schedules. The map key is an arbitrary identifier for the schedule.
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
bool |
true |
Turn the schedule on or off. |
expression |
string |
required | EventBridge schedule expression, for example rate(5 minutes) or cron(0 8 * * ? *). |
payload |
string |
null |
JSON payload passed to the function on each invocation. |
description |
string |
null |
Description shown in the EventBridge Scheduler console. |
timezone |
string |
"UTC" |
Timezone the schedule expression is evaluated in. |
flexible_time_window |
string |
"OFF" |
Either OFF or FLEXIBLE. With OFF, the schedule runs at the exact time defined by expression. |
Resources
-
AWS documentation
Official AWS documentation for Lambda