diff --git a/.github/workflows/deploy_fastapi_backend.yml b/.github/workflows/deploy_fastapi_backend.yml index b85dd700..37b52031 100644 --- a/.github/workflows/deploy_fastapi_backend.yml +++ b/.github/workflows/deploy_fastapi_backend.yml @@ -44,6 +44,19 @@ jobs: aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} aws-region: eu-west-2 + - name: Install lambda specific dependencies, with bianries, in a separate dir + run: | + mkdir python + pip install -r backend/requirements/lambda.txt -t python + + - name: Create Layer package + run: | + zip -r layer.zip python + + - name: Deploy Layer to Lambda + run: | + aws lambda publish-layer-version --layer-name LambdaDependenciesLayer --zip-file fileb://layer.zip + - name: Set domain name id: set_domain run: echo "::set-output name=domain::${{ secrets[format('{0}_DOMAIN_NAME', github.ref_name)] }}" diff --git a/backend/requirements/base.txt b/backend/requirements/base.txt index 5a1693c4..5ea3ef76 100644 --- a/backend/requirements/base.txt +++ b/backend/requirements/base.txt @@ -1,7 +1,6 @@ anyio==3.7.1 cffi==1.15.1 click==8.1.3 -cryptography==37.0.4 ecdsa==0.18.0 exceptiongroup==1.1.2 fastapi==0.99.1 diff --git a/backend/requirements/lambda.txt b/backend/requirements/lambda.txt new file mode 100644 index 00000000..036f6666 --- /dev/null +++ b/backend/requirements/lambda.txt @@ -0,0 +1 @@ +cryptography==37.0.4 \ No newline at end of file diff --git a/backend/serverless.yml b/backend/serverless.yml index de71c14a..e18d584d 100644 --- a/backend/serverless.yml +++ b/backend/serverless.yml @@ -4,7 +4,7 @@ provider: name: aws runtime: python3.10 region: eu-west-2 - architecture: arm64 + architecture: x86_64 environment: API_KEY: ${env:API_KEY} ENVIRONMENT: ${env:ENVIRONMENT} @@ -12,7 +12,6 @@ provider: PLAN_TRIGGER_BUCKET: ${env:PLAN_TRIGGER_BUCKET} DOMAIN_NAME: ${env:DOMAIN_NAME} - package: individually: true include: @@ -37,13 +36,9 @@ custom: functions: app: handler: app.main.handler + layers: + - { Ref: LambdaDependenciesLayerLambdaLayer } events: - http: path: /{proxy+} method: ANY -# vpc: -# securityGroupIds: -# - sg-0abcd1234efgh5678 -# subnetIds: -# - subnet-a1b2c3d4 -# - subnet-e5f6g7h8