Skip to content

Commit 83ce1c5

Browse files
committed
Add content for Extensions API (preview)
1 parent b1a45de commit 83ce1c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+859
-135
lines changed

doc_source/applications-tutorial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ When the deployment process completes, invoke the function from the Lambda conso
9494

9595
1. Choose **Test**\.
9696

97-
The Lambda console executes your function and displays the result\. Expand the **Details** section under the result to see the output and execution details\.
97+
The Lambda console runs your function and displays the result\. Expand the **Details** section under the result to see the output and execution details\.
9898

9999
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/application-create-result.png)
100100

@@ -326,7 +326,7 @@ You can continue to modify and use the sample to develop your own application\.
326326

327327
1. Open the [Amazon S3 console](https://console.aws.amazon.com/s3)\.
328328

329-
1. Delete the artifact bucket – **aws\-*us\-east\-2*\-*123456789012*\-my\-app\-pipe**\.
329+
1. Delete the artifact bucket – ***us\-east\-2*\-*123456789012*\-my\-app\-pipe**\.
330330

331331
1. Return to the AWS CloudFormation console and delete the infrastructure stack – **serverlessrepo\-my\-app\-toolchain**\.
332332

doc_source/applications-usecases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The diagram illustrates the following sequence:
2424

2525
1. Amazon S3 invokes your Lambda function using the permissions provided by the [execution role](lambda-intro-execution-role.md)\.
2626

27-
1. AWS Lambda executes the Lambda function, specifying the event as a parameter\.
27+
1. AWS Lambda runs the Lambda function, specifying the event as a parameter\.
2828

2929
You configure Amazon S3 to invoke your function as a bucket notification action\. To grant Amazon S3 permission to invoke the function, update the function's [resource\-based policy](access-control-resource-based.md)\.
3030

doc_source/best-practices.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ The following are recommended best practices for using AWS Lambda:
1616
var foo = event.foo;
1717
var bar = event.bar;
1818
var result = MyLambdaFunction (foo, bar);
19-
19+
2020
callback(null, result);
2121
}
22-
22+
2323
function MyLambdaFunction (foo, bar) {
2424
// MyLambdaFunction logic here
2525
}
2626
```
2727
+ **Take advantage of execution context reuse to improve the performance of your function\.** Initialize SDK clients and database connections outside of the function handler, and cache static assets locally in the `/tmp` directory\. Subsequent invocations processed by the same instance of your function can reuse these resources\. This saves execution time and cost\.
2828

29-
To avoid potential data leaks across invocations, don’t use the execution context to store user data, events, or other information with security implications\. If your function relies on a mutable state that can’t be stored in memory within the handler, consider creating a separate function or separate versions of a function for each user\.
29+
To avoid potential data leaks across invocations, don’t use the execution environment to store user data, events, or other information with security implications\. If your function relies on a mutable state that can’t be stored in memory within the handler, consider creating a separate function or separate versions of a function for each user\.
3030
+ **Use a keep\-alive directive to maintain persistent connections\.** Lambda purges idle connections over time\. Attempting to reuse an idle connection when invoking a function will result in a connection error\. To maintain your persistent connection, use the keep\-alive directive associated with your runtime\. For an example, see [Reusing Connections with Keep\-Alive in Node\.js](https://docs.amazonaws.cn/en_us/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html)\.
3131
+ **Use [environment variables](configuration-envvars.md) to pass operational parameters to your function\.** For example, if you are writing to an Amazon S3 bucket, instead of hard\-coding the bucket name you are writing to, configure the bucket name as an environment variable\.
3232
+ **Control the dependencies in your function's deployment package\. ** The AWS Lambda execution environment contains a number of libraries such as the AWS SDK for the Node\.js and Python runtimes \(a full list can be found here: [AWS Lambda runtimes](lambda-runtimes.md)\)\. To enable the latest set of features and security updates, Lambda will periodically update these libraries\. These updates may introduce subtle changes to the behavior of your Lambda function\. To have full control of the dependencies your function uses, package all of your dependencies with your deployment package\.
3333
+ **Minimize your deployment package size to its runtime necessities\. ** This will reduce the amount of time that it takes for your deployment package to be downloaded and unpacked ahead of invocation\. For functions authored in Java or \.NET Core, avoid uploading the entire AWS SDK library as part of your deployment package\. Instead, selectively depend on the modules which pick up components of the SDK you need \(e\.g\. DynamoDB, Amazon S3 SDK modules and [Lambda core libraries](https://github.com/aws/aws-lambda-java-libs)\)\.
3434
+ **Reduce the time it takes Lambda to unpack deployment packages** authored in Java by putting your dependency `.jar` files in a separate /lib directory\. This is faster than putting all your function’s code in a single jar with a large number of `.class` files\. See [AWS Lambda deployment package in Java](java-package.md) for instructions\.
35-
+ **Minimize the complexity of your dependencies\.** Prefer simpler frameworks that load quickly on [execution context](runtimes-context.md) startup\. For example, prefer simpler Java dependency injection \(IoC\) frameworks like [Dagger](https://google.github.io/dagger/) or [Guice](https://github.com/google/guice), over more complex ones like [Spring Framework](https://github.com/spring-projects/spring-framework)\.
35+
+ **Minimize the complexity of your dependencies\.** Prefer simpler frameworks that load quickly on [execution environment](runtimes-context.md) startup\. For example, prefer simpler Java dependency injection \(IoC\) frameworks like [Dagger](https://google.github.io/dagger/) or [Guice](https://github.com/google/guice), over more complex ones like [Spring Framework](https://github.com/spring-projects/spring-framework)\.
3636
+ **Avoid using recursive code** in your Lambda function, wherein the function automatically calls itself until some arbitrary criteria is met\. This could lead to unintended volume of function invocations and escalated costs\. If you do accidentally do so, set the function concurrent execution limit to `0` immediately to throttle all invocations to the function, while you update the code\.
3737

3838
## Function configuration<a name="function-configuration"></a>

doc_source/configuration-console.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ With the function node selected in the designer, you can modify the following se
1515

1616
**Function settings**
1717
+ **Code** – The code and dependencies of your function\. For scripting languages, you can edit your function code in the embedded [editor](code-editor.md)\. To add libraries, or for languages that the editor doesn't support, upload a [deployment package](gettingstarted-features.md#gettingstarted-features-package)\. If your deployment package is larger than 50 MB, choose **Upload a file from Amazon S3**\.
18-
+ **Runtime** – The [Lambda runtime](lambda-runtimes.md) that executes your function\.
19-
+ **Handler** – The method that the runtime executes when your function is invoked, such as `index.handler`\. The first value is the name of the file or module\. The second value is the name of the method\.
18+
+ **Runtime** – The [Lambda runtime](lambda-runtimes.md) that runs your function\.
19+
+ **Handler** – The method that the runtime runs when your function is invoked, such as `index.handler`\. The first value is the name of the file or module\. The second value is the name of the method\.
2020
+ **Environment variables** – Key\-value pairs that Lambda sets in the execution environment\. [ Use environment variables](configuration-envvars.md) to extend your function's configuration outside of code\.
2121
+ **Tags** – Key\-value pairs that Lambda attaches to your function resource\. [Use tags](configuration-tags.md) to organize Lambda functions into groups for cost reporting and filtering in the Lambda console\.
2222

2323
Tags apply to the entire function, including all versions and aliases\.
24-
+ **Execution role** – The [IAM role](lambda-intro-execution-role.md) that AWS Lambda assumes when it executes your function\.
24+
+ **Execution role** – The [IAM role](lambda-intro-execution-role.md) that AWS Lambda assumes when it runs your function\.
2525
+ **Description** – A description of the function\.
2626
+ **Memory**– The amount of memory available to the function during execution\. Choose an amount [between 128 MB and 3,008 MB](gettingstarted-limits.md) in 64\-MB increments\.
2727

doc_source/configuration-envvars.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ You set environment variables on the unpublished version of your function by spe
2727

2828
1. Choose **Save**\.
2929

30-
Use environment variables to pass environment\-specific settings to your code\. For example, you can have two functions with the same code but different configuration\. One function connects to a test database, and the other connects to a production database\. In this situation, you use environment variables to tell the function the hostname and other connection details for the database\. You might also set an environment variable to configure your test environment to use more verbose logging or more detailed tracing\.
30+
Use environment variables to pass environment\-specific settings to your code\. For example, you can have two functions with the same code but different configuration\. One function connects to a test database, and the other connects to a production database\. In this situation, you use environment variables to tell the function the hostname and other connection details for the database\.
31+
32+
The following example shows how to define the database host and database name as environment variables\.
3133

3234
![\[\]](http://docs.aws.amazon.com/lambda/latest/dg/images/console-env.png)
3335

36+
If you want your test environment to generate more debug information than the production environment, you could set an environment variable to configure your test environment to use more verbose logging or more detailed tracing\.
37+
38+
**Note**
39+
Environment variables are not evaluated prior to the function invocation\. Any value you define is considered a literal string and not expanded\. Perform the variable evaluation in the function code\.
40+
3441
To retrieve environment variables in your function code, use the standard method for your programming language\.
3542

3643
------
@@ -99,6 +106,7 @@ Lambda [runtimes](lambda-runtimes.md) set several environment variables during i
99106

100107
**Reserved environment variables**
101108
+ `_HANDLER` – The handler location configured on the function\.
109+
+ `_X_AMZN_TRACE_ID` – The [X\-Ray tracing header](services-xray.md)\.
102110
+ `AWS_REGION` – The AWS Region where the Lambda function is executed\.
103111
+ `AWS_EXECUTION_ENV` – The [runtime identifier](lambda-runtimes.md), prefixed by `AWS_Lambda_`—for example, `AWS_Lambda_java8`\.
104112
+ `AWS_LAMBDA_FUNCTION_NAME` – The name of the function\.
@@ -120,7 +128,6 @@ The following additional environment variables aren't reserved and can be extend
120128
+ `NODE_PATH`\([Node\.js](lambda-nodejs.md)\) The Node\.js library path \(`/opt/nodejs/node12/node_modules/:/opt/nodejs/node_modules:$LAMBDA_RUNTIME_DIR/node_modules`\)\.
121129
+ `PYTHONPATH`\([Python 2\.7, 3\.6, 3\.8](lambda-python.md)\) The Python library path \(`$LAMBDA_RUNTIME_DIR`\)\.
122130
+ `GEM_PATH`\([Ruby](lambda-ruby.md)\) The Ruby library path \(`$LAMBDA_TASK_ROOT/vendor/bundle/ruby/2.5.0:/opt/ruby/gems/2.5.0`\)\.
123-
+ `_X_AMZN_TRACE_ID` – The [X\-Ray tracing header](services-xray.md)\.
124131
+ `AWS_XRAY_CONTEXT_MISSING` – For X\-Ray tracing, Lambda sets this to `LOG_ERROR` to avoid throwing runtime errors from the X\-Ray SDK\.
125132
+ `AWS_XRAY_DAEMON_ADDRESS` – For X\-Ray tracing, the IP address and port of the X\-Ray daemon\.
126133

doc_source/configuration-filesystem.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ Resources:
162162
FileSystemConfigs:
163163
-
164164
Arn: !Sub
165-
- "arn:aws:elasticfilesystem:eu-central-1:123456789101:access-point/${ap}"
166-
- {ap: !Ref AccessPoint}
165+
- "arn:aws:elasticfilesystem:eu-central-1:123456789101:access-point/fsap-015cxmplb72b405fd"
167166
LocalMountPath: "/mnt/efs0"
168167
DependsOn: "MountTarget1"
169168
```

