000 django lambda - Enterprise-CMCS/cmcs-eregulations GitHub Wiki

Design for running a Django service on AWS Lambda

proposed

Context

AWS Lambda is being encouraged as the runtime for eRegs. Being a Django project, eRegs is typically run as a Python WSGI application.

Decision

https://www.serverless.com/blog/django-serverless-framework-a-match-made-in-heaven https://medium.com/@matias.forbord/starting-serverless-with-django-1b3dda1fb6a

service: cmcs-eregs

provider:
  name: aws
  runtime: python3.6

functions:
  reg_core:
    environment: ${self:custom}
    handler: handler.reg_core
    package:
      include:
        - /app/src/handler.py
    events:
      - http: ANY /
      - http: ANY {proxy+}
  reg_site:
    environment: ${self:custom}
    handler: handler.reg_site
    package:
      include:
        - /app/src/regulations/handler.py
    events:
      - http: ANY /
      - http: ANY {proxy+}

plugins:
  - serverless-python-requirements
  - serverless-wsgi
  • TODO: we need to show that we can do this with the existing programs.

Consequences

Requires wsgi.py files or equivalent for our systems.

⚠️ **GitHub.com Fallback** ⚠️