engineering-handbook/sam-project-layout.md
Adam Moussa 0333e7f8f5 Add engineering handbook
Conventions covering naming, git workflow, commit messages, pull
requests, code review, GitHub standards, AWS infrastructure, SAM
project layout, and secrets management. Commit messages section
adapted from RomuloOliveira/commit-messages-guide (CC-BY-4.0).
2026-05-02 16:42:44 -04:00

1.5 KiB

SAM Project Layout

Standard Directory Structure

project-name/
├── template.yaml            # SAM template at root
├── samconfig.toml           # Deploy config (gitignored)
├── samconfig.toml.example   # Template for onboarding (committed)
├── src/
│   ├── function_name/
│   │   ├── app.py           # Lambda handler
│   │   └── requirements.txt # Per-function dependencies
│   └── shared/              # Shared layer code (if needed)
└── .gitignore

File Purposes

template.yaml

The SAM/CloudFormation template. Lives at the project root. Defines all Lambda functions, IAM roles, API Gateway endpoints, DynamoDB tables, and other resources.

samconfig.toml

Contains real ARNs, S3 bucket names, and deploy parameters. Gitignored because it varies per environment and may contain account-specific values.

samconfig.toml.example

A committed template showing the expected structure and parameter names. New contributors copy this to samconfig.toml and fill in their values.

src/function_name/

One directory per Lambda function. Each contains its own handler (app.py) and dependencies (requirements.txt). This keeps functions independently deployable and avoids bloating one function with another's dependencies.

src/shared/

Optional. Used for code shared across multiple functions, typically deployed as a Lambda layer.

Standard .gitignore

.aws-sam/
__pycache__/
*.pyc
.env
samconfig.toml