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.
Topics
- Function versions
- Using the function overview
- Configuring functions (console)
- Configuring functions (API)
- Configuring function memory (console)
- Accepting function memory recommendations (console)
- Configuring triggers (console)
- Testing functions (console)
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).
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.
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 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.
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.
- Database proxies – Create a database proxy for functions that use an Amazon RDS DB instance or cluster.
- 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 proxies
To configure functions with the Lambda API, use the following actions:
- UpdateFunctionCode – Update the function's code.
- UpdateFunctionConfiguration – Update version-specific settings.
- TagResource – Tag a function.
- AddPermission – Modify the resource-based policy of a function, version, or alias.
- PutFunctionConcurrency – Configure a function's reserved concurrency.
- PublishVersion – Create an immutable version with the current code and configuration.
- CreateAlias – Create aliases for function versions.
- PutFunctionEventInvokeConfig – Configure error handling for asynchronous invocation.
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.
To update the memory of a function
-
Open the Functions page of the Lambda console.
-
Choose a function.
-
On the function configuration page, on the General configuration pane, choose Edit.
-
For Memory (MB), set a value from 128 MB to 10,240 MB.
-
Choose Save.
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.
To accept a function memory recommendation
-
Open the Functions page of the Lambda console.
-
Choose a function.
-
On the function configuration page, on the General configuration pane, choose Edit.
-
Under Memory (MB), in the memory alert, choose Update.
-
Choose Save.
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.
To add a trigger to your function.
-
Open the Functions page of the Lambda console.
-
Choose the function to update.
-
Under Function overview, choose Add trigger.
-
From the drop-down list of triggers, choose a trigger. The console displays additional configuration fields required for this trigger.
-
Choose Add.
You can create test events for your function from the Test tab.
To create a test event
-
Open the Functions page of the Lambda console.
-
Choose the function to test, and choose Test.
-
Under Test event, select New event.
-
Select a Template.
-
For Name, enter a name for the test. In the text entry box, enter the JSON test event.
-
Choose Save changes.
Saved test events are also available from the Code tab, under the Test menu. After you create one or more test events, you can invoke your function using one of your tests as an event.
To test the function
-
Open the Functions page of the Lambda console.
-
Choose the function to test, and choose Test.
-
Under Test event, select Saved events and select the event you want to use.
-
Choose Test.
-
Expand the Execution result panel to display details about the test.
You can also invoke your function without saving your test event by choosing Test before saving. This creates an unsaved test event that Lambda will preserve for the duration of the session. You can access your unsaved test events from either the Test or Code tab.