$npx -y skills add giuseppe-trisciuoglio/developer-kit --skill aws-sam-bootstrapProvides AWS SAM bootstrap patterns: generates template.yaml and samconfig.toml for new projects via sam init, creates SAM templates for existing Lambda/CloudFormation code migration, validates build/package/deploy workflows, and configures local testing with `sam local inv
| 1 | # AWS SAM Bootstrap |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Generates SAM project artifacts for greenfield and migration scenarios. Creates the minimum required files (`template.yaml`, `samconfig.toml`, `events/`), validates with `sam build`, and configures `sam deploy` workflows following AWS SAM conventions. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - User needs to start a new AWS SAM project (`sam init`, `sam deploy`) |
| 10 | - User wants to migrate existing Lambda functions or CloudFormation resources to SAM templates |
| 11 | - User asks about SAM CLI commands (`sam init`, `sam build`, `sam local invoke`, `sam deploy`) |
| 12 | - User needs to create or update `template.yaml` or `samconfig.toml` for serverless deployments |
| 13 | - User wants to configure local testing with `sam local invoke` for Lambda functions |
| 14 | |
| 15 | ## Instructions |
| 16 | |
| 17 | ### 1) Classify Scenario |
| 18 | |
| 19 | - **New project**: no Lambda structure exists. Run `sam init` to scaffold. |
| 20 | - **Existing project migration**: Lambda/CloudFormation resources exist. Create `template.yaml` manually. |
| 21 | |
| 22 | ### 2) Select Runtime and Package Type |
| 23 | |
| 24 | Use current non-deprecated runtimes. Package type: **Zip** (default) or **Image** (container/native deps). |
| 25 | |
| 26 | ### 3) Bootstrap New Projects |
| 27 | |
| 28 | ```bash |
| 29 | sam init |
| 30 | sam build |
| 31 | sam local invoke <LogicalFunctionId> -e events/event.json |
| 32 | sam deploy --guided |
| 33 | ``` |
| 34 | |
| 35 | ### 4) Bootstrap Existing Projects |
| 36 | |
| 37 | 1. Inspect current Lambda handlers, runtime, and dependency layout |
| 38 | 2. Create `template.yaml` with `Transform: AWS::Serverless-2016-10-31` |
| 39 | 3. Map existing resources to `AWS::Serverless::Function` and related SAM resources |
| 40 | 4. Create `samconfig.toml` with deploy defaults and environment overrides |
| 41 | 5. Add `events/event.json` payload samples for local invocation |
| 42 | 6. Validate with `sam validate` and `sam build` before deploy |
| 43 | |
| 44 | ### 5) Required Artifacts |
| 45 | |
| 46 | ``` |
| 47 | . |
| 48 | ├── template.yaml |
| 49 | ├── samconfig.toml |
| 50 | └── events/ |
| 51 | └── event.json |
| 52 | ``` |
| 53 | |
| 54 | See reference templates: [examples.md](references/examples.md), [migration-checklist.md](references/migration-checklist.md) |
| 55 | |
| 56 | ### 6) Validation Checklist |
| 57 | |
| 58 | - `sam validate` succeeds |
| 59 | - `sam build` succeeds |
| 60 | - `template.yaml` has correct logical IDs and handlers |
| 61 | - `samconfig.toml` contains deploy parameters for target environments |
| 62 | |
| 63 | ## Examples |
| 64 | |
| 65 | ### New SAM Project |
| 66 | |
| 67 | ```bash |
| 68 | sam init # Interactive scaffold |
| 69 | sam build |
| 70 | sam local invoke HelloFunction -e events/event.json |
| 71 | sam deploy --guided |
| 72 | ``` |
| 73 | |
| 74 | ### Migrate Existing Lambda |
| 75 | |
| 76 | 1. Detect handler/runtime → create `template.yaml` with SAM transform |
| 77 | 2. Add `samconfig.toml` with `stack_name`, `capabilities`, `resolve_s3` |
| 78 | 3. Add `events/event.json` → validate with `sam build` |
| 79 | |
| 80 | Full templates in [references/examples.md](references/examples.md). |
| 81 | |
| 82 | ## Best Practices |
| 83 | |
| 84 | - One deployable function first, then expand; keep migration-first PRs minimal |
| 85 | - Keep `samconfig.toml` committed for deterministic deployments |
| 86 | - Use environment-specific sections (`[default]`, `[prod]`) instead of CLI flags |
| 87 | - Map existing handler paths to SAM conventions during migration |
| 88 | |
| 89 | ## Constraints and Warnings |
| 90 | |
| 91 | - SAM CLI must be installed locally for command execution |
| 92 | - `CAPABILITY_IAM` is required when IAM resources are created |
| 93 | - Container image packaging requires Docker availability |
| 94 | - Existing projects may require refactoring handler paths to match SAM conventions |
| 95 | - `sam deploy --guided` writes local configuration; review before committing |