diff --git a/Cargo.lock b/Cargo.lock index 28f05de5..cd85e76e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1160,7 +1160,7 @@ dependencies = [ [[package]] name = "lambda_web_adapter" -version = "0.7.1" +version = "0.7.2" dependencies = [ "aws-sigv4", "flate2", diff --git a/README.md b/README.md index cfd649eb..df13f014 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ AWS Lambda Web Adapter work with Lambda functions packaged as both docker images ### Lambda functions packaged as Docker Images or OCI Images To use Lambda Web Adapter with docker images, package your web app (http api) in a Dockerfile, and add one line to copy Lambda Web Adapter binary to /opt/extensions inside your container. -By default, Lambda Web Adapter assumes the web app is listening on port 8080. If not, you can specify the port via [configuration](#Configurations). +By default, Lambda Web Adapter assumes the web app is listening on port 8080. If not, you can specify the port via [configuration](#configurations). ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` Pre-compiled Lambda Web Adapter binaries are provided in ECR public repo: [public.ecr.aws/awsguru/aws-lambda-adapter](https://gallery.ecr.aws/awsguru/aws-lambda-adapter). @@ -37,8 +37,8 @@ Multi-arch images are also provided in this repo. It works on both x86_64 and ar Below is a Dockerfile for [an example nodejs application](examples/expressjs). ```dockerfile -FROM public.ecr.aws/docker/library/node:16.13.2-stretch-slim -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +FROM public.ecr.aws/docker/library/node:20-slim +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ENV PORT=7000 WORKDIR "/var/task" ADD src/package.json /var/task/package.json @@ -56,14 +56,17 @@ AWS Lambda Web Adapter also works with AWS managed Lambda runtimes. You need to 1. attach Lambda Web Adapter layer to your function. #### AWS Commercial Regions - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17` + + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18` + #### AWS China Regions - 1. cn-north-1 (Beijing) - - x86_64: `arn:aws-cn:lambda:cn-north-1:041581134020:layer:LambdaAdapterLayerX86:17` - 2. cn-northwest-1 (Ningxia) - - x86_64: `arn:aws-cn:lambda:cn-northwest-1:069767869989:layer:LambdaAdapterLayerX86:17` - + + 1. cn-north-1 (Beijing) + - x86_64: `arn:aws-cn:lambda:cn-north-1:041581134020:layer:LambdaAdapterLayerX86:18` + 2. cn-northwest-1 (Ningxia) + - x86_64: `arn:aws-cn:lambda:cn-northwest-1:069767869989:layer:LambdaAdapterLayerX86:18` + 2. configure Lambda environment variable `AWS_LAMBDA_EXEC_WRAPPER` to `/opt/bootstrap`. 3. set function handler to your web application start up script. e.g. `run.sh`. @@ -71,15 +74,15 @@ For details, please check out [the example Node.js application](examples/express ## Readiness Check -When a new Lambda Execution Environment starts up, Lambda Web Adapter will boot up as a Lambda Extension, followed by the web application. +When a new Lambda Execution Environment starts up, Lambda Web Adapter will boot up as a Lambda Extension, followed by the web application. By default, Lambda Web Adapter will send HTTP GET requests to the web application at `http://127.0.0.1:8080/`. The port and path can be customized with two environment variables: `AWS_LWA_READINESS_CHECK_PORT` and `AWS_LWA_READINESS_CHECK_PATH`. -Lambda Web Adapter will retry this request every 10 milliseconds until the web application returns an HTTP response (**status code >= 100 and < 500**) or the function times out. +Lambda Web Adapter will retry this request every 10 milliseconds until the web application returns an HTTP response (**status code >= 100 and < 500**) or the function times out. -In addition, you can configure the adapter to preform readiness check with TCP connect, by setting `AWS_LWA_READINESS_CHECK_PROTOCOL` to `tcp`. +In addition, you can configure the adapter to preform readiness check with TCP connect, by setting `AWS_LWA_READINESS_CHECK_PROTOCOL` to `tcp`. -After passing readiness check, Lambda Web Adapter will start Lambda Runtime and forward the invokes to the web application. +After passing readiness check, Lambda Web Adapter will start Lambda Runtime and forward the invokes to the web application. ## Configurations @@ -98,18 +101,18 @@ The readiness check port/path and traffic port can be configured using environme | AWS_LWA_INVOKE_MODE | Lambda function invoke mode: "buffered" or "response_stream", default is "buffered" | "buffered" | > **Note:** -> We use "AWS_LWA_" prefix to namespacing all environment variables used by Lambda Web Adapter. The original ones will be supported until we reach version 1.0. +> We use "AWS_LWA_" prefix to namespacing all environment variables used by Lambda Web Adapter. The original ones will be supported until we reach version 1.0. -**AWS_LWA_PORT / PORT** - Lambda Web Adapter will send traffic to this port. This is the port your web application listening on. Inside Lambda execution environment, -the web application runs as a non-root user, and not allowed to listen on ports lower than 1024. Please also avoid port 9001 and 3000. +**AWS_LWA_PORT / PORT** - Lambda Web Adapter will send traffic to this port. This is the port your web application listening on. Inside Lambda execution environment, +the web application runs as a non-root user, and not allowed to listen on ports lower than 1024. Please also avoid port 9001 and 3000. Lambda Runtime API is on port 9001. CloudWatch Lambda Insight extension uses port 3000. -**AWS_LWA_ASYNC_INIT / ASYNC_INIT** - Lambda managed runtimes offer up to 10 seconds for function initialization. During this period of time, Lambda functions have burst of CPU to accelerate initialization, and it is free. -If a lambda function couldn't complete the initialization within 10 seconds, Lambda will restart the function, and bill for the initialization. -To help functions to use this 10 seconds free initialization time and avoid the restart, Lambda Web Adapter supports asynchronous initialization. -When this feature is enabled, Lambda Web Adapter performs readiness check up to 9.8 seconds. If the web app is not ready by then, -Lambda Web Adapter signals to Lambda service that the init is completed, and continues readiness check in the handler. -This feature is disabled by default. Enable it by setting environment variable `AWS_LWA_ASYNC_INIT` to `true`. +**AWS_LWA_ASYNC_INIT / ASYNC_INIT** - Lambda managed runtimes offer up to 10 seconds for function initialization. During this period of time, Lambda functions have burst of CPU to accelerate initialization, and it is free. +If a lambda function couldn't complete the initialization within 10 seconds, Lambda will restart the function, and bill for the initialization. +To help functions to use this 10 seconds free initialization time and avoid the restart, Lambda Web Adapter supports asynchronous initialization. +When this feature is enabled, Lambda Web Adapter performs readiness check up to 9.8 seconds. If the web app is not ready by then, +Lambda Web Adapter signals to Lambda service that the init is completed, and continues readiness check in the handler. +This feature is disabled by default. Enable it by setting environment variable `AWS_LWA_ASYNC_INIT` to `true`. **AWS_LWA_REMOVE_BASE_PATH / REMOVE_BASE_PATH** - The value of this environment variable tells the adapter whether the application is running under a base path. For example, you could have configured your API Gateway to have a /orders/{proxy+} and a /catalog/{proxy+} resource. @@ -119,8 +122,8 @@ Use REMOVE_BASE_PATH to remove the /orders prefix when routing requests to the a **AWS_LWA_ENABLE_COMPRESSION** - Lambda Web Adapter supports gzip compression for response body. This feature is disabled by default. Enable it by setting environment variable `AWS_LWA_ENABLE_COMPRESSION` to `true`. When enabled, this will compress responses unless it's an image as determined by the content-type starting with `image` or the response is less than 32 bytes. This will also compress HTTP/1.1 chunked streaming response. -**AWS_LWA_INVOKE_MODE** - Lambda function invoke mode, this should match Function Url invoke mode. The default is "buffered". When configured as "response_stream", Lambda Web Adapter will stream response to Lambda service [blog](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/). -Please check out [FastAPI with Response Streaming](examples/fastapi-response-streaming) example. +**AWS_LWA_INVOKE_MODE** - Lambda function invoke mode, this should match Function Url invoke mode. The default is "buffered". When configured as "response_stream", Lambda Web Adapter will stream response to Lambda service [blog](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/). +Please check out [FastAPI with Response Streaming](examples/fastapi-response-streaming) example. **AWS_LWA_READINESS_CHECK_MIN_UNHEALTHY_STATUS** - allows you to customize which HTTP status codes are considered healthy and which ones are not @@ -130,7 +133,6 @@ Please check out [FastAPI with Response Streaming](examples/fastapi-response-str Lambda Web Adapter forwards this information to the web application in a Http Header named "x-amzn-request-context". In the web application, you can retrieve the value of this http header and deserialize it into a JSON object. Check out [Express.js in Zip](examples/expressjs-zip) on how to use it. - ## Lambda Context **Lambda Context** is an object that Lambda passes to the function handler. This object provides information about the invocation, function, and execution environment. You can find a full list of properties accessible through the Lambda Context [here](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html) @@ -139,9 +141,9 @@ Lambda Web Adapter forwards this information to the web application in a Http He ## Graceful Shutdown -For a function with Lambda Extensions registered, Lambda enables shutdown phase for the function. When Lambda service is about to shut down a Lambda execution environment, +For a function with Lambda Extensions registered, Lambda enables shutdown phase for the function. When Lambda service is about to shut down a Lambda execution environment, it sends a SIGTERM signal to the runtime and then a SHUTDOWN event to each registered external extensions. Developers could catch the SIGTERM signal in the lambda functions and perform graceful shutdown tasks. -The [Express.js](examples/expressjs/app/src/index.js) gives a simple example. More details in [this repo](https://github.com/aws-samples/graceful-shutdown-with-aws-lambda). +The [Express.js](examples/expressjs/app/src/index.js) gives a simple example. More details in [this repo](https://github.com/aws-samples/graceful-shutdown-with-aws-lambda). ## Local Debugging @@ -151,14 +153,14 @@ Lambda Web Adapter allows developers to develop web applications locally with fa sam local start-api ``` -Please note that `sam local` starts a Lambda Runtime Interface Emulator on port 8080. So your web application should avoid port `8080` if you plan to use `sam local`. +Please note that `sam local` starts a Lambda Runtime Interface Emulator on port 8080. So your web application should avoid port `8080` if you plan to use `sam local`. ## Examples - [FastAPI](examples/fastapi) +- [FastAPI in Zip](examples/fastapi-zip) - [FastAPI with Response Streaming](examples/fastapi-response-streaming) - [FastAPI with Response Streaming in Zip](examples/fastapi-response-streaming-zip) -- [FastAPI in Zip](examples/fastapi-zip) - [Flask](examples/flask) - [Flask in Zip](examples/flask-zip) - [Serverless Django](https://github.com/aws-hebrew-book/serverless-django) by [@efi-mk](https://github.com/efi-mk) @@ -191,13 +193,13 @@ This project was inspired by several community projects. ## Similar Projects -Several projects also provide similar capabilities as language specific packages/frameworks. +Several projects also provide similar capabilities as language specific packages/frameworks. - [Serverless Java Container](https://github.com/awslabs/aws-serverless-java-container) - [Serverless Express](https://github.com/vendia/serverless-express) - [Serverless Python - Zappa](https://github.com/zappa/Zappa) -- [Serverless Rails - Lamby](https://github.com/customink/lamby) -- [Serverless PHP - Bref](https://github.com/brefphp/bref) +- [Serverless Rails - Lamby](https://github.com/customink/lamby) +- [Serverless PHP - Bref](https://github.com/brefphp/bref) ## Security diff --git a/examples/aspnet-mvc-zip/README.md b/examples/aspnet-mvc-zip/README.md index 27b36fa3..60c0c62e 100644 --- a/examples/aspnet-mvc-zip/README.md +++ b/examples/aspnet-mvc-zip/README.md @@ -17,7 +17,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: Api: Type: HttpApi diff --git a/examples/aspnet-mvc-zip/template.yaml b/examples/aspnet-mvc-zip/template.yaml index 2d57e74d..d1fd4e8b 100644 --- a/examples/aspnet-mvc-zip/template.yaml +++ b/examples/aspnet-mvc-zip/template.yaml @@ -22,7 +22,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: Api: Type: HttpApi diff --git a/examples/aspnet-mvc/README.md b/examples/aspnet-mvc/README.md index fbfd0f56..715dd2b9 100644 --- a/examples/aspnet-mvc/README.md +++ b/examples/aspnet-mvc/README.md @@ -23,7 +23,7 @@ RUN dotnet publish "AspNetLambdaWebAdapter.csproj" -c Release -o /app/publish FROM base AS final ENV ASPNETCORE_URLS=http://+:8080 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "AspNetLambdaWebAdapter.dll"] @@ -32,7 +32,7 @@ ENTRYPOINT ["dotnet", "AspNetLambdaWebAdapter.dll"] Line 12 copies lambda adapter binary into /opt/extenions. This is required to run ASP.NET application on Lambda. The `ASPNETCORE_URLS` environment variable is also set to 8080. This is required for the Lambda Web Adapter to work. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ## Pre-requisites diff --git a/examples/aspnet-mvc/src/Dockerfile b/examples/aspnet-mvc/src/Dockerfile index 5cb852ee..5bbd45a4 100644 --- a/examples/aspnet-mvc/src/Dockerfile +++ b/examples/aspnet-mvc/src/Dockerfile @@ -12,7 +12,7 @@ RUN dotnet publish "AspNetLambdaWebAdapter.csproj" -c Release -o /app/publish FROM base AS final ENV ASPNETCORE_URLS=http://+: -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "AspNetLambdaWebAdapter.dll"] \ No newline at end of file diff --git a/examples/aspnet-webapi-zip/README.md b/examples/aspnet-webapi-zip/README.md index ff587685..3cea230e 100644 --- a/examples/aspnet-webapi-zip/README.md +++ b/examples/aspnet-webapi-zip/README.md @@ -17,7 +17,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: Api: Type: HttpApi diff --git a/examples/aspnet-webapi-zip/template.yaml b/examples/aspnet-webapi-zip/template.yaml index b3ac9f4f..ff4fd275 100644 --- a/examples/aspnet-webapi-zip/template.yaml +++ b/examples/aspnet-webapi-zip/template.yaml @@ -22,7 +22,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: Api: Type: HttpApi diff --git a/examples/deno-zip/README.md b/examples/deno-zip/README.md index db977681..2c68ef4c 100644 --- a/examples/deno-zip/README.md +++ b/examples/deno-zip/README.md @@ -19,7 +19,7 @@ We use `java11` runtime to get SnapStart support with one caveat: no runtime hoo Architectures: - x86_64 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 MemorySize: 512 Environment: Variables: diff --git a/examples/deno-zip/template.yaml b/examples/deno-zip/template.yaml index c27e407d..1639bf99 100644 --- a/examples/deno-zip/template.yaml +++ b/examples/deno-zip/template.yaml @@ -24,7 +24,7 @@ Resources: Architectures: - x86_64 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 MemorySize: 512 Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object Variables: diff --git a/examples/expressjs-zip/README.md b/examples/expressjs-zip/README.md index 7ee2961e..e590e10b 100644 --- a/examples/expressjs-zip/README.md +++ b/examples/expressjs-zip/README.md @@ -7,8 +7,8 @@ This example shows how to use Lambda Adapter to run an express.js application on We add Lambda Adapter layer to the function and configure wrapper script. 1. attach Lambda Adapter layer to your function. This layer containers Lambda Adapter binary and a wrapper script. - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17` + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18` 2. configure Lambda environment variable `AWS_LAMBDA_EXEC_WRAPPER` to `/opt/bootstrap`. This is a wrapper script included in the layer. 3. set function handler to a startup command: `run.sh`. The wrapper script will execute this command to boot up your application. diff --git a/examples/expressjs-zip/template.yaml b/examples/expressjs-zip/template.yaml index a34c8b75..34525bb2 100644 --- a/examples/expressjs-zip/template.yaml +++ b/examples/expressjs-zip/template.yaml @@ -16,7 +16,7 @@ Resources: Properties: CodeUri: hello-world/ Handler: run.sh - Runtime: nodejs14.x + Runtime: nodejs18.x MemorySize: 1024 Architectures: - x86_64 @@ -25,7 +25,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: RootPath: Type: Api diff --git a/examples/expressjs/README.md b/examples/expressjs/README.md index a6256652..16dca123 100644 --- a/examples/expressjs/README.md +++ b/examples/expressjs/README.md @@ -10,7 +10,7 @@ The top level folder is a typical AWS SAM project. The `app` directory is an exp ```dockerfile FROM public.ecr.aws/docker/library/node:16.13.2-stretch-slim -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter EXPOSE 8080 WORKDIR "/var/task" ADD src/package.json /var/task/package.json @@ -23,7 +23,7 @@ CMD ["node", "index.js"] Line 2 copies lambda adapter binary into /opt/extenions. This is the only change to run the express.js application on Lambda. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ## Pre-requisites diff --git a/examples/expressjs/app/Dockerfile b/examples/expressjs/app/Dockerfile index 9c69d3fd..50a8fdb7 100644 --- a/examples/expressjs/app/Dockerfile +++ b/examples/expressjs/app/Dockerfile @@ -1,5 +1,5 @@ FROM public.ecr.aws/docker/library/node:16.13.2-stretch-slim -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter EXPOSE 8080 WORKDIR "/var/task" ADD src/package.json /var/task/package.json diff --git a/examples/fastapi-response-streaming-zip/README.md b/examples/fastapi-response-streaming-zip/README.md index da030274..10a621f6 100644 --- a/examples/fastapi-response-streaming-zip/README.md +++ b/examples/fastapi-response-streaming-zip/README.md @@ -7,8 +7,8 @@ This example shows how to use Lambda Web Adapter to run a FastAPI application wi We add Lambda Web Adapter layer to the function and configure wrapper script. 1. attach Lambda Adapter layer to your function. This layer containers Lambda Adapter binary and a wrapper script. - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17` + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18` 2. configure Lambda environment variable `AWS_LAMBDA_EXEC_WRAPPER` to `/opt/bootstrap`. This is a wrapper script included in the layer. 3. set function handler to a startup command: `run.sh`. The wrapper script will execute this command to boot up your application. @@ -30,7 +30,7 @@ This is the resource for Lambda function. The function urls's invoke mode is con AWS_LWA_INVOKE_MODE: response_stream PORT: 8000 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 FunctionUrlConfig: AuthType: NONE InvokeMode: RESPONSE_STREAM diff --git a/examples/fastapi-response-streaming-zip/template.yaml b/examples/fastapi-response-streaming-zip/template.yaml index 5f826ca3..5ba42298 100644 --- a/examples/fastapi-response-streaming-zip/template.yaml +++ b/examples/fastapi-response-streaming-zip/template.yaml @@ -14,7 +14,7 @@ Resources: Properties: CodeUri: app/ Handler: run.sh - Runtime: python3.9 + Runtime: python3.11 MemorySize: 256 Environment: Variables: @@ -22,7 +22,7 @@ Resources: AWS_LWA_INVOKE_MODE: response_stream PORT: 8000 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 FunctionUrlConfig: AuthType: NONE InvokeMode: RESPONSE_STREAM diff --git a/examples/fastapi-response-streaming/README.md b/examples/fastapi-response-streaming/README.md index 28bcd177..d9cfe3cb 100644 --- a/examples/fastapi-response-streaming/README.md +++ b/examples/fastapi-response-streaming/README.md @@ -14,7 +14,7 @@ This function is packaged as a Docker image. Here is the content of the Dockerfi ```dockerfile FROM public.ecr.aws/docker/library/python:3.12.0-slim-bullseye -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /app ADD . . @@ -26,7 +26,7 @@ CMD ["python", "main.py"] Notice that we only need to add the second line to install Lambda Web Adapter. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/ +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/ ``` In the SAM template, we use an environment variable `AWS_LWA_INVOKE_MODE: RESPONSE_STREAM` to configure Lambda Web Adapter in response streaming mode. And adding a function url with `InvokeMode: RESPONSE_STREAM`. diff --git a/examples/fastapi-response-streaming/app/Dockerfile b/examples/fastapi-response-streaming/app/Dockerfile index 9f4e9c2b..d8c14803 100644 --- a/examples/fastapi-response-streaming/app/Dockerfile +++ b/examples/fastapi-response-streaming/app/Dockerfile @@ -1,5 +1,5 @@ FROM public.ecr.aws/docker/library/python:3.12.0-slim-bullseye -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /app ADD . . diff --git a/examples/fastapi-zip/README.md b/examples/fastapi-zip/README.md index 8e192135..54105d79 100644 --- a/examples/fastapi-zip/README.md +++ b/examples/fastapi-zip/README.md @@ -7,8 +7,8 @@ This example shows how to use Lambda Web Adapter to run a FastAPI application on We add Lambda Web Adapter layer to the function and configure wrapper script. 1. attach Lambda Adapter layer to your function. This layer containers Lambda Adapter binary and a wrapper script. - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17` + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18` 2. configure Lambda environment variable `AWS_LAMBDA_EXEC_WRAPPER` to `/opt/bootstrap`. This is a wrapper script included in the layer. 3. set function handler to a startup command: `run.sh`. The wrapper script will execute this command to boot up your application. diff --git a/examples/fastapi-zip/template.yaml b/examples/fastapi-zip/template.yaml index 406379c9..d084dd1a 100644 --- a/examples/fastapi-zip/template.yaml +++ b/examples/fastapi-zip/template.yaml @@ -14,14 +14,14 @@ Resources: Properties: CodeUri: app/ Handler: run.sh - Runtime: python3.9 + Runtime: python3.11 MemorySize: 256 Environment: Variables: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap PORT: 8000 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: ApiEvent: Type: HttpApi diff --git a/examples/fastapi/README.md b/examples/fastapi/README.md index cf43cb20..60cfe359 100644 --- a/examples/fastapi/README.md +++ b/examples/fastapi/README.md @@ -10,7 +10,7 @@ The top level folder is a typical AWS SAM project. The `app` directory is a Fast ```dockerfile FROM public.ecr.aws/docker/library/python:3.8.12-slim-buster -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ENV PORT=8000 WORKDIR /var/task COPY requirements.txt ./ @@ -22,7 +22,7 @@ CMD exec uvicorn --port=$PORT main:app Line 2 copies lambda web adapter binary into /opt/extensions. This is the change to run the FastAPI application on Lambda. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ## Pre-requisites diff --git a/examples/fastapi/app/Dockerfile b/examples/fastapi/app/Dockerfile index bbb00606..f4d37d18 100644 --- a/examples/fastapi/app/Dockerfile +++ b/examples/fastapi/app/Dockerfile @@ -1,5 +1,5 @@ -FROM public.ecr.aws/docker/library/python:3.8.12-slim-buster -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +FROM public.ecr.aws/docker/library/python:3.11-slim +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ENV PORT=8000 WORKDIR /var/task COPY requirements.txt ./ diff --git a/examples/flask-zip/README.md b/examples/flask-zip/README.md index d6a164dd..a72f747d 100644 --- a/examples/flask-zip/README.md +++ b/examples/flask-zip/README.md @@ -7,8 +7,8 @@ This example shows how to use Lambda Adapter to run an Flask application on mana We add Lambda Adapter layer to the function and configure wrapper script. 1. attach Lambda Adapter layer to your function. This layer containers Lambda Adapter binary and a wrapper script. - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17` + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18` 2. configure Lambda environment variable `AWS_LAMBDA_EXEC_WRAPPER` to `/opt/bootstrap`. This is a wrapper script included in the layer. 3. set function handler to a startup command: `run.sh`. The wrapper script will execute this command to boot up your application. diff --git a/examples/flask-zip/template.yaml b/examples/flask-zip/template.yaml index 6514f36c..96fa3f18 100644 --- a/examples/flask-zip/template.yaml +++ b/examples/flask-zip/template.yaml @@ -14,14 +14,14 @@ Resources: Properties: CodeUri: app/ Handler: run.sh - Runtime: python3.10 + Runtime: python3.12 MemorySize: 256 Environment: Variables: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap PORT: 8000 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: ApiEvent: Type: HttpApi diff --git a/examples/flask/README.md b/examples/flask/README.md index 3d1fd974..3827c493 100644 --- a/examples/flask/README.md +++ b/examples/flask/README.md @@ -10,7 +10,7 @@ The top level folder is a typical AWS SAM project. The `app` directory is a flas ```dockerfile FROM public.ecr.aws/docker/library/python:3.8.12-slim-buster -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /var/task COPY app.py requirements.txt ./ RUN python3.8 -m pip install -r requirements.txt @@ -20,7 +20,7 @@ CMD ["gunicorn", "-b=:8080", "-w=1", "app:app"] Line 2 copies lambda adapter binary into /opt/extensions. This is the only change to run the Flask application on Lambda. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ## Pre-requisites diff --git a/examples/flask/app/Dockerfile b/examples/flask/app/Dockerfile index ad3854b4..077bc848 100644 --- a/examples/flask/app/Dockerfile +++ b/examples/flask/app/Dockerfile @@ -1,5 +1,5 @@ -FROM public.ecr.aws/docker/library/python:3.8.12-slim-buster -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +FROM public.ecr.aws/docker/library/python:3.12.1-slim +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter WORKDIR /var/task COPY app.py requirements.txt ./ RUN python -m pip install -r requirements.txt diff --git a/examples/gin-zip/template.yaml b/examples/gin-zip/template.yaml index b850e351..a53efdc9 100644 --- a/examples/gin-zip/template.yaml +++ b/examples/gin-zip/template.yaml @@ -15,14 +15,14 @@ Resources: Properties: CodeUri: ./app Handler: bootstrap - Runtime: provided.al2 + Runtime: provided.al2023 MemorySize: 256 Environment: Variables: PORT: 8000 GIN_MODE: release Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: APIEvent: Type: HttpApi diff --git a/examples/gin/app/Dockerfile b/examples/gin/app/Dockerfile index bc60864d..9338a880 100644 --- a/examples/gin/app/Dockerfile +++ b/examples/gin/app/Dockerfile @@ -8,7 +8,7 @@ RUN go mod download RUN GOOS=linux CGO_ENABLED=0 go build -o bootstrap . FROM alpine:3.9 RUN apk add ca-certificates -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter COPY --from=build_base /tmp/gin/bootstrap /app/bootstrap ENV PORT=8000 GIN_MODE=release diff --git a/examples/nextjs-response-streaming/Dockerfile b/examples/nextjs-response-streaming/Dockerfile index 77a2a110..9d0d8485 100644 --- a/examples/nextjs-response-streaming/Dockerfile +++ b/examples/nextjs-response-streaming/Dockerfile @@ -1,11 +1,11 @@ -FROM public.ecr.aws/lambda/nodejs:16 as builder +FROM public.ecr.aws/lambda/nodejs:20 as builder WORKDIR /app COPY . . RUN npm update && npm run build -FROM public.ecr.aws/lambda/nodejs:16 as runner -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +FROM public.ecr.aws/lambda/nodejs:20 as runner +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ENV PORT=3000 NODE_ENV=production diff --git a/examples/nextjs-zip/template.yaml b/examples/nextjs-zip/template.yaml index 2a7c8d97..35094173 100644 --- a/examples/nextjs-zip/template.yaml +++ b/examples/nextjs-zip/template.yaml @@ -16,7 +16,7 @@ Resources: CodeUri: app/ MemorySize: 256 Handler: run.sh - Runtime: nodejs18.x + Runtime: nodejs20.x Architectures: - x86_64 Environment: @@ -26,7 +26,7 @@ Resources: RUST_LOG: info PORT: 8000 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: HttpEvent: Type: HttpApi diff --git a/examples/nextjs/app/Dockerfile b/examples/nextjs/app/Dockerfile index fca46c12..e6b4830e 100644 --- a/examples/nextjs/app/Dockerfile +++ b/examples/nextjs/app/Dockerfile @@ -4,7 +4,7 @@ COPY . . RUN npm ci && npm run build FROM public.ecr.aws/docker/library/node:20.9.0-slim as runner -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ENV PORT=3000 NODE_ENV=production ENV AWS_LWA_ENABLE_COMPRESSION=true WORKDIR /app diff --git a/examples/nginx-zip/template.yaml b/examples/nginx-zip/template.yaml index 66919a8c..71c57f7b 100644 --- a/examples/nginx-zip/template.yaml +++ b/examples/nginx-zip/template.yaml @@ -24,7 +24,7 @@ Resources: RUST_LOG: debug PORT: 8080 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:Nginx123X86:12 Events: Root: diff --git a/examples/nginx/Dockerfile b/examples/nginx/Dockerfile index 45117edf..04501cbf 100644 --- a/examples/nginx/Dockerfile +++ b/examples/nginx/Dockerfile @@ -1,6 +1,6 @@ FROM public.ecr.aws/awsguru/nginx:1.23.2023.3.11.1 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter # config files ADD nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf diff --git a/examples/nginx/README.md b/examples/nginx/README.md index 3054cb07..6716738e 100644 --- a/examples/nginx/README.md +++ b/examples/nginx/README.md @@ -14,7 +14,7 @@ a [Dockerfile](Dockerfile). ```dockerfile FROM public.ecr.aws/awsguru/nginx:1.23.2023.3.11.1 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter # config files ADD nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf @@ -28,7 +28,7 @@ EXPOSE 8080 Line 3 copies Lambda adapter binary into /opt/extensions. This is the main change to run the Nginx server on Lambda. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ## Pre-requisites diff --git a/examples/php-zip/template.yaml b/examples/php-zip/template.yaml index 83c9a006..c6567e5d 100644 --- a/examples/php-zip/template.yaml +++ b/examples/php-zip/template.yaml @@ -33,7 +33,7 @@ Resources: RUST_LOG: debug PORT: 8080 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:Php82FpmNginxX86:13 Events: Root: diff --git a/examples/php/Dockerfile b/examples/php/Dockerfile index a38104c7..4cc5add8 100644 --- a/examples/php/Dockerfile +++ b/examples/php/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /var/task/app RUN composer install --prefer-dist --optimize-autoloader --no-dev --no-interaction FROM public.ecr.aws/awsguru/php:82.2023.3.11.1 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter COPY --from=builder /var/task /var/task # config files diff --git a/examples/php/README.md b/examples/php/README.md index c31b909d..c27717b4 100644 --- a/examples/php/README.md +++ b/examples/php/README.md @@ -21,7 +21,7 @@ WORKDIR /var/task/app RUN composer install --prefer-dist --optimize-autoloader --no-dev --no-interaction FROM public.ecr.aws/awsguru/php:82.2023.3.11.1 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter COPY --from=builder /var/task /var/task # config files diff --git a/examples/rust-actix-web-zip/template.yaml b/examples/rust-actix-web-zip/template.yaml index 5956c6b1..62658a76 100644 --- a/examples/rust-actix-web-zip/template.yaml +++ b/examples/rust-actix-web-zip/template.yaml @@ -18,11 +18,11 @@ Resources: Properties: CodeUri: ./rust_app # Points to dir of Cargo.toml Handler: bootstrap # Do not change, as this is the default executable name produced by Cargo Lambda - Runtime: provided.al2 + Runtime: provided.al2023 Architectures: - arm64 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18 Events: HttpEvents: Type: HttpApi # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api diff --git a/examples/rust-axum-zip/template.yaml b/examples/rust-axum-zip/template.yaml index 603a52f8..a32c78ff 100644 --- a/examples/rust-axum-zip/template.yaml +++ b/examples/rust-axum-zip/template.yaml @@ -16,11 +16,11 @@ Resources: Properties: CodeUri: rust_app Handler: bootstrap - Runtime: provided.al2 + Runtime: provided.al2023 Architectures: - arm64 Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:18 Events: Root: Type: HttpApi # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api diff --git a/examples/springboot-response-streaming-zip/README.md b/examples/springboot-response-streaming-zip/README.md index f2f1bbb1..751e222a 100644 --- a/examples/springboot-response-streaming-zip/README.md +++ b/examples/springboot-response-streaming-zip/README.md @@ -31,7 +31,7 @@ In the configuration we have to specify the AWS Lambda adapter as a layer and co AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap AWS_LWA_INVOKE_MODE: response_stream Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 ``` In this template, we enable SnapStart for this function. SnapStart drastically reduces cold start time for Java functions using Firecracker MicroVM snapshotting technology. Read more about SnapStart [here](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html). diff --git a/examples/springboot-response-streaming-zip/template.yaml b/examples/springboot-response-streaming-zip/template.yaml index bc61de33..f30c35b6 100644 --- a/examples/springboot-response-streaming-zip/template.yaml +++ b/examples/springboot-response-streaming-zip/template.yaml @@ -16,7 +16,7 @@ Resources: MemorySize: 512 Handler: run.sh CodeUri: app/ - Runtime: java11 + Runtime: java17 AutoPublishAlias: live SnapStart: ApplyOn: PublishedVersions @@ -28,7 +28,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap AWS_LWA_INVOKE_MODE: response_stream Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 FunctionUrlConfig: AuthType: NONE InvokeMode: RESPONSE_STREAM diff --git a/examples/springboot-zip/README.md b/examples/springboot-zip/README.md index 6c086d10..9f4931fb 100644 --- a/examples/springboot-zip/README.md +++ b/examples/springboot-zip/README.md @@ -30,7 +30,7 @@ In the configuration we have to specify the AWS Lambda adapter as a layer and co REMOVE_BASE_PATH: /v1 AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 ``` In this template, we enable SnapStart for this function. SnapStart drastically reduces cold start time for Java functions using Firecracker MicroVM snapshotting technology. Read more about SnapStart [here](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html). diff --git a/examples/springboot-zip/template.yaml b/examples/springboot-zip/template.yaml index 8ea68bd1..b13ef098 100644 --- a/examples/springboot-zip/template.yaml +++ b/examples/springboot-zip/template.yaml @@ -16,7 +16,7 @@ Resources: MemorySize: 512 Handler: run.sh CodeUri: app/ - Runtime: java11 + Runtime: java17 AutoPublishAlias: live SnapStart: ApplyOn: PublishedVersions @@ -27,7 +27,7 @@ Resources: REMOVE_BASE_PATH: /v1 AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:17 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:18 Events: Root: Type: HttpApi diff --git a/examples/springboot/README.md b/examples/springboot/README.md index 591d2aab..9cd11f77 100644 --- a/examples/springboot/README.md +++ b/examples/springboot/README.md @@ -16,7 +16,7 @@ COPY pom.xml ./ RUN mvn -q clean package FROM public.ecr.aws/docker/library/amazoncorretto:8u322-al2 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter EXPOSE 8080 WORKDIR /opt COPY --from=build-image /task/target/petstore-0.0.1-SNAPSHOT.jar /opt @@ -26,7 +26,7 @@ CMD ["java", "-jar", "petstore-0.0.1-SNAPSHOT.jar"] Line 7 copies lambda adapter binary to /opt/extensions. This is the only change to run the Spring Boot application on Lambda. ```dockerfile -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter ``` ### Remove the base path diff --git a/examples/springboot/app/Dockerfile b/examples/springboot/app/Dockerfile index 14c762d9..1ae83b20 100644 --- a/examples/springboot/app/Dockerfile +++ b/examples/springboot/app/Dockerfile @@ -5,7 +5,7 @@ COPY pom.xml ./ RUN mvn -q clean package FROM public.ecr.aws/docker/library/amazoncorretto:8u322-al2 -COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.1 /lambda-adapter /opt/extensions/lambda-adapter +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.2 /lambda-adapter /opt/extensions/lambda-adapter EXPOSE 8080 WORKDIR /opt COPY --from=build-image /task/target/petstore-0.0.1-SNAPSHOT.jar /opt