doc_source/configuration-vpc.md

+46-22
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
You can configure a Lambda function to connect to private subnets in a virtual private cloud \(VPC\) in your AWS account\. Use Amazon Virtual Private Cloud \(Amazon VPC\) to create a private network for resources such as databases, cache instances, or internal services\. Connect your function to the VPC to access private resources during execution\.
44

5-
**To connect a function to a VPC**
6-
7-
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
8-
9-
1. Choose a function\.
10-
11-
1. Under **VPC**, choose **Edit**\.
12-
13-
1. For **VPC connection**, choose **Custom VPC**\.
14-
15-
1. Choose a VPC, subnets, and security groups\.
16-
**Note**
17-
Connect your function to private subnets to access private resources\. If your function needs internet access, use [network address translation \(NAT\)](#vpc-internet)\. Connecting a function to a public subnet doesn't give it internet access or a public IP address\.
18-
19-
1. Choose **Save**\.
20-
215
When you connect a function to a VPC, Lambda creates an [elastic network interface](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_ElasticNetworkInterfaces.html) for each combination of security group and subnet in your function's VPC configuration\. This process can take about a minute\.
226

237
While Lambda creates a network interface, you can't perform additional operations that target the function, such as [creating versions](configuration-versions.md) or updating the function's code\. For new functions, you can't invoke the function until its state changes from `Pending` to `Active`\. For existing functions, you can still invoke an earlier version while the update is in progress\. For more information about function states, see [Monitoring the state of a function with the Lambda API](functions-states.md)\.
@@ -28,15 +12,13 @@ If your functions aren't active for a long period of time, Lambda reclaims its n
2812

2913
Lambda functions can't connect directly to a VPC with [ dedicated instance tenancy](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-instance.html)\. To connect to resources in a dedicated VPC, [peer it to a second VPC with default tenancy](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-dedicated-vpc/)\.
3014

31-
**VPC tutorials**
32-
+ [Tutorial: Configuring a Lambda function to access Amazon RDS in an Amazon VPC](services-rds-tutorial.md)
33-
+ [Tutorial: Configuring a Lambda function to access Amazon ElastiCache in an Amazon VPC](services-elasticache-tutorial.md)
34-
3515
**Topics**
3616
+ [Execution role and user permissions](#vpc-permissions)
37-
+ [Configuring VPC access with the Lambda API](#vpc-configuring)
17+
+ [Configuring VPC access with the Lambda console](#vpc-configuring)
18+
+ [Configuring VPC access with the Lambda API](#vpc-configuring-api)
3819
+ [Using IAM condition keys for VPC settings](#vpc-conditions)
3920
+ [Internet and service access for VPC\-connected functions](#vpc-internet)
21+
+ [VPC tutorials](#vpc-tutorials)
4022
+ [Sample VPC configurations](#vpc-samples)
4123

4224
## Execution role and user permissions<a name="vpc-permissions"></a>
@@ -57,7 +39,43 @@ When you configure VPC connectivity, Lambda uses your permissions to verify netw
5739
+ **ec2:DescribeSubnets**
5840
+ **ec2:DescribeVpcs**
5941

60-
## Configuring VPC access with the Lambda API<a name="vpc-configuring"></a>
42+
## Configuring VPC access with the Lambda console<a name="vpc-configuring"></a>
43+
44+
If your [IAM permissions](#vpc-conditions) allow you only to create Lambda functions that connect to your VPC, you must configure the VPC when you create the function\. If your IAM permissions allow you to create functions that aren't connected to your VPC, you can add the VPC configuration after you create the function\.
45+
46+
**To configure a VPC when you create a function**
47+
48+
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
49+
50+
1. Choose **Create function**\.
51+
52+
1. Under **Basic information**, for **Function name**, enter a name for your function\.
53+
54+
1. Expand **Advanced settings**\.
55+
56+
1. Under **Network**, choose a **VPC** for your function to access\.
57+
58+
1. Choose subnets and security groups\. When you choose a security group, the console displays the inbound and outbound rules for that security group\.
59+
**Note**
60+
To access private resources, connect your function to private subnets\. If your function needs internet access, use [network address translation \(NAT\)](#vpc-internet)\. Connecting a function to a public subnet doesn't give it internet access or a public IP address\.
61+
62+
1. Choose **Create function**\.
63+
64+
**To configure a VPC for an existing function**
65+
66+
1. Open the Lambda console [Functions page](https://console.aws.amazon.com/lambda/home#/functions)\.
67+
68+
1. Choose a function\.
69+
70+
1. Under **VPC**, choose **Edit**\.
71+
72+
1. Choose a VPC, subnets, and security groups\.
73+
**Note**
74+
To access private resources, connect your function to private subnets\. If your function needs internet access, use [network address translation \(NAT\)](#vpc-internet)\. Connecting a function to a public subnet doesn't give it internet access or a public IP address\.
75+
76+
1. Choose **Save**\.
77+
78+
## Configuring VPC access with the Lambda API<a name="vpc-configuring-api"></a>
6179

6280
To connect a Lambda function to a VPC, you can use the following API operations:
6381
+ [CreateFunction](API_CreateFunction.md)
@@ -269,6 +287,12 @@ Several AWS services offer [VPC endpoints](https://docs.aws.amazon.com/vpc/lates
269287

270288
Internet access from a private subnet requires network address translation \(NAT\)\. To give your function access to the internet, route outbound traffic to a [NAT gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html) in a public subnet\. The NAT gateway has a public IP address and can connect to the internet through the VPC's internet gateway\. For more information, see [How do I give internet access to my Lambda function in a VPC?](https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/)
271289

290+
## VPC tutorials<a name="vpc-tutorials"></a>
291+
292+
In the following tutorials, you connect a Lambda function to resources in your VPC\.
293+
+ [Tutorial: Configuring a Lambda function to access Amazon RDS in an Amazon VPC](services-rds-tutorial.md)
294+
+ [Tutorial: Configuring a Lambda function to access Amazon ElastiCache in an Amazon VPC](services-elasticache-tutorial.md)
295+
272296
## Sample VPC configurations<a name="vpc-samples"></a>
273297

274298
You can use the following sample AWS CloudFormation templates to create VPC configurations to use with Lambda functions\. There are two templates available in this guide's GitHub repository:

0 commit comments

Comments
 (0)