Skip to content

Commit

Permalink
Merge pull request #78 from oslokommune/dockerize
Browse files Browse the repository at this point in the history
Dockerify Lambda runtimes
  • Loading branch information
simenheg authored May 2, 2024
2 parents 148cc8f + 7022d39 commit da61d86
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 619 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM public.ecr.aws/lambda/python:3.11

COPY event ${LAMBDA_TASK_ROOT}/event
COPY status ${LAMBDA_TASK_ROOT}/status
COPY requirements.txt ${LAMBDA_TASK_ROOT}
RUN pip install --no-cache-dir -r requirements.txt

CMD ["set-me-in-serverless.yaml"]
601 changes: 2 additions & 599 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "status-api-serverless-testing",
"name": "okdata-status-api",
"description": "",
"version": "0.1.0",
"devDependencies": {
"serverless": "^3.38.0",
"serverless-better-credentials": "^2.0.0",
"serverless-plugin-git-variables": "^5.2.0",
"serverless-prune-plugin": "^2.0.2",
"serverless-python-requirements": "^6.0.1",
"serverless-scriptable-plugin": "^1.3.1"
}
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rsa==4.8
# via python-jose
s3transfer==0.6.0
# via boto3
simplejson==3.17.6
simplejson==3.17.2
# via status-api (setup.py)
six==1.16.0
# via
Expand Down
16 changes: 5 additions & 11 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ service: status-api

provider:
name: aws
runtime: python3.11
ecr:
images:
okdata-status-api:
path: ./
platform: linux/amd64
region: ${opt:region, 'eu-west-1'}
endpointType: REGIONAL
stage: ${opt:stage, 'dev'}
Expand Down Expand Up @@ -40,20 +44,13 @@ plugins:
- serverless-better-credentials # must be first
- serverless-plugin-git-variables
- serverless-prune-plugin
- serverless-python-requirements
- serverless-scriptable-plugin

resources:
Description: |
${self:service} ${git:branch}:${git:sha1}
${git:message}
package:
patterns:
- '!**/*'
- event/*.py
- status/*.py

functions:
get_status: ${file(serverless/functions/get_status.yaml)}
get_status_from_s3_path: ${file(serverless/functions/get_status_from_s3_path.yaml)}
Expand All @@ -62,9 +59,6 @@ functions:
act_on_queue: ${file(serverless/functions/act_on_queue.yaml)}

custom:
pythonRequirements:
dockerizePip: non-linux
usePoetry: false
prune:
automatic: true
number: 3
Expand Down
5 changes: 4 additions & 1 deletion serverless/functions/act_on_queue.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
handler: event.handler.act_on_queue
image:
name: okdata-status-api
command:
- event.handler.act_on_queue
timeout: 60
events:
- sns: arn:aws:sns:${self:provider.region}:${aws:accountId}:dataplatform_state_machine_event
5 changes: 4 additions & 1 deletion serverless/functions/create_status.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
handler: status.create_status.handler
image:
name: okdata-status-api
command:
- status.create_status.handler
events:
- http:
path: status
Expand Down
5 changes: 4 additions & 1 deletion serverless/functions/get_status.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
handler: status.get_status.handler
image:
name: okdata-status-api
command:
- status.get_status.handler
events:
- http:
path: status/{trace_id}
Expand Down
5 changes: 4 additions & 1 deletion serverless/functions/get_status_from_s3_path.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
handler: status.get_status_from_s3_path.handler
image:
name: okdata-status-api
command:
- status.get_status_from_s3_path.handler
events:
- http:
path: status-from-path/{s3_path}
Expand Down
5 changes: 4 additions & 1 deletion serverless/functions/update_status.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
handler: status.update_status.handler
image:
name: okdata-status-api
command:
- status.update_status.handler
events:
- http:
path: status/{trace_id}
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"okdata-resource-auth",
"okdata-sdk>=2.4,<4",
"requests",
"simplejson",
# Require this version specifically to not clash with the version
# required by AWS' Python image for Lambda. ("awslambdaric 2.0.10
# requires simplejson==3.17.2, but you have simplejson [...] which is
# incompatible.")
"simplejson==3.17.2",
],
)

0 comments on commit da61d86

Please sign in to comment.