Skip to main content

Overview and Configuration

Recommended configuration for developing AWS Lambda applications with Python runtime.

Overview​

Configuration diagram of the source code included in this catalog.

Architecture​

The documentation and source code included in this catalog assume the following configuration.

Two Application Types​

AWS Lambda startup patterns can be broadly classified into two types. This is not based on AWS Lambda specifications, but from the implementation practice perspective of this catalog.

  • WebAPI Development
    • WebAPI logic triggered from API Gateway
  • Event Processing
    • Processing events notified from S3, DynamoDB, SQS, SNS, etc.

Although each implementation approach appears different, they share a common layer structure. Each directory configuration is inspired by domain-driven development practices, reflecting the fact that it's a scripting language runtime and the execution environment is AWS Lambda.

The catalog project is located in the ~/serverless-backend-application-stack-python directory.

Overall Project Structure​

Directory and file structure of this entire catalog.

serverless-backend-application-stack-python/
│
├── .vscode/ # VSCode configuration files
│ ├── extensions.json
│ └── settings.json
│
├── deploy/
│ ├── cloudformation/
│ │ ├── apigateway-lambda.yaml
│ │ ├── db.yaml
│ │ ├── s3-lambda.yaml
│ │ └── vpc.yaml
│ └── fixtures/
│ └── psycopg3.zip # DB library (psycopg3) binary
│
├── src/
│ ├── sample_api/ # WebAPI implementation
│ │ ├── actions/
│ │ │ ├── create_users_action.py
│ │ │ └── get_users_action.py
│ │ ├── daos/
│ │ │ └── users_dao.py
│ │ ├── services/
│ │ │ └── users_service.py
│ │ └── index.py
│ │
│ ├── sample_event/ # Event processing implementation
│ │ ├── actions/
│ │ │ └── data_import_action.py
│ │ ├── aws/
│ │ │ └── s3_client.py
│ │ ├── daos/
│ │ │ └── users_dao.py
│ │ ├── services/
│ │ │ └── data_import_service.py
│ │ └── index.py
│ │
│ ├── .init_db.py # Local DB initialization
│ ├── .init_minio.py # Local S3 initialization
│ ├── .local.sample_api.get_users.py # Local execution script
│ ├── .local.sample_api.post_users.py # Local execution script
│ ├── .local.sample_event.import_users.py # Local execution script
│ └── sample_users.csv # Dummy data for local execution
│
├── tests/
│ ├── sample_api/ # Unit tests for WebAPI implementation
│ │ ├── conftest.py
│ │ ├── test_create_users.py
│ │ └── test_get_users.py
│ │
│ └── sample_event/ # Unit tests for event processing
│ ├── conftest.py
│ └── test_data_import.py
│
├── .editorconfig
├── .gitignore
├── build-app.sh # Script for creating deployment zip for WebAPI and event processing Lambda functions
├── build-layer.sh # Script for creating deployment zip for dependency library Lambda Layer
├── docker-compose.yml # For launching Local DB (PostgreSQL), Local S3 (MiniO)
├── poetry.lock
├── pyproject.yoml
└── README.md