Skip to content

Latest commit

 

History

History
executable file
·
165 lines (102 loc) · 10.9 KB

configuration-function-common.md

File metadata and controls

executable file
·
165 lines (102 loc) · 10.9 KB

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.

Topics

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.

[The Lambda function overview, with no configured triggers or destinations.]

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 and other monitoring tools.

  • ConcurrencyReserve 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 invocationConfigure 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 proxiesCreate 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

Configuring functions (API)

To configure functions with the Lambda API, use the following actions:

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.

To update the memory of a function

  1. Open the Functions page of the Lambda console.

  2. Choose a function.

  3. On the function configuration page, on the General configuration pane, choose Edit.

  4. For Memory (MB), set a value from 128 MB to 10,240 MB.

  5. Choose Save.

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.

To accept a function memory recommendation

  1. Open the Functions page of the Lambda console.

  2. Choose a function.

  3. On the function configuration page, on the General configuration pane, choose Edit.

  4. Under Memory (MB), in the memory alert, choose Update.

  5. Choose Save.

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.

To add a trigger to your function.

  1. Open the Functions page of the Lambda console.

  2. Choose the function to update.

  3. Under Function overview, choose Add trigger.

  4. From the drop-down list of triggers, choose a trigger. The console displays additional configuration fields required for this trigger.

  5. Choose Add.

Testing functions (console)

You can create test events for your function from the Test tab.

To create a test event

  1. Open the Functions page of the Lambda console.

  2. Choose the function to test, and choose Test.

  3. Under Test event, select New event.

  4. Select a Template.

  5. For Name, enter a name for the test. In the text entry box, enter the JSON test event.

  6. 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

  1. Open the Functions page of the Lambda console.

  2. Choose the function to test, and choose Test.

  3. Under Test event, select Saved events and select the event you want to use.

  4. Choose Test.

  5. 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.