-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add nodejs22.x support * use nodejs22 public ecr image * Update package.json to use nodejs22
- Loading branch information
Showing
12 changed files
with
379 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
ARG IMAGE_ARCH | ||
FROM public.ecr.aws/lambda/nodejs:22-$IMAGE_ARCH | ||
|
||
ENV PATH=/var/lang/bin:$PATH \ | ||
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \ | ||
AWS_EXECUTION_ENV=AWS_Lambda_nodejs22.x \ | ||
NODE_PATH=/opt/nodejs/node22/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules | ||
|
||
RUN dnf remove -y microdnf-dnf && \ | ||
microdnf install -y dnf | ||
|
||
RUN dnf groupinstall -y development && \ | ||
dnf install -y \ | ||
tar \ | ||
gzip \ | ||
unzip \ | ||
python3 \ | ||
jq \ | ||
grep \ | ||
make \ | ||
rsync \ | ||
binutils \ | ||
gcc-c++ \ | ||
procps \ | ||
gmp-devel \ | ||
zlib-devel \ | ||
libmpc-devel \ | ||
python3-devel \ | ||
&& dnf clean all | ||
|
||
# Install AWS CLI | ||
ARG AWS_CLI_ARCH | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$AWS_CLI_ARCH.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install && rm awscliv2.zip && rm -rf ./aws | ||
|
||
# Install SAM CLI from native installer | ||
ARG SAM_CLI_VERSION | ||
# need to redefine since ARG is not available after FROM tag: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact | ||
ARG IMAGE_ARCH | ||
RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v$SAM_CLI_VERSION/aws-sam-cli-linux-$IMAGE_ARCH.zip" -o "samcli.zip" && \ | ||
unzip samcli.zip -d sam-installation && ./sam-installation/install && \ | ||
rm samcli.zip && rm -rf sam-installation && sam --version | ||
|
||
# Prepare virtualenv for lambda builders | ||
RUN python3 -m venv --without-pip /usr/local/opt/lambda-builders | ||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | ||
RUN LD_LIBRARY_PATH= /usr/local/opt/lambda-builders/bin/python3 get-pip.py | ||
# Install lambda builders in a dedicated Python virtualenv | ||
# Nodejs22 uses a different version (3.1.3) of OpenSSL. This caused an error when Python (installed via dnf) tries to use the ssl module. | ||
# Temporarily set LD_LIBRARY_PATH to empty for python and pip to pick up the right OpenSSL version | ||
RUN AWS_LB_VERSION=$(curl -sSL https://raw.githubusercontent.com/aws/aws-sam-cli/v$SAM_CLI_VERSION/requirements/base.txt | grep aws_lambda_builders | cut -d= -f3) && \ | ||
LD_LIBRARY_PATH= /usr/local/opt/lambda-builders/bin/pip3 --no-cache-dir install "aws-lambda-builders==$AWS_LB_VERSION" | ||
|
||
ENV PATH=$PATH:/usr/local/opt/lambda-builders/bin | ||
|
||
ENV LANG=en_US.UTF-8 | ||
|
||
# Wheel is required by SAM CLI to build libraries like cryptography. It needs to be installed in the system | ||
# Python for it to be picked up during `sam build` | ||
RUN LD_LIBRARY_PATH= pip3 install wheel | ||
|
||
COPY ATTRIBUTION.txt / | ||
|
||
# Compatible with initial base image | ||
ENTRYPOINT [] | ||
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ markers = | |
nodejs16x | ||
nodejs18x | ||
nodejs20x | ||
nodejs22x | ||
provided_al2 | ||
provided_al2023 | ||
python38 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
|
||
# Created by https://www.gitignore.io/api/osx,node,linux,windows | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
|
||
### OSX ### | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
|
||
# End of https://www.gitignore.io/api/osx,node,linux,windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"body": "{\"message\": \"hello world\"}", | ||
"resource": "/{proxy+}", | ||
"path": "/path/to/resource", | ||
"httpMethod": "POST", | ||
"isBase64Encoded": false, | ||
"queryStringParameters": { | ||
"foo": "bar" | ||
}, | ||
"pathParameters": { | ||
"proxy": "/path/to/resource" | ||
}, | ||
"stageVariables": { | ||
"baz": "qux" | ||
}, | ||
"headers": { | ||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | ||
"Accept-Encoding": "gzip, deflate, sdch", | ||
"Accept-Language": "en-US,en;q=0.8", | ||
"Cache-Control": "max-age=0", | ||
"CloudFront-Forwarded-Proto": "https", | ||
"CloudFront-Is-Desktop-Viewer": "true", | ||
"CloudFront-Is-Mobile-Viewer": "false", | ||
"CloudFront-Is-SmartTV-Viewer": "false", | ||
"CloudFront-Is-Tablet-Viewer": "false", | ||
"CloudFront-Viewer-Country": "US", | ||
"Host": "1234567890.execute-api.us-east-1.amazonaws.com", | ||
"Upgrade-Insecure-Requests": "1", | ||
"User-Agent": "Custom User Agent String", | ||
"Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", | ||
"X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", | ||
"X-Forwarded-For": "127.0.0.1, 127.0.0.2", | ||
"X-Forwarded-Port": "443", | ||
"X-Forwarded-Proto": "https" | ||
}, | ||
"requestContext": { | ||
"accountId": "123456789012", | ||
"resourceId": "123456", | ||
"stage": "prod", | ||
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", | ||
"requestTime": "09/Apr/2015:12:34:56 +0000", | ||
"requestTimeEpoch": 1428582896000, | ||
"identity": { | ||
"cognitoIdentityPoolId": null, | ||
"accountId": null, | ||
"cognitoIdentityId": null, | ||
"caller": null, | ||
"accessKey": null, | ||
"sourceIp": "127.0.0.1", | ||
"cognitoAuthenticationType": null, | ||
"cognitoAuthenticationProvider": null, | ||
"userArn": null, | ||
"userAgent": "Custom User Agent String", | ||
"user": null | ||
}, | ||
"path": "/prod/path/to/resource", | ||
"resourcePath": "/{proxy+}", | ||
"httpMethod": "POST", | ||
"apiId": "1234567890", | ||
"protocol": "HTTP/1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* | ||
* Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format | ||
* @param {Object} event - API Gateway Lambda Proxy Input Format | ||
* | ||
* Context doc: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html | ||
* @param {Object} context | ||
* | ||
* Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html | ||
* @returns {Object} object - API Gateway Lambda Proxy Output Format | ||
* | ||
*/ | ||
|
||
export const lambdaHandler = async (event, context) => { | ||
try { | ||
return { | ||
'statusCode': 200, | ||
'body': JSON.stringify({ | ||
message: 'hello world', | ||
}) | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
return err; | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
tests/apps/nodejs22.x/sam-test-app/hello-world/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "hello_world", | ||
"version": "1.0.0", | ||
"description": "Hello world sample for NodeJS22", | ||
"main": "app.mjs", | ||
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs", | ||
"author": "SAM CLI", | ||
"license": "MIT", | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
}, | ||
"scripts": { | ||
"test": "mocha tests/unit/" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.3.8", | ||
"mocha": "^10.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: > | ||
sam-test-app12 | ||
Sample SAM Template for sam-test-app12 | ||
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst | ||
Globals: | ||
Function: | ||
Timeout: 3 | ||
|
||
Resources: | ||
HelloWorldFunction: | ||
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction | ||
Properties: | ||
CodeUri: hello-world/ | ||
Handler: app.lambdaHandler | ||
Runtime: nodejs22.x | ||
Events: | ||
HelloWorld: | ||
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | ||
Properties: | ||
Path: /hello | ||
Method: get | ||
|
||
Outputs: | ||
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function | ||
# Find out more about other implicit resources you can reference within SAM | ||
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api | ||
HelloWorldApi: | ||
Description: "API Gateway endpoint URL for Prod stage for Hello World function" | ||
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" | ||
HelloWorldFunction: | ||
Description: "Hello World Lambda Function ARN" | ||
Value: !GetAtt HelloWorldFunction.Arn | ||
HelloWorldFunctionIamRole: | ||
Description: "Implicit IAM Role created for Hello World function" | ||
Value: !GetAtt HelloWorldFunctionRole.Arn |
Oops, something went wrong.