diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index e2735cf5..bdd5b1a7 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -2,11 +2,12 @@ name: Pipeline on: push: + branches: + - main + - dev pull_request: - workflow_dispatch: - release: - types: - - released + branches: + - main env: PIPELINE_USER_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -312,7 +313,7 @@ jobs: # trigger the integration tests here load-gamma-matrix2: - if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} + if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} needs: [ integration-test ] runs-on: ubuntu-latest outputs: @@ -323,7 +324,7 @@ jobs: run: echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/gamma.json)}" deploy-gamma: - if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} + if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} needs: [load-gamma-matrix2] runs-on: ubuntu-latest strategy: @@ -376,7 +377,7 @@ jobs: --role-arn ${{ matrix.cloudformation_execution_role }} load-prod-matrix2: - if: ${{ github.event_name == 'release' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') }} needs: [ deploy-gamma ] runs-on: ubuntu-latest outputs: @@ -387,7 +388,7 @@ jobs: run: echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/prod.json)}" deploy-prod: - if: ${{ github.event_name == 'release' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') }} needs: [load-prod-matrix2] runs-on: ubuntu-latest environment: prod diff --git a/README.md b/README.md index 216aa1b1..6a220443 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ This works with any base images except AWS managed base images. To use AWS manag AWS Lambda Adapter also works with AWS managed Lambda runtimes. You need to do three things: 1. attach Lambda Adapter layer to your function. - 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:1` - 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:1` + 1. x86_64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:2` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:2` 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`. diff --git a/examples/expressjs-zip/README.md b/examples/expressjs-zip/README.md index 021abbd0..2d830853 100644 --- a/examples/expressjs-zip/README.md +++ b/examples/expressjs-zip/README.md @@ -4,9 +4,13 @@ This example shows how to use Lambda Adapter to run an express.js application on ### How does it work? -We package Lambda Adapter binary and a wrapper script into a Lambda Layer. And we configure environment variable 'AWS_LAMBDA_EXEC_WRAPPER' pointing to the wrapper script. +We add Lambda Adapter layer to the function and configure wrapper script. -When Lambda execution environment starts, Lambda will execute the wrapper script and starts the adapter. +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:2` + 2. arm64: `arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:2` +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. To get more information of Wrapper script, please read Lambda documentation [here](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-modify.html#runtime-wrapper). diff --git a/examples/expressjs-zip/template.yaml b/examples/expressjs-zip/template.yaml index 56e3c09e..c9cc40e4 100644 --- a/examples/expressjs-zip/template.yaml +++ b/examples/expressjs-zip/template.yaml @@ -25,7 +25,7 @@ Resources: AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap RUST_LOG: info Layers: - - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:1 + - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:2 Events: RootPath: Type: Api diff --git a/template-arm64.yaml b/template-arm64.yaml index 6cc7cee0..c7b79f6e 100644 --- a/template-arm64.yaml +++ b/template-arm64.yaml @@ -28,6 +28,13 @@ Resources: BuildMethod: makefile BuildArchitecture: arm64 + LayerPermission: + Type: AWS::Lambda::LayerVersionPermission + Properties: + Action: lambda:GetLayerVersion + LayerVersionArn: !Ref LambdaAdapterLayerArm64 + Principal: '*' + Outputs: LambdaAdapterLayerArm64Arn: Description: "arn for LambdaAdapterLayerArm64" diff --git a/template-x86_64.yaml b/template-x86_64.yaml index 7969fce4..9af69bea 100644 --- a/template-x86_64.yaml +++ b/template-x86_64.yaml @@ -31,6 +31,13 @@ Resources: BuildMethod: makefile BuildArchitecture: x86_64 + LayerPermission: + Type: AWS::Lambda::LayerVersionPermission + Properties: + Action: lambda:GetLayerVersion + LayerVersionArn: !Ref LambdaAdapterLayerX86 + Principal: '*' + Outputs: LambdaAdapterLayerX86Arn: Description: "arn for LambdaAdapterLayerX86"