Skip to content

Commit 53966ff

Browse files
committed
Upgrade to Node.js v16
1 parent 8bc9453 commit 53966ff

8 files changed

Lines changed: 50 additions & 36 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM node:15.14.0-buster-slim
1+
FROM node:16.0.0-buster-slim
22

33
RUN apt-get update && apt-get install -y p7zip-full curl xz-utils gnupg && apt-get clean all

README.md

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# AWS Lambda NodeJS-15 Runtime
1+
# AWS Lambda NodeJS-16 Runtime
22

33
AWS Lambda runtime API implemented in Node.js. The supported version is usually the latest LTS.
44

55
It's easy to use this project and build Node.js runtime that will target any version - just replace the version number in `auto/package` with your preferred one.
66

77
## Current versions
88

9-
* Node.js - **15.14.0**
10-
* aws-sdk - **2.887.0**
9+
* Node.js - **16.0.0**
10+
* aws-sdk - **2.889.0**
1111

1212
## Goals
1313

14-
* Provide always up-to-date Node.js execution environment.
14+
* Provide always up-to-date Node.js execution environment as a Lambda runtime layer and a Lambda container image.
1515
* Include the most recent `aws-cli` library.
16-
* MAke the runtime environment compatible with the default node12.x and node14.x environments
16+
* Make the runtime environment compatible with the default node12.x and node14.x environments
1717

1818
## How to install?
1919

@@ -39,8 +39,8 @@ Deploy the runtime layer using the following command:
3939

