EasySAM Skill
This skill provides opinionated workflows and syntax rules for building, validating, and deploying serverless applications using the EasySAM YAML-to-SAM generator.
Core Directives & Cardinal Rules
- NEVER Edit
template.yml Directly:
template.yml (and template.yaml) is an ephemeral build artifact automatically generated by easysam generate and easysam deploy. Do NOT edit template.yml manually under any circumstances. All configuration changes must be made in resources.yaml, module-level easysam.yaml, or deploy-context.yaml.
- FastAPI Lambdas MUST Be Greedy:
Any Lambda function using FastAPI or similar routing frameworks must set
greedy: true under integration:. FastAPI manages internal sub-path routing (/api/v1/items); non-greedy routes will cause API Gateway to return 404 for sub-routes.
- Deployment Failure Circuit-Breaker:
If
easysam deploy or CloudFormation stack update gets stuck, fails, or enters a rollback loop 2 or more times: STOP attempting retries immediately. Do not run command loops. Output the exact failure details from CloudFormation logs and inform the user so they can intervene (e.g. manual console rollback, easysam delete --force, or fixing CloudFormation resource locks).
- Do NOT Run Standalone
prismarine generate-client:
When using Prismarine in EasySAM, client code generation (prismarine_client.py) is automatically performed as an integrated step of easysam generate . and easysam deploy .. Do NOT execute separate prismarine generate-client shell commands.
Standard Project Hierarchy
EasySAM strictly enforces a modular "Module Pattern" for organizing AWS resources. Divide applications into feature or resource modules:
my-project/
├── resources.yaml # Global configuration (prefix, tags, python, envvars) and module imports
├── deploy-context.yaml # Environment overrides (dev, prod ARNs/VPCs)
├── .gitignore # Excludes **/common/ and **/prismarine_clients/
├── sam/
│ └── thirdparty/
│ └── requirements.txt # Runtime dependencies packaged into Lambda artifacts
├── pyproject.toml # Dev dependencies (pytest, ruff, easysam)
├── backend/ # Main module (imported by resources.yaml)
│ ├── database/ # Database resources module (DynamoDB or Prismarine schema)
│ │ ├── easysam.yaml
│ │ └── schema.prisma # Prismarine schema (if using Prismarine ORM)
│ └── function/ # Compute resources module
│ └── my-function/
│ ├── easysam.yaml # Local resource definition
│ └── index.py # Lambda handler code
├── common/ # Shared application logic & custom DynamoAccess helpers
│ ├── utils.py
│ └── dynamo_access.py # Custom DynamoAccess helper (if not using Prismarine)
└── tests/ # Unit & integration test suite (pytest)
└── test_myapp.py
Key Architectural & Git Conventions
- Modular Imports: Root
resources.yaml must list sub-modules under import: (e.g., import: [backend]).
- Git Configuration: Every
.gitignore (or root .gitignore) must exclude:
**/common/ (synced shared code modules)
**/prismarine_clients/ (auto-generated Prismarine ORM clients)
- Dependency Management:
- Place Lambda runtime packages in
sam/thirdparty/requirements.txt.
- Keep project dependencies empty in
pyproject.toml ([project] dependencies = []) and place development tools under [dependency-groups] dev.
Data Access Guidance: Prismarine vs Custom DynamoAccess
When building DynamoDB-backed applications in EasySAM, choose one of two supported data access patterns:
- Prismarine (Prisma for DynamoDB):
- Use Case: Schema-driven ORM with type-safe models, auto-generated Pydantic models, and structured queries.
- Setup: Define models in
common/<package>/models.py and configure prismarine: in resources.yaml. EasySAM automatically generates prismarine_client.py during easysam generate . or easysam deploy ..
- Custom
DynamoAccess (boto3 Helper):
- Use Case: Lightweight, zero-dependency, low-latency DynamoDB access using direct
boto3 queries.
- Setup: Define a
DynamoAccess class in common/dynamo_access.py wrapping boto3.resource('dynamodb') table operations (get_item, put_item, query, update_item).
Core Developer Workflows
1. Scaffolding a New Application
- Run
uv run easysam init to initialize project baseline.
- Structure modules by boundary (e.g.,
backend/database/, backend/orders/).
- Define global settings in
resources.yaml (set prefix, tags, python, import).
- Ensure
.gitignore ignores **/common/ and **/prismarine_clients/.
2. Adding a Resource (Implement-Validate-Test Cycle)
- Add local resource definitions in the target module's
easysam.yaml.
- Schema Validation Gate: Run
uv run easysam --environment dev inspect schema . to validate YAML schema.
- Write minimal Lambda handler code alongside the module's
easysam.yaml.
- Write unit tests in
tests/ using pytest.
3. Deployment Pipeline & Safety
- Cloud Verification Gate: Run
uv run easysam --environment dev --aws-profile <profile> inspect cloud . to verify external ARNs and roles.
- Template Preview: Run
uv run easysam --environment dev generate . to inspect generated templates and generate Prismarine clients automatically. (Do NOT edit template.yml directly or run standalone prismarine generate-client).
- Deploy: Run
uv run easysam --environment dev --aws-profile <profile> deploy ..
- Stuck Deployment Safety: If deployment fails or hangs 2+ times, STOP retrying and report CloudFormation stack status to the user.
EasySAM YAML Syntax Rules
1. Resource References
- Refer to local DynamoDB tables and S3 buckets by bare name strings (
MyTable, my-bucket). Do NOT use !Ref.
2. Environment Variables
envvars MUST be defined under resources:, NOT as a sibling of resources: under lambda:.
- SSM Parameters: Use
{{resolve:ssm:/path/to/param}}. Do NOT use !Param.
3. HTTP Integrations & Greedy Routes
- Use
integration: (not api:). Ensure each HTTP Lambda has a unique path prefix.
- FastAPI / Framework Lambdas: Always specify
greedy: true.
lambda:
name: api-handler
integration:
path: /api/v1
greedy: true # Mandatory for FastAPI to handle sub-paths
open: true
Reference Material
- Examples Index: See references/examples.md for a complete mapping of all 18 example projects under
example/ in the easysam repository.
- Resource Recipes & Patterns: See references/patterns.md for full YAML recipes across all 14 supported resource types (FastAPI greedy routes, OpenSearch Serverless, Lambda Function URLs, Kinesis Streams, Custom Layers, Custom Authorizers, IoT MQTT, Prismarine vs DynamoAccess, DynamoDB, S3, SQS, SNS, Poller).
- Troubleshooting: See references/troubleshooting.md for schema, cloud, stack lock, and template resolution error fixes.
- CI/CD Pipeline: Use assets/publish.yml for GitHub Actions OIDC deployment.
1---2name: easysam-skill3description: Build and deploy modular serverless applications using the EasySAM YAML-to-SAM generator. Always use this skill whenever the user asks to scaffold a serverless project, configure AWS resources (Lambda, DynamoDB, S3, SQS, SNS, EventBridge poller, OpenSearch Serverless, Kinesis, Function URLs), define resources.yaml or easysam.yaml, inspect schema or cloud settings, generate SAM templates, or set up GitHub Actions CI/CD pipelines for serverless applications, even if they don't explicitly mention 'EasySAM'.4---56# EasySAM Skill78This skill provides opinionated workflows and syntax rules for building, validating, and deploying serverless applications using the EasySAM YAML-to-SAM generator.910## Core Directives & Cardinal Rules11121. **NEVER Edit `template.yml` Directly**:13 `template.yml` (and `template.yaml`) is an ephemeral build artifact automatically generated by `easysam generate` and `easysam deploy`. **Do NOT edit `template.yml` manually under any circumstances.** All configuration changes must be made in `resources.yaml`, module-level `easysam.yaml`, or `deploy-context.yaml`.142. **FastAPI Lambdas MUST Be Greedy**:15 Any Lambda function using FastAPI or similar routing frameworks must set `greedy: true` under `integration:`. FastAPI manages internal sub-path routing (`/api/v1/items`); non-greedy routes will cause API Gateway to return 404 for sub-routes.163. **Deployment Failure Circuit-Breaker**:17 If `easysam deploy` or CloudFormation stack update gets stuck, fails, or enters a rollback loop **2 or more times**: **STOP attempting retries immediately.** Do not run command loops. Output the exact failure details from CloudFormation logs and inform the user so they can intervene (e.g. manual console rollback, `easysam delete --force`, or fixing CloudFormation resource locks).184. **Do NOT Run Standalone `prismarine generate-client`**:19 When using Prismarine in EasySAM, client code generation (`prismarine_client.py`) is **automatically performed as an integrated step of `easysam generate .` and `easysam deploy .`**. Do NOT execute separate `prismarine generate-client` shell commands.2021## Standard Project Hierarchy2223EasySAM strictly enforces a modular "Module Pattern" for organizing AWS resources. Divide applications into feature or resource modules:2425```text26my-project/27├── resources.yaml # Global configuration (prefix, tags, python, envvars) and module imports28├── deploy-context.yaml # Environment overrides (dev, prod ARNs/VPCs)29├── .gitignore # Excludes **/common/ and **/prismarine_clients/30├── sam/31│ └── thirdparty/32│ └── requirements.txt # Runtime dependencies packaged into Lambda artifacts33├── pyproject.toml # Dev dependencies (pytest, ruff, easysam)34├── backend/ # Main module (imported by resources.yaml)35│ ├── database/ # Database resources module (DynamoDB or Prismarine schema)36│ │ ├── easysam.yaml37│ │ └── schema.prisma # Prismarine schema (if using Prismarine ORM)38│ └── function/ # Compute resources module39│ └── my-function/40│ ├── easysam.yaml # Local resource definition41│ └── index.py # Lambda handler code42├── common/ # Shared application logic & custom DynamoAccess helpers43│ ├── utils.py44│ └── dynamo_access.py # Custom DynamoAccess helper (if not using Prismarine)45└── tests/ # Unit & integration test suite (pytest)46 └── test_myapp.py47```4849### Key Architectural & Git Conventions50- **Modular Imports**: Root `resources.yaml` must list sub-modules under `import:` (e.g., `import: [backend]`).51- **Git Configuration**: Every `.gitignore` (or root `.gitignore`) **must** exclude:52 - `**/common/` (synced shared code modules)53 - `**/prismarine_clients/` (auto-generated Prismarine ORM clients)54- **Dependency Management**:55 - Place Lambda runtime packages in `sam/thirdparty/requirements.txt`.56 - Keep project dependencies empty in `pyproject.toml` (`[project] dependencies = []`) and place development tools under `[dependency-groups] dev`.5758## Data Access Guidance: Prismarine vs Custom `DynamoAccess`5960When building DynamoDB-backed applications in EasySAM, choose one of two supported data access patterns:61621. **Prismarine (Prisma for DynamoDB)**:63 - **Use Case**: Schema-driven ORM with type-safe models, auto-generated Pydantic models, and structured queries.64 - **Setup**: Define models in `common/<package>/models.py` and configure `prismarine:` in `resources.yaml`. EasySAM automatically generates `prismarine_client.py` during `easysam generate .` or `easysam deploy .`.652. **Custom `DynamoAccess` (boto3 Helper)**:66 - **Use Case**: Lightweight, zero-dependency, low-latency DynamoDB access using direct `boto3` queries.67 - **Setup**: Define a `DynamoAccess` class in `common/dynamo_access.py` wrapping `boto3.resource('dynamodb')` table operations (`get_item`, `put_item`, `query`, `update_item`).6869## Core Developer Workflows7071### 1. Scaffolding a New Application721. Run `uv run easysam init` to initialize project baseline.732. Structure modules by boundary (e.g., `backend/database/`, `backend/orders/`).743. Define global settings in `resources.yaml` (set `prefix`, `tags`, `python`, `import`).754. Ensure `.gitignore` ignores `**/common/` and `**/prismarine_clients/`.7677### 2. Adding a Resource (Implement-Validate-Test Cycle)781. Add local resource definitions in the target module's `easysam.yaml`.792. **Schema Validation Gate**: Run `uv run easysam --environment dev inspect schema .` to validate YAML schema.803. Write minimal Lambda handler code alongside the module's `easysam.yaml`.814. Write unit tests in `tests/` using `pytest`.8283### 3. Deployment Pipeline & Safety841. **Cloud Verification Gate**: Run `uv run easysam --environment dev --aws-profile <profile> inspect cloud .` to verify external ARNs and roles.852. **Template Preview**: Run `uv run easysam --environment dev generate .` to inspect generated templates and generate Prismarine clients automatically. (**Do NOT edit `template.yml` directly or run standalone `prismarine generate-client`**).863. **Deploy**: Run `uv run easysam --environment dev --aws-profile <profile> deploy .`.874. **Stuck Deployment Safety**: If deployment fails or hangs 2+ times, **STOP retrying** and report CloudFormation stack status to the user.8889## EasySAM YAML Syntax Rules9091### 1. Resource References92- Refer to local DynamoDB tables and S3 buckets by bare name strings (`MyTable`, `my-bucket`). **Do NOT use `!Ref`**.9394### 2. Environment Variables95- `envvars` MUST be defined under `resources:`, NOT as a sibling of `resources:` under `lambda:`.96- **SSM Parameters**: Use `{{resolve:ssm:/path/to/param}}`. **Do NOT use `!Param`**.9798### 3. HTTP Integrations & Greedy Routes99- Use `integration:` (not `api:`). Ensure each HTTP Lambda has a unique path prefix.100- **FastAPI / Framework Lambdas**: Always specify `greedy: true`.101102```yaml103lambda:104 name: api-handler105 integration:106 path: /api/v1107 greedy: true # Mandatory for FastAPI to handle sub-paths108 open: true109```110111## Reference Material112- **Examples Index**: See [references/examples.md](references/examples.md) for a complete mapping of all 18 example projects under `example/` in the `easysam` repository.113- **Resource Recipes & Patterns**: See [references/patterns.md](references/patterns.md) for full YAML recipes across all 14 supported resource types (FastAPI greedy routes, OpenSearch Serverless, Lambda Function URLs, Kinesis Streams, Custom Layers, Custom Authorizers, IoT MQTT, Prismarine vs DynamoAccess, DynamoDB, S3, SQS, SNS, Poller).114- **Troubleshooting**: See [references/troubleshooting.md](references/troubleshooting.md) for schema, cloud, stack lock, and template resolution error fixes.115- **CI/CD Pipeline**: Use [assets/publish.yml](assets/publish.yml) for GitHub Actions OIDC deployment.