Configuring Lambda function options
After you create a function, you can configure additional capabilities for the function, such as triggers, network access, and file system access. You can also adjust resources associated with the function, such as memory and concurrency. These configurations apply to functions defined as .zip file archives and to functions defined as container images.
You can also create and edit test events to test your function using the console.
For function configuration best practices, see Function configuration.
Sections
- Function versions
- Using the function overview
- Configuring functions (console)
- Configuring function memory (console)
- Accepting function memory recommendations (console)
- Configuring function timeout (console)
- Configuring ephemeral storage (console)
- Configuring triggers (console)
- Configuring Lambda advanced logging options
- Connecting RDS databases (console)
Function versions
A function has an unpublished version, and can have published versions and aliases. By default, the console displays configuration information for the unpublished version of the function. You change the unpublished version when you update your function's code and configuration.
A published version is a snapshot of your function code and configuration that can't be changed (except for a few configuration items relevant to a function version, such as provisioned concurrency).
Using the function overview
The Function overview shows a visualization of your function and its upstream and downstream resources. You can use it to jump to trigger and destination configuration. You can use it to jump to layer configuration for functions defined as .zip file archives.
Configuring functions (console)
For the following function configurations, you can change the settings only for the unpublished version of a function. In the console, the function Configuration tab provides the following sections:
-
General configuration – Configure memory or opt in to the AWS Compute Optimizer. You can also configure function timeout and the execution role.
-
Permissions – Configure the execution role and other permissions.
-
Environment variables – Key-value pairs that Lambda sets in the execution environment. To extend your function's configuration outside of code, use environment variables.
-
Tags – Key-value pairs that Lambda attaches to your function resource. Use tags to organize Lambda functions into groups for cost reporting and filtering in the Lambda console.
Tags apply to the entire function, including all versions and aliases.
-
Virtual private cloud (VPC) – If your function needs network access to resources that are not available over the internet, configure it to connect to a virtual private cloud (VPC).
-
Monitoring and operations tools – configure CloudWatch log groups and other monitoring tools.
-
Concurrency – Reserve concurrency for a function to set the maximum number of simultaneous executions for a function. Provision concurrency to ensure that a function can scale without fluctuations in latency. Reserved concurrency applies to the entire function, including all versions and aliases.
-
Function URL – Configure a function URL to add a unique HTTP(S) endpoint to your Lambda function. You can configure a function URL on the
$LATEST
unpublished function version, or on any function alias.
You can configure the following options on a function, a function version, or an alias.
-
Triggers – Configure triggers.
-
Destinations – Configure destinations for asynchronous invocations.
-
Asynchronous invocation – Configure error handling behavior to reduce the number of retries that Lambda attempts, or the amount of time that unprocessed events stay queued before Lambda discards them. Configure a dead-letter queue to retain discarded events.
-
Code signing – To use Code signing with your function, configure the function to include a code-signing configuration.
-
File systems – Connect your function to a file system.
-
State machines – Use a state machine to orchestrate and apply error handling to your function.
The console provides separate tabs to configure aliases and versions:
Aliases – An alias is a named resource that maps to a function version. You can change an alias to map to a different function version.
Versions – Lambda assigns a new version number each time you publish your function. For more information about managing versions, see Lambda function versions.
You can configure the following items for a published function version:
Triggers
Destinations
Provisioned concurrency
Asynchronous invocation
Database connections and proxies
Configuring function memory (console)
Lambda allocates CPU power in proportion to the amount of memory configured. Memory is the amount of memory available to your Lambda function at runtime. You can increase or decrease the memory and CPU power allocated to your function using the Memory (MB) setting. To configure the memory for your function, set a value between 128 MB and 10,240 MB in 1-MB increments. At 1,769 MB, a function has the equivalent of one vCPU (one vCPU-second of credits per second).
You can configure the memory of your function in the Lambda console.
Accepting function memory recommendations (console)
If you have administrator permissions in AWS Identity and Access Management (IAM), you can opt in to receive Lambda function memory setting recommendations from AWS Compute Optimizer. For instructions on opting in to memory recommendations for your account or organization, see Opting in your account in the AWS Compute Optimizer User Guide.
Note
Compute Optimizer supports only functions that use x86_64 architecture.
When you've opted in and your Lambda function meets Compute Optimizer requirements, you can view and accept function memory recommendations from Compute Optimizer in the Lambda console in General configuration.
Configuring function timeout (console)
Lambda runs your code for a set amount of time before timing out. Timeout is the maximum amount of time in seconds that a Lambda function can run. The default value for this setting is 3 seconds, but you can adjust this in increments of 1 second up to a maximum value of 15 minutes.
Configuring ephemeral storage (console)
By default, Lambda allocates 512 MB for a function’s /tmp directory. You can increase or decrease this amount using the Ephemeral storage (MB) setting. To configure the size of a function’s /tmp directory, set a whole number value between 512 MB and 10,240 MB, in 1-MB increments.
Note
Configuring ephemeral storage past the default 512 MB allocated incurs a cost.
For more information, see Lambda pricing
Configuring triggers (console)
You can configure other AWS services to trigger your function each time a specified event occurs. For details about how services trigger Lambda functions, see Using AWS Lambda with other services.
Configuring Lambda advanced logging options
To give you more control over how your functions’ logs are captured, processed, and consumed, Lambda offers the following logging configuration options:
-
Log format - select between plain text and structured JSON format for your function’s logs
-
Log level - for JSON structured logs, choose the detail level of the logs Lambda sends to CloudWatch, such as ERROR, DEBUG, or INFO
-
Log group - choose the CloudWatch log group your function sends logs to
For more information about configuring these options in the Lambda console, see Configuring advanced logging controls for your Lambda function.
Connecting RDS databases (console)
You can connect a Lambda function to an Amazon Relational Database Service (Amazon RDS) database directly and through an Amazon RDS Proxy. Direct connections are useful in simple scenarios, and proxies are recommended for production. A database proxy manages a pool of shared database connections which enables your function to reach high concurrency levels without exhausting database connections.
To connect Lambda functions and Amazon RDS, see Using AWS Lambda with Amazon RDS