4040
```bash
4141
aws lambda publish-layer-version \
42-
--layer-name node-15-runtime \
43-
--description "nodejs-15.14.0 aws-cli-2.887.0" \
42+
--layer-name node-16-runtime \
43+
--description "nodejs-16.0.0 aws-cli-2.889.0" \
4444
--compatible-runtimes provided \
4545
--license-info Apache-2.0 \
4646
--zip-file fileb://stage/layer.zip
@@ -49,14 +49,14 @@ aws lambda publish-layer-version \
4949
The output will look like this:
5050
```json
5151
{
52-
"LayerVersionArn": "arn:aws:lambda:us-east-2:356111732087:layer:node-15-runtime:1",
53-
"Description": "nodejs-15.14.0 aws-cli-2.887.0",
52+
"LayerVersionArn": "arn:aws:lambda:us-east-2:356111732087:layer:node-16-runtime:1",
53+
"Description": "nodejs-16.0.0 aws-cli-2.889.0",
5454
"CreatedDate": "2018-12-02T22:32:00.572+0000",
55-
"LayerArn": "arn:aws:lambda:us-east-2:356111732087:layer:node-15-runtime",
55+
"LayerArn": "arn:aws:lambda:us-east-2:356111732087:layer:node-16-runtime",
5656
"Content": {
5757
"CodeSize": 18104889,
5858
"CodeSha256": "VonrpX23FWJOmE4lvhpox+9PS9kuY4sng0o0wxNTROs=",
59-
"Location": "https://awslambda-us-east-2-layers.s3.us-east-2.amazonaws.com/snapshots/356111732087/node-15-runtime-f3415c38-d865-46b6-ae42-009985092116?......"
59+
"Location": "https://awslambda-us-east-2-layers.s3.us-east-2.amazonaws.com/snapshots/356111732087/node-16-runtime-f3415c38-d865-46b6-ae42-009985092116?......"
6060
},
6161
"Version": 1,
6262
"CompatibleRuntimes": [
@@ -72,7 +72,7 @@ You can share the layer with other AWS accounts by executing the following comma
7272

7373
```bash
7474
aws lambda add-layer-version-permission \
75-
--layer-name node-15-runtime \
75+
--layer-name node-16-runtime \
7676
--version-number 1 \
7777
--principal "*" \
7878
--statement-id publish \
@@ -84,7 +84,7 @@ Response:
8484
```json
8585
{
8686
"RevisionId": "8b5b2e27-5013-4983-ac1a-9008dff90bac",
87-
"Statement": "{\"Sid\":\"publish\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"lambda:GetLayerVersion\",\"Resource\":\"arn:aws:lambda:us-east-2:356111732087:layer:node-15-runtime:1\"}"
87+
"Statement": "{\"Sid\":\"publish\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"lambda:GetLayerVersion\",\"Resource\":\"arn:aws:lambda:us-east-2:356111732087:layer:node-16-runtime:1\"}"
8888
}
8989
```
9090

@@ -103,11 +103,11 @@ Let's assume that your lambda function is packaged as `lambda.zip` file and the
103103
```bash
104104
aws lambda create-function \
105105
--region us-east-2 \
106-
--function-name node-15-runtime-example \
106+
--function-name node-16-runtime-example \
107107
--zip-file fileb://lambda.zip \
108108
--handler hello.handler \
109109
--runtime provided \
110-
--layers "arn:aws:lambda:us-east-2:356111732087:layer:node-15-runtime:2" \
110+
--layers "arn:aws:lambda:us-east-2:356111732087:layer:node-16-runtime:2" \
111111
--role arn:aws:iam::356111732087:role/lambda-role
112112
out.txt
113113
```
@@ -119,10 +119,10 @@ Let's assume that your lambda function is packaged as `lambda.zip` file and the
119119
"Layers": [
120120
{
121121
"CodeSize": 18104889,
122-
"Arn": "arn:aws:lambda:us-east-2:356111732087:layer:node-15-runtime:1"
122+
"Arn": "arn:aws:lambda:us-east-2:356111732087:layer:node-16-runtime:1"
123123
}
124124
],
125-
"FunctionName": "node-15-runtime-example",
125+
"FunctionName": "node-16-runtime-example",
126126
"LastModified": "2018-12-02T22:59:10.408+0000",
127127
"RevisionId": "32e7e8a1-b5ba-4388-b6be-596278e36126",
128128
"MemorySize": 128,
@@ -136,7 +136,7 @@ Let's assume that your lambda function is packaged as `lambda.zip` file and the
136136
"CodeSha256": "shSeSmJZHv8Z0WmOAcFcHeSUGbRYRR1cFdbEudkSJHo=",
137137
"Description": "",
138138
"CodeSize": 340,
139-
"FunctionArn": "arn:aws:lambda:us-east-2:356111732087:function:node-15-runtime-example",
139+
"FunctionArn": "arn:aws:lambda:us-east-2:356111732087:function:node-16-runtime-example",
140140
"Handler": "hello.handler"
141141
}
142142
```
@@ -146,7 +146,7 @@ Let's assume that your lambda function is packaged as `lambda.zip` file and the
146146
```bash
147147
aws lambda invoke \
148148
--region us-east-2 \
149-
--function-name node-15-runtime-example \
149+
--function-name node-16-runtime-example \
150150
--payload '{"hello":"world"}' \
151151
output.txt
152152
@@ -170,10 +170,7 @@ The context object is compatible with [the default node environments](https://do
170170
* `awsRequestId` – The identifier of the invocation request.
171171
* `logGroupName` – The log group for the function.
172172
* `logStreamName` – The log stream for the function instance.
173-
* `callbackWaitsForEmptyEventLoop` – Set to false to send the response right away when the callback executes, instead of waiting for the Node.js event loop to be empty. If false, any outstanding events will continue to run during the next invocation.
174-
175-
### Not yet supported properties
176-
173+
* `callbackWaitsForEmptyEventLoop` – Set to false to send the response right away when the callback executes, instead of waiting for the Node.js event loop to be empty.
177174
* `identity` - Information about the Amazon Cognito identity that authorized the request.
178175
* `clientContext` - Client context provided to the Lambda invoker by the client application.
179176
@@ -201,3 +198,22 @@ AWS_LAMBDA_LOG_GROUP_NAME AWS_LAMBDA_LOG_STREAM_NAME|Yes|The name of the Amazon
201198
|LD_LIBRARY_PATH|No|/lib64:/usr/lib64:$LAMBDA_RUNTIME_DIR:$LAMBDA_RUNTIME_DIR/lib:$LAMBDA_TASK_ROOT:$LAMBDA_TASK_ROOT/lib:/opt/lib|
202199
|NODE_PATH|No|/opt/node_modules|
203200
|AWS_LAMBDA_RUNTIME_API|Yes|(custom runtime) The host and port of the [runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html).|
201+
202+
## The base container image
203+
204+
The releases include a base Docker image that is compatible with the Lambda Container runtime and it's compatible with the Node.js Lambda runtime.
205+
206+
### Using the base image
207+
208+
The example below assumes that the Dockerfile is in the root folder of the Lambda project and there's an `index.js` file that exports the handler function called `handler`.
209+
210+
```Dockerfile
211+
FROM janaz/aws-lambda-node-runtime:test-1
212+
213+
COPY . ${LAMBDA_TASK_ROOT}
214+
RUN npm install
215+
216+
CMD ["index.handler"]
217+
```
218+
219+
The image created from that `Dockerfile` should be uploaded to your ECR registry and referenced in the Lambda configuration.

auto/package

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
export NODE_VERSION=15.14.0
5+
export NODE_VERSION=16.0.0
66

77
DIR="$( cd "$( dirname "$0" )" && pwd )"
88

auto/publish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ us-west-2
3232
"
3333

3434
TMP="deployment-$(date +%s).txt"
35-
LAYER_NAME=node-15-runtime
35+
LAYER_NAME=node-16-runtime
3636
for R in $REGIONS ; do
3737
echo "Deploying in ${R}"
3838
docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY --rm \
@@ -42,7 +42,7 @@ for R in $REGIONS ; do
4242
lambda publish-layer-version \
4343
--region "${R}" \
4444
--layer-name "${LAYER_NAME}" \
45-
--description "nodejs-15.14.0 aws-cli-2.887.0" \
45+
--description "nodejs-16.0.0 aws-cli-2.889.0" \
4646
--compatible-runtimes provided \
4747
--license-info Apache-2.0 \
4848
--zip-file fileb://stage/layer.zip

container/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
ARG NODE_VERSION=15.14.0
3-
ARG AWS_SDK_VERSION=2.887.0
2+
ARG NODE_VERSION=16.0.0
3+
ARG AWS_SDK_VERSION=2.889.0
44
ARG AWS_LAMBDA_NODE_RUNTIME_VERSION=0.1.0
55

66
FROM node:${NODE_VERSION}-buster-slim
@@ -17,7 +17,5 @@ RUN mkdir ${BOOTSTRAP_DIR} && \
1717
npm install --no-save -g aws-lambda-node-runtime@${AWS_LAMBDA_NODE_RUNTIME_VERSION}
1818

1919
WORKDIR ${LAMBDA_TASK_ROOT}
20-
# COPY hello.js ${LAMBDA_TASK_ROOT}/
2120

2221
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-node-runtime"]
23-
# CMD ["hello.handler"]

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
- runtime-api
4343

4444
runtime-api:
45-
image: node:15.14.0-buster-slim
45+
image: node:16.0.0-buster-slim
4646
environment:
4747
NPM_CONFIG_CACHE: /tmp/npm-cache
4848
volumes:

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"dependencies": {
1515
"aws-lambda-node-runtime": "0.1.0",
16-
"aws-sdk": "^2.887.0"
16+
"aws-sdk": "^2.889.0"
1717
}
1818
}

0 commit comments

Comments
 (0)