vybekiit 0.7.3 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/bin.js +16607 -7527
  2. package/dist/global-skills/aws-cdk/SKILL.md +2 -1
  3. package/dist/global-skills/aws-cloudformation/SKILL.md +2 -1
  4. package/dist/global-skills/aws-serverless/SKILL.md +45 -44
  5. package/dist/global-skills/aws-serverless/assets/powertools-handler.py +2 -1
  6. package/dist/global-skills/aws-serverless/references/api-gateway.md +50 -470
  7. package/dist/global-skills/aws-serverless/references/architecture.md +47 -186
  8. package/dist/global-skills/aws-serverless/references/concurrency.md +44 -158
  9. package/dist/global-skills/aws-serverless/references/deployment.md +1 -1
  10. package/dist/global-skills/aws-serverless/references/event-sources.md +72 -391
  11. package/dist/global-skills/aws-serverless/references/lambda.md +69 -428
  12. package/dist/global-skills/aws-serverless/references/orchestration.md +65 -384
  13. package/dist/global-skills/aws-serverless/references/production.md +78 -415
  14. package/dist/global-skills/aws-serverless/references/troubleshooting.md +92 -619
  15. package/dist/global-skills/claimable-postgres/SKILL.md +60 -49
  16. package/dist/global-skills/design-my-data/SKILL.md +2 -0
  17. package/dist/global-skills/eas-app-stores/SKILL.md +8 -0
  18. package/dist/global-skills/eas-app-stores/references/play-store.md +2 -0
  19. package/dist/global-skills/eas-hosting/SKILL.md +8 -0
  20. package/dist/global-skills/eas-observe/SKILL.md +30 -8
  21. package/dist/global-skills/eas-observe/agents/openai.yaml +1 -1
  22. package/dist/global-skills/eas-observe/references/metrics.md +54 -3
  23. package/dist/global-skills/eas-observe/references/queries.md +78 -17
  24. package/dist/global-skills/eas-observe/references/setup.md +164 -5
  25. package/dist/global-skills/eas-observe/references/third-party.md +136 -0
  26. package/dist/global-skills/eas-simulator/SKILL.md +63 -11
  27. package/dist/global-skills/eas-simulator/references/controllers.md +21 -2
  28. package/dist/global-skills/eas-simulator/references/run-your-app.md +16 -11
  29. package/dist/global-skills/eas-simulator/references/troubleshooting.md +8 -5
  30. package/dist/global-skills/eas-update-insights/SKILL.md +8 -0
  31. package/dist/global-skills/eas-workflows/SKILL.md +15 -10
  32. package/dist/global-skills/eas-workflows/scripts/package.json +2 -7
  33. package/dist/global-skills/email-best-practices/.github/workflows/sync-skills.yml +30 -0
  34. package/dist/global-skills/email-best-practices/README.md +63 -0
  35. package/dist/global-skills/email-best-practices/references/accessibility.md +189 -0
  36. package/dist/global-skills/email-best-practices/references/compliance.md +125 -0
  37. package/dist/global-skills/email-best-practices/references/deliverability.md +121 -0
  38. package/dist/global-skills/email-best-practices/references/email-capture.md +129 -0
  39. package/dist/global-skills/email-best-practices/references/email-types.md +173 -0
  40. package/dist/global-skills/email-best-practices/references/list-management.md +157 -0
  41. package/dist/global-skills/email-best-practices/references/marketing-emails.md +115 -0
  42. package/dist/global-skills/email-best-practices/references/sending-reliability.md +155 -0
  43. package/dist/global-skills/email-best-practices/references/transactional-email-catalog.md +418 -0
  44. package/dist/global-skills/email-best-practices/references/transactional-emails.md +92 -0
  45. package/dist/global-skills/email-best-practices/references/webhooks-events.md +167 -0
  46. package/dist/global-skills/email-best-practices/tests/README.md +35 -0
  47. package/dist/global-skills/email-best-practices/tests/scenarios/01-spam-deliverability.md +46 -0
  48. package/dist/global-skills/email-best-practices/tests/scenarios/02-multi-region-compliance.md +48 -0
  49. package/dist/global-skills/email-best-practices/tests/scenarios/03-retry-idempotency.md +36 -0
  50. package/dist/global-skills/email-best-practices/tests/scenarios/04-webhook-bounce-handling.md +52 -0
  51. package/dist/global-skills/email-best-practices/tests/scenarios/05-new-saas-email-plan.md +51 -0
  52. package/dist/global-skills/expo-animation/LICENSE +21 -0
  53. package/dist/global-skills/expo-animation/RECIPES.md +385 -0
  54. package/dist/global-skills/expo-animation/SKILL.md +267 -0
  55. package/dist/global-skills/expo-animation/agents/openai.yaml +4 -0
  56. package/dist/global-skills/expo-app-clip/SKILL.md +8 -0
  57. package/dist/global-skills/expo-brownfield/SKILL.md +8 -0
  58. package/dist/global-skills/expo-brownfield/references/brownfield-isolated.md +53 -4
  59. package/dist/global-skills/expo-data-fetching/SKILL.md +8 -0
  60. package/dist/global-skills/expo-design-system/SKILL.md +356 -0
  61. package/dist/global-skills/expo-design-system/agents/openai.yaml +4 -0
  62. package/dist/global-skills/expo-design-system/references/audit.md +185 -0
  63. package/dist/global-skills/expo-dev-client/SKILL.md +8 -0
  64. package/dist/global-skills/expo-dom/SKILL.md +8 -0
  65. package/dist/global-skills/expo-examples/SKILL.md +8 -0
  66. package/dist/global-skills/expo-migrate-module/SKILL.md +113 -0
  67. package/dist/global-skills/expo-migrate-module/agents/openai.yaml +4 -0
  68. package/dist/global-skills/expo-migrate-module/references/compatibility.md +73 -0
  69. package/dist/global-skills/expo-migrate-module/references/example.md +212 -0
  70. package/dist/global-skills/expo-migrate-module/references/migration-map.md +306 -0
  71. package/dist/global-skills/expo-module/SKILL.md +11 -1
  72. package/dist/global-skills/expo-native-ui/SKILL.md +8 -0
  73. package/dist/global-skills/expo-project-structure/SKILL.md +114 -0
  74. package/dist/global-skills/expo-project-structure/agents/openai.yaml +4 -0
  75. package/dist/global-skills/expo-router/SKILL.md +8 -0
  76. package/dist/global-skills/expo-skill-feedback/SKILL.md +66 -33
  77. package/dist/global-skills/expo-skill-feedback/agents/openai.yaml +2 -2
  78. package/dist/global-skills/expo-tailwind-setup/SKILL.md +8 -0
  79. package/dist/global-skills/expo-ui/SKILL.md +8 -0
  80. package/dist/global-skills/expo-upgrade/SKILL.md +15 -1
  81. package/dist/global-skills/expo-web-to-native/SKILL.md +8 -0
  82. package/dist/global-skills/extension-to-functions-codebase/SKILL.md +129 -0
  83. package/dist/global-skills/extension-to-functions-codebase/references/configuration-migration.md +161 -0
  84. package/dist/global-skills/extension-to-functions-codebase/references/destructuring-shim.md +122 -0
  85. package/dist/global-skills/extension-to-functions-codebase/references/signature-mapping.md +84 -0
  86. package/dist/global-skills/firebase-ai-logic-basics/SKILL.md +61 -19
  87. package/dist/global-skills/firebase-ai-logic-basics/references/flutter_setup.md +6 -3
  88. package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +5 -1
  89. package/dist/global-skills/firebase-auth-basics/SKILL.md +4 -2
  90. package/dist/global-skills/firebase-basics/SKILL.md +5 -5
  91. package/dist/global-skills/firebase-crashlytics/SKILL.md +2 -0
  92. package/dist/global-skills/firebase-data-connect/SKILL.md +2 -0
  93. package/dist/global-skills/firebase-firestore/SKILL.md +3 -6
  94. package/dist/global-skills/firebase-hosting-basics/SKILL.md +4 -1
  95. package/dist/global-skills/firebase-remote-config-basics/SKILL.md +5 -1
  96. package/dist/global-skills/firebase-security-rules-auditor/SKILL.md +4 -1
  97. package/dist/global-skills/harden/SKILL.md +2 -1
  98. package/dist/global-skills/instrument-feature-flags/SKILL.md +1 -0
  99. package/dist/global-skills/instrument-feature-flags/references/COMMANDMENTS.md +5 -0
  100. package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +6 -4
  101. package/dist/global-skills/instrument-feature-flags/references/android.md +6 -4
  102. package/dist/global-skills/instrument-feature-flags/references/api.md +6 -4
  103. package/dist/global-skills/instrument-feature-flags/references/best-practices.md +6 -4
  104. package/dist/global-skills/instrument-feature-flags/references/django.md +38 -5
  105. package/dist/global-skills/instrument-feature-flags/references/dotnet.md +10 -4
  106. package/dist/global-skills/instrument-feature-flags/references/elixir.md +6 -4
  107. package/dist/global-skills/instrument-feature-flags/references/flask.md +17 -5
  108. package/dist/global-skills/instrument-feature-flags/references/flutter.md +7 -5
  109. package/dist/global-skills/instrument-feature-flags/references/go.md +6 -4
  110. package/dist/global-skills/instrument-feature-flags/references/ios.md +6 -4
  111. package/dist/global-skills/instrument-feature-flags/references/java.md +6 -4
  112. package/dist/global-skills/instrument-feature-flags/references/laravel.md +6 -4
  113. package/dist/global-skills/instrument-feature-flags/references/next-js.md +74 -8
  114. package/dist/global-skills/instrument-feature-flags/references/nodejs.md +6 -4
  115. package/dist/global-skills/instrument-feature-flags/references/php.md +6 -4
  116. package/dist/global-skills/instrument-feature-flags/references/python.md +6 -4
  117. package/dist/global-skills/instrument-feature-flags/references/react-native.md +6 -4
  118. package/dist/global-skills/instrument-feature-flags/references/react.md +6 -4
  119. package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +6 -4
  120. package/dist/global-skills/instrument-feature-flags/references/ruby.md +6 -4
  121. package/dist/global-skills/instrument-feature-flags/references/rust.md +6 -4
  122. package/dist/global-skills/instrument-feature-flags/references/usage.md +41 -4
  123. package/dist/global-skills/instrument-feature-flags/references/web.md +7 -5
  124. package/dist/global-skills/instrument-product-analytics/SKILL.md +2 -1
  125. package/dist/global-skills/instrument-product-analytics/references/COMMANDMENTS.md +5 -0
  126. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-hybrid.md +12 -14
  127. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-ssr.md +25 -21
  128. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-django.md +75 -55
  129. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +3 -6
  130. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +26 -16
  131. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-nuxt-3-6.md +8 -5
  132. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-nuxt-4.md +4 -4
  133. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-react-react-router-7-framework.md +3 -3
  134. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby-on-rails.md +8 -4
  135. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-tanstack-start.md +20 -8
  136. package/dist/global-skills/instrument-product-analytics/references/android.md +46 -4
  137. package/dist/global-skills/instrument-product-analytics/references/angular.md +41 -5
  138. package/dist/global-skills/instrument-product-analytics/references/astro.md +41 -5
  139. package/dist/global-skills/instrument-product-analytics/references/configuration.md +7 -4
  140. package/dist/global-skills/instrument-product-analytics/references/django.md +38 -5
  141. package/dist/global-skills/instrument-product-analytics/references/dotnet.md +10 -4
  142. package/dist/global-skills/instrument-product-analytics/references/elixir.md +6 -4
  143. package/dist/global-skills/instrument-product-analytics/references/flask.md +17 -5
  144. package/dist/global-skills/instrument-product-analytics/references/flutter.md +49 -4
  145. package/dist/global-skills/instrument-product-analytics/references/go.md +6 -4
  146. package/dist/global-skills/instrument-product-analytics/references/identify-users.md +38 -7
  147. package/dist/global-skills/instrument-product-analytics/references/ios.md +14 -4
  148. package/dist/global-skills/instrument-product-analytics/references/laravel.md +6 -4
  149. package/dist/global-skills/instrument-product-analytics/references/next-js.md +74 -8
  150. package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +39 -7
  151. package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +40 -4
  152. package/dist/global-skills/instrument-product-analytics/references/php.md +6 -4
  153. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +21 -17
  154. package/dist/global-skills/instrument-product-analytics/references/python.md +15 -5
  155. package/dist/global-skills/instrument-product-analytics/references/react-native.md +41 -7
  156. package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +18 -4
  157. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +18 -4
  158. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +18 -4
  159. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +18 -4
  160. package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +6 -4
  161. package/dist/global-skills/instrument-product-analytics/references/ruby.md +6 -4
  162. package/dist/global-skills/instrument-product-analytics/references/svelte.md +42 -6
  163. package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +31 -7
  164. package/dist/global-skills/instrument-product-analytics/references/usage.md +41 -4
  165. package/dist/global-skills/instrument-product-analytics/references/vue-js.md +42 -6
  166. package/dist/global-skills/manifest.json +6 -1
  167. package/dist/global-skills/neon/SKILL.md +235 -121
  168. package/dist/global-skills/neon-ai-gateway/SKILL.md +95 -16
  169. package/dist/global-skills/neon-functions/SKILL.md +242 -152
  170. package/dist/global-skills/neon-functions/references/ai-sdk.md +9 -3
  171. package/dist/global-skills/neon-functions/references/mastra-studio.md +1 -1
  172. package/dist/global-skills/neon-functions/references/mcp.md +13 -4
  173. package/dist/global-skills/neon-functions/references/sentry.md +165 -52
  174. package/dist/global-skills/neon-functions/references/sse.md +23 -6
  175. package/dist/global-skills/neon-object-storage/SKILL.md +40 -16
  176. package/dist/global-skills/neon-postgres/SKILL.md +63 -262
  177. package/dist/global-skills/neon-postgres-branches/SKILL.md +61 -50
  178. package/dist/global-skills/neon-postgres-egress-optimizer/SKILL.md +22 -3
  179. package/dist/global-skills/resend/SKILL.md +6 -6
  180. package/dist/global-skills/resend/references/automations.md +2 -2
  181. package/dist/global-skills/resend/references/broadcasts.md +11 -3
  182. package/dist/global-skills/resend/references/domains.md +25 -3
  183. package/dist/global-skills/resend/references/installation.md +7 -7
  184. package/dist/global-skills/setup-payments/SKILL.md +4 -5
  185. package/dist/global-skills/stripe-best-practices/SKILL.md +32 -7
  186. package/dist/global-skills/stripe-best-practices/references/billing.md +11 -1
  187. package/dist/global-skills/stripe-best-practices/references/payments.md +23 -2
  188. package/dist/global-skills/stripe-best-practices/references/security.md +21 -11
  189. package/dist/global-skills/stripe-best-practices/references/tax.md +116 -11
  190. package/dist/global-skills/supabase/CHANGELOG.md +25 -0
  191. package/dist/global-skills/supabase/SKILL.md +5 -1
  192. package/dist/global-skills/supabase-postgres-best-practices/CHANGELOG.md +30 -0
  193. package/dist/global-skills/supabase-postgres-best-practices/SKILL.md +1 -1
  194. package/dist/global-skills/use-kit-mcp/SKILL.md +5 -5
  195. package/dist/global-skills/use-railway/SKILL.md +4 -4
  196. package/dist/global-skills/use-railway/references/iac.md +206 -57
  197. package/dist/global-skills/use-railway/scripts/railway-api.sh +7 -2
  198. package/dist/global-skills/xcode-project-setup/SKILL.md +2 -0
  199. package/package.json +12 -9
  200. package/LICENSE.md +0 -47
  201. package/dist/global-skills/eas-workflows/scripts/validate.js +0 -84
  202. package/dist/global-skills/expo-skill-feedback/scripts/skill-feedback.cjs +0 -118
  203. package/dist/global-skills/neon-functions/references/hono-websockets.md +0 -145
@@ -1,15 +1,13 @@
1
1
  # Production-Ready Serverless on AWS
2
2
 
3
- Quick-reference for shipping Lambda workloads to production. Covers the pre-deployment checklist, architecture trade-offs, and operational patterns for production traffic.
3
+ Pre-deployment checklist, architecture trade-offs, and operational patterns. Concise on purpose — the value here is the structured checklist and opinionated defaults, not API syntax.
4
4
 
5
5
  ## Contents
6
6
 
7
7
  - [Production readiness checklist](#production-readiness-checklist)
8
8
  - [Architecture decisions](#architecture-decisions)
9
9
  - [Observability](#observability)
10
- - [Security hardening](#security-hardening)
11
- - [Testing strategies](#testing-strategies)
12
- - [Idempotency patterns](#idempotency-patterns)
10
+ - [Idempotency](#idempotency)
13
11
  - [Response streaming](#response-streaming)
14
12
  - [Anti-patterns](#anti-patterns)
15
13
 
@@ -17,365 +15,134 @@ Quick-reference for shipping Lambda workloads to production. Covers the pre-depl
17
15
 
18
16
  ## Production readiness checklist
19
17
 
20
- Walk through every item before the first production deployment.
21
-
22
18
  ### Compute
23
19
 
24
- - [ ] Memory right-sized (use AWS Lambda Power Tuning or load testing)
25
- - [ ] Timeout set explicitly (P99 + buffer, never the 3 s default)
26
- - [ ] Reserved concurrency configured to protect downstream systems
27
- - [ ] Dead-letter queue (DLQ) or on-failure destination for every async invocation
28
- - [ ] Environment variables for all config (bucket names, table names, endpoints)
29
- - [ ] Code signing enabled (if compliance requires it)
30
- - [ ] SDK clients initialized outside handler (reuse across warm invocations)
31
- - [ ] Deployment package size minimized (exclude tests, docs, unused dependencies)
20
+ - [ ] Memory right-sized (Power Tuning / load test)
21
+ - [ ] Timeout set explicitly (P99 + buffer never the 3s default)
22
+ - [ ] Reserved concurrency set to protect downstream
23
+ - [ ] DLQ / on-failure destination on every async invocation and ESM
24
+ - [ ] Config via env vars; SDK clients initialized outside the handler
25
+ - [ ] Deployment package minimized (exclude tests, docs, unused deps)
32
26
 
33
27
  ### Observability
34
28
 
35
- - [ ] Structured JSON logging via Powertools Logger
36
- - [ ] X-Ray active tracing enabled
37
- - [ ] Custom metrics emitted via Embedded Metric Format (EMF)
38
- - [ ] CloudWatch Alarms on Errors, Throttles, Duration P99, IteratorAge, ConcurrentExecutions, DLQ depth
39
- - [ ] Log retention policy set — do not leave at unlimited
40
- - [ ] Correlation IDs propagated to downstream services
41
- - [ ] Lambda Insights enabled for system-level metrics (CPU, memory, network)
29
+ - [ ] Structured JSON logging (Powertools Logger) + correlation IDs propagated
30
+ - [ ] X-Ray active tracing
31
+ - [ ] Custom metrics via EMF
32
+ - [ ] Alarms on Errors, Throttles, Duration P99, IteratorAge, ConcurrentExecutions, DLQ depth (see below)
33
+ - [ ] Log retention set — **not** unlimited
34
+ - [ ] Log group encryption with customer managed KMS key when compliance requires it
35
+ - [ ] Lambda Insights enabled
42
36
 
43
37
  ### Security
44
38
 
45
- - [ ] One IAM execution role per function, scoped to exact resource ARNs
46
- - [ ] No secrets in environment variablesuse Secrets Manager / SSM with caching
47
- - [ ] Input validation on every event payload (JSON Schema, Zod, Pydantic)
48
- - [ ] VPC placement only when required (RDS, ElastiCache); VPC endpoints for AWS services
49
- - [ ] GuardDuty Lambda Protection enabled
50
- - [ ] Security Hub Lambda controls enabled
51
- - [ ] Dependency scanning in CI (`npm audit`, `pip-audit`, Snyk)
52
- - [ ] Amazon Inspector Lambda scanning enabled
39
+ - [ ] One IAM role per function, scoped to exact resource ARNs
40
+ - [ ] No secrets in env vars — Secrets Manager / SSM (SecureString) with Powertools caching
41
+ - [ ] Input validation at the handler boundary (Zod / Pydantic / Powertools Validation)
42
+ - [ ] VPC only when required (RDS, ElastiCache); VPC endpoints for AWS services
43
+ - [ ] GuardDuty Lambda Protection, Security Hub Lambda controls, Inspector Lambda scanning, CI dependency scanning
53
44
  - [ ] Function URLs use `AWS_IAM` auth (not `NONE`) in production
45
+ - [ ] SQS queues use SSE-KMS for encryption at rest when compliance requires customer managed keys (SSE-SQS is enabled by default)
46
+ - [ ] DynamoDB tables use customer managed KMS keys when compliance requires key control (AWS owned encryption is enabled by default)
47
+ - [ ] Enforce HTTPS-only access with `aws:SecureTransport` condition in resource policies (S3 buckets, SQS queues)
54
48
 
55
49
  ### Reliability
56
50
 
57
- - [ ] Every handler is idempotent
58
- - [ ] Partial batch failure reporting enabled (SQS, Kinesis, DynamoDB Streams)
59
- - [ ] `BisectBatchOnFunctionError` enabled for stream sources (isolates poison records)
60
- - [ ] Retry config tuned `MaximumRetryAttempts`, `MaximumEventAgeInSeconds`
61
- - [ ] Circuit breakers on downstream HTTP calls
62
- - [ ] Reserved concurrency = 0 documented as emergency kill switch
63
- - [ ] Graceful error handling — catch, log, and return meaningful errors (no unhandled exceptions)
51
+ - [ ] Every handler idempotent
52
+ - [ ] Partial batch failure reporting (SQS, Kinesis, DynamoDB Streams)
53
+ - [ ] `BisectBatchOnFunctionError` for stream sources
54
+ - [ ] Retry config tuned (`MaximumRetryAttempts`, `MaximumEventAgeInSeconds`)
55
+ - [ ] Reserved concurrency = 0 documented as the emergency kill switch
56
+ - [ ] No unhandled exceptions catch, log, return meaningful errors
64
57
 
65
58
  ### Deployment
66
59
 
67
- - [ ] Aliases + weighted traffic shifting (or CodeDeploy canary/linear)
68
- - [ ] Rollback alarms wired into the deployment pipeline
69
- - [ ] All infrastructure defined in code (CDK, SAM, or CloudFormation)
70
- - [ ] Separate AWS accounts for dev, staging, production
71
- - [ ] Automated smoke tests run post-deployment before full traffic shift
72
- - [ ] Pre-traffic hooks (BeforeAllowTraffic) validate function health before shifting
60
+ - [ ] Aliases + weighted shifting (or CodeDeploy canary/linear) with rollback alarms
61
+ - [ ] All infra in code (CDK/SAM/CloudFormation)
62
+ - [ ] Separate accounts for dev/staging/prod
63
+ - [ ] Post-deploy smoke tests + pre-traffic hooks before full shift
73
64
 
74
65
  ---
75
66
 
76
67
  ## Architecture decisions
77
68
 
78
- ### Monolith Lambda vs micro-Lambda
79
-
80
- | Aspect | Lambdalith (single function) | Micro-Lambda (function per route) |
81
- |---|---|---|
82
- | Cold starts | One function to warm; larger package | Many functions; smaller, faster init |
83
- | IAM granularity | Single broad role | Per-function least-privilege |
84
- | Deployment | Everything together; simpler CI/CD | Independent; more pipeline complexity |
85
- | Observability | One log group; harder per-route metrics | Per-function metrics, alarms, logs |
86
- | Scaling | Single concurrency pool | Independent scaling + reserved concurrency per function |
87
- | DX | Familiar Express/FastAPI style | More AWS-native; requires IaC discipline |
88
-
89
- **Guidance**: Prefer micro-Lambda for greenfield (least privilege, independent scaling, granular observability). Use Lambdalith when migrating existing Express/FastAPI apps or when team size makes deployment simplicity more valuable than granularity.
90
-
91
- ### Function URLs vs API Gateway
69
+ ### Lambdalith vs micro-Lambda
92
70
 
93
- | Feature | Function URLs | API Gateway (HTTP API) | API Gateway (REST API) |
94
- |---|---|---|---|
95
- | Auth | IAM only (or in-code) | IAM, JWT, Lambda authorizers | IAM, Cognito, Lambda authorizers, API keys |
96
- | Rate limiting | None built-in | Built-in throttling | Throttling + usage plans |
97
- | Response streaming | Yes (native) | No | Yes (proxy integration) |
98
- | Custom domains | Via CloudFront | Built-in | Built-in |
99
- | WAF | No (use CloudFront) | No (use CloudFront) | Yes |
100
- | Request validation | None | None | JSON Schema |
101
- | Caching | Via CloudFront | None | Built-in |
102
- | WebSocket | No | No | No (separate WebSocket API required) |
103
-
104
- **Use Function URLs** for: internal service-to-service (IAM auth), Lambdalith + CloudFront, streaming, webhook receivers.
105
-
106
- **Use API Gateway** for: public APIs needing rate limiting, JWT/Cognito auth, multi-function path routing, WAF without CloudFront.
71
+ Prefer **micro-Lambda** (function per route) for greenfield: per-function least-privilege IAM, independent scaling + reserved concurrency, granular observability, smaller/faster cold starts. Use a **Lambdalith** when migrating an existing Express/FastAPI app or when a small team values deployment simplicity over granularity.
107
72
 
108
73
  ### Reserved vs Provisioned Concurrency
109
74
 
110
- | Aspect | Reserved Concurrency | Provisioned Concurrency |
111
- |---|---|---|
112
- | Purpose | Guarantee capacity + protect downstream | Eliminate cold starts |
113
- | Cold starts | Still possible | Eliminated (pre-warmed) |
114
- | Throttling | Throttles at the limit | Spills to on-demand beyond provisioned |
115
- | Use case | Protect a database; guarantee capacity | Latency-sensitive APIs; payment processing |
116
-
117
- Decision flow:
118
-
119
- 1. **Need to limit scaling** → Reserved concurrency
120
- 2. **Need to eliminate cold starts** → Provisioned concurrency (try SnapStart first — no additional cost for Java; caching + restore charges for Python/.NET)
121
- 3. **Need both** → Set provisioned ≤ reserved; reserved acts as the ceiling
75
+ Reserved = guarantee capacity + protect downstream (cold starts still possible, throttles at the limit). Provisioned = eliminate cold starts (spills to on-demand beyond the count). Need both → provisioned ≤ reserved. Try **SnapStart** before Provisioned for Java/Python 3.12+/.NET 8+ (no cost for Java). See [concurrency.md](concurrency.md).
122
76
 
123
77
  ---
124
78
 
125
79
  ## Observability
126
80
 
127
- ### Powertools setup (Python / TypeScript / Java / .NET)
128
-
129
- **Logger** — structured JSON, correlation IDs injected automatically, log level via env var.
130
-
131
- **Tracer** — wraps X-Ray SDK; auto-captures AWS SDK calls, HTTP requests, handler. Add custom subsegments for critical paths. Annotate traces with business keys (customer ID, order ID) for filtering.
132
-
133
- **Metrics** — emits via Embedded Metric Format. Zero latency impact.
134
-
135
- ### EMF vs PutMetricData
136
-
137
- | | EMF (Powertools Metrics) | `PutMetricData` API |
138
- |---|---|---|
139
- | Latency impact | Zero — writes to stdout | Synchronous API call (~5–20 ms) |
140
- | Complexity | One-liner with Powertools | Manual batching, error handling |
141
- | Recommendation | **Use this** | Avoid in hot paths |
142
-
143
- ### Minimum alarm set
144
-
145
- Set these six alarms on every production function:
146
-
147
- | Alarm | Metric | Threshold | Period | Why |
148
- |---|---|---|---|---|
149
- | Error rate | `Errors / Invocations` | > 1 % | 5 min | Catch bugs and upstream failures |
150
- | Throttles | `Throttles` | > 0 | 5 min | Concurrency limit hit |
151
- | Duration P99 | `Duration` P99 | > 80 % of timeout | 5 min | Catch slow functions before timeout |
152
- | Iterator age | `IteratorAge` | > 60 s | 5 min | Stream processing falling behind |
153
- | Concurrent executions | `ConcurrentExecutions` | > 80 % of reserved | 5 min | Approaching throttle threshold |
154
- | DLQ depth | SQS `ApproximateNumberOfMessagesVisible` | > 0 | 5 min | Failed messages accumulating |
155
-
156
- ### Log retention
157
-
158
- Set retention when creating log groups. Defaults to "never expire" — storage accumulates continuously. Choose a retention period based on your compliance and debugging needs.
159
-
160
- ---
161
-
162
- ## Security hardening
163
-
164
- ### One role per function
165
-
166
- Never share IAM roles across functions. Scope every policy to specific resource ARNs:
167
-
168
- ```yaml
169
- # Good
170
- Effect: Allow
171
- Action: dynamodb:PutItem
172
- Resource: arn:aws:dynamodb:us-east-1:123456789012:table/OrdersTable
173
-
174
- # Bad
175
- Effect: Allow
176
- Action: dynamodb:*
177
- Resource: "*"
178
- ```
179
-
180
- Use IAM Access Analyzer to identify unused permissions and generate least-privilege policies.
181
-
182
- ### Secrets management
183
-
184
- - Store in **Secrets Manager** or **SSM Parameter Store** (SecureString)
185
- - Cache in the execution environment with **Powertools Parameters** (avoids API call per invocation)
186
- - Rotate automatically via Secrets Manager rotation Lambdas
187
- - Environment variables are visible in the Lambda console and API — never put secrets there
81
+ Use Powertools **Logger** (structured JSON, auto correlation IDs), **Tracer** (wraps X-Ray, auto-captures SDK/HTTP calls; annotate traces with business keys), **Metrics** (EMF — zero latency, writes to stdout vs ~5–20ms for synchronous `PutMetricData`; avoid `PutMetricData` in hot paths).
188
82
 
189
- ### Input validation
83
+ ### Minimum alarm set (every production function)
190
84
 
191
- Validate at the handler boundary before business logic runs:
192
-
193
- | Language | Library |
194
- |---|---|
195
- | TypeScript | Zod, io-ts, JSON Schema |
196
- | Python | Pydantic, Powertools Validation (JSON Schema) |
197
- | Java | Bean Validation (JSR 380), JSON Schema |
198
-
199
- Powertools Validation supports envelope extraction for API Gateway, SQS, EventBridge, etc.
200
-
201
- ### VPC: endpoints over NAT Gateway
202
-
203
- If your function must be in a VPC, use **VPC endpoints** for AWS service access instead of NAT Gateway:
204
-
205
- | | VPC Endpoint | NAT Gateway |
206
- |---|---|---|
207
- | Latency | Lower (stays on AWS backbone) | Higher (extra hop) |
208
-
209
- Create endpoints for: DynamoDB (gateway), S3 (gateway), SQS, Secrets Manager, SSM, KMS.
210
-
211
- ---
212
-
213
- ## Testing strategies
214
-
215
- ### The serverless testing pyramid (inverted)
216
-
217
- ```
218
- ┌─────────────┐
219
- │ E2E Tests │ Few — full workflow verification
220
- ├─────────────┤
221
- │ Integration │ Many — THIS IS THE MOST VALUABLE LAYER
222
- │ (in cloud) │ Test real service interactions
223
- ├─────────────┤
224
- │ Unit Tests │ Fast — pure business logic only
225
- └─────────────┘
226
- ```
227
-
228
- Serverless apps are primarily about service integrations, not complex business logic. Integration tests in the cloud detect the most impactful defects.
229
-
230
- ### Structure code for testability
231
-
232
- ```
233
- handler (thin adapter)
234
- → extract + validate event
235
- → call business logic (pure functions — unit test these)
236
- → call AWS services (integration test these in the cloud)
237
- ```
238
-
239
- ### What to test where
240
-
241
- | Layer | What | How |
242
- |---|---|---|
243
- | Unit | Business logic (calculations, transforms, validation) | Local, fast, mocked dependencies |
244
- | Integration | Service contracts (DynamoDB reads/writes, SQS send/receive, IAM permissions) | Deploy to AWS, test against real services |
245
- | E2E | Full workflows (API → Lambda → DynamoDB → Stream → Lambda → SQS) | Dedicated staging environment; poll for async side effects |
246
-
247
- ### Fast iteration
85
+ | Alarm | Metric | Threshold | Why |
86
+ |---|---|---|---|
87
+ | Error rate | `Errors / Invocations` | > 1% | Bugs / upstream failures |
88
+ | Throttles | `Throttles` | > 0 | Concurrency limit hit |
89
+ | Duration P99 | `Duration` P99 | > 80% of timeout | Catch slow functions before timeout |
90
+ | Iterator age | `IteratorAge` | > 60s | Stream processing falling behind |
91
+ | Concurrent executions | `ConcurrentExecutions` | > 80% of reserved | Approaching throttle threshold |
92
+ | DLQ depth | SQS `ApproximateNumberOfMessagesVisible` | > 0 | Failed messages accumulating |
248
93
 
249
- - **`sam sync`** hot-deploys code changes to AWS in seconds
250
- - **`cdk watch`** — watches for file changes and auto-deploys
251
- - Each developer gets an isolated test stack (separate account or prefixed stack name)
94
+ Set **log retention** when creating log groups the default is "never expire."
252
95
 
253
- ### What NOT to do
96
+ ### Testing
254
97
 
255
- - Don't rely on LocalStack / DynamoDB Local as primary testing they diverge from real AWS (IAM, quotas, error codes)
256
- - Don't mock AWS SDK calls for integration tests — you'll miss permission and config issues
257
- - Don't skip cloud testing because "it's slow" — use `sam sync` / `cdk watch`
98
+ Serverless apps are mostly about **service integrations**, not complex business logic — so the **integration layer (tested in the cloud) is the most valuable**, with few unit tests (pure logic) and few E2E. Structure handlers as thin adapters calling pure functions. Don't rely on LocalStack/DynamoDB Local as primary testing (they diverge on IAM, quotas, error codes); don't mock AWS SDK calls for integration tests. Iterate fast with `sam sync` / `cdk watch`; give each developer an isolated stack.
258
99
 
259
100
  ---
260
101
 
261
- ## Idempotency patterns
262
-
263
- Lambda guarantees **at-least-once** execution. Duplicates happen from: async retries, SQS visibility timeout expiry, stream shard replays, client retries on timeout, Step Functions task retries.
264
-
265
- ### Powertools Idempotency utility
266
-
267
- Uses DynamoDB to track processed events. Available for Python, TypeScript, Java, .NET.
268
-
269
- **Python:**
270
-
271
- ```python
272
- from aws_lambda_powertools.utilities.idempotency import (
273
- DynamoDBPersistenceLayer, idempotent
274
- )
275
-
276
- persistence = DynamoDBPersistenceLayer(table_name="IdempotencyTable")
277
-
278
- @idempotent(persistence_store=persistence)
279
- def handler(event, context):
280
- payment = process_payment(event)
281
- return {"statusCode": 200, "body": payment}
282
- ```
283
-
284
- **TypeScript:**
285
-
286
- ```typescript
287
- import { makeIdempotent } from "@aws-lambda-powertools/idempotency";
288
- import { DynamoDBPersistenceLayer } from "@aws-lambda-powertools/idempotency/dynamodb";
289
-
290
- const persistence = new DynamoDBPersistenceLayer({ tableName: "IdempotencyTable" });
102
+ ## Idempotency
291
103
 
292
- export const handler = makeIdempotent(async (event) => {
293
- const payment = await processPayment(event);
294
- return { statusCode: 200, body: JSON.stringify(payment) };
295
- }, { persistenceStore: persistence });
296
- ```
104
+ Lambda guarantees **at-least-once** duplicates come from async retries, SQS visibility expiry, stream replays, client retries, Step Functions task retries. Use the **Powertools Idempotency** utility (Python/TS/Java/.NET), backed by a DynamoDB table with TTL.
297
105
 
298
- ### DynamoDB table design
106
+ Table: `id` (hash of idempotency key) + `status` (INPROGRESS/COMPLETED/EXPIRED), `data` (cached response), `expiration` (TTL).
299
107
 
300
- ```
301
- Table: IdempotencyTable
302
- PK: id (String) — hash of the idempotency key
303
- Attributes:
304
- status: INPROGRESS | COMPLETED | EXPIRED
305
- data: cached response payload
306
- expiration: TTL epoch timestamp
307
- TTL attribute: expiration
308
- ```
108
+ Idempotency key by source:
309
109
 
310
- ### Choosing the idempotency key
311
-
312
- | Event source | Key |
110
+ | Source | Key |
313
111
  |---|---|
314
112
  | SQS | `messageId` |
315
- | EventBridge | `detail.id` or composite of event fields |
113
+ | EventBridge | `detail.id` or composite |
316
114
  | DynamoDB Streams | `eventID` |
317
- | API Gateway / Function URL | `Idempotency-Key` header or request body hash |
115
+ | API Gateway / Function URL | `Idempotency-Key` header or body hash |
318
116
  | Step Functions | Execution ID + task token |
319
117
 
320
- ### TTL for cleanup
118
+ TTL how long duplicates can arrive (API retries ~1h; SQS ≈ `maxReceiveCount` × visibility; stream replays ~24h).
321
119
 
322
- Set TTL based on how long duplicates can arrive. Typical values:
120
+ ---
323
121
 
324
- - API retries: 1 hour
325
- - SQS retries: match the queue's `maxReceiveCount` × visibility timeout
326
- - Stream replays: 24 hours (Kinesis retention default)
122
+ ## Response streaming
327
123
 
328
- DynamoDB automatically deletes expired items (typically within a few days of TTL expiry).
124
+ Use for payloads > 6 MB (buffered limit), TTFB-sensitive responses, SSE, LLM token streaming, or large file generation.
329
125
 
330
- ---
126
+ - **Function URLs** are simplest; REST API also supports streaming (proxy, STREAM mode); **HTTP API does not**.
127
+ - **200 MB** response limit; **2 MBps** cap after the first 6 MB.
128
+ - Billed for full duration even if the client disconnects.
129
+ - Node.js has native support (`awslambda.streamifyResponse` + `awslambda.HttpResponseStream.from`); other runtimes need a custom runtime or Lambda Web Adapter.
130
+ - **Not supported for VPC-attached functions via Function URL** — use the `InvokeWithResponseStream` API instead.
331
131
 
332
- ## Response streaming
132
+ Don't stream small JSON (< 6 MB) — buffered is simpler.
333
133
 
334
- ### When to use
134
+ ---
335
135
 
336
- | Use case | Why streaming helps |
337
- |---|---|
338
- | Large payloads (> 6 MB) | Buffered limit is 6 MB; streaming supports up to 200 MB |
339
- | TTFB-sensitive responses | Client sees partial data immediately (HTML shell, then content) |
340
- | Server-sent events (SSE) | Real-time updates to browser clients |
341
- | LLM / AI token streaming | Stream tokens as generated (conversational AI-style) |
342
- | Large file generation | CSV/PDF rows streamed as produced |
343
-
344
- ### Constraints
345
-
346
- - **Function URLs** are simplest for streaming. REST API also supports streaming via proxy integration with STREAM transfer mode. HTTP API does **not** support streaming.
347
- - **200 MB** response limit
348
- - **2 MBps** bandwidth cap after the first 6 MB
349
- - Billed for full function duration even if client disconnects
350
- - Node.js has native support; other runtimes use custom runtime or Lambda Web Adapter
351
- - **Function URL streaming is NOT supported for VPC-attached functions.** Use the `InvokeWithResponseStream` API as an alternative.
352
-
353
- ### Node.js example
354
-
355
- ```javascript
356
- export const handler = awslambda.streamifyResponse(
357
- async (event, responseStream, context) => {
358
- const metadata = {
359
- statusCode: 200,
360
- headers: { "Content-Type": "text/html" },
361
- };
362
- responseStream = awslambda.HttpResponseStream.from(responseStream, metadata);
363
-
364
- responseStream.write("<html><body>");
365
- for (const chunk of generateContent()) {
366
- responseStream.write(chunk);
367
- }
368
- responseStream.write("</body></html>");
369
- responseStream.end();
370
- }
371
- );
372
- ```
373
-
374
- ### When NOT to use
375
-
376
- - Small JSON responses (< 6 MB) — buffered is simpler
377
- - When you need API Gateway features (rate limiting, caching, WAF) without CloudFront
378
- - VPC-based functions needing Function URL streaming (use `InvokeWithResponseStream` API instead)
136
+ ## Anti-patterns
137
+
138
+ - **Lambda calling Lambda synchronously** doubles latency, tight coupling, fragile error handling. Decouple via SQS, or use Step Functions when you need the result.
139
+ - **Unintentional monolithic handler** — routing stuffed into one function without weighing trade-offs prevents independent scaling and broadens IAM blast radius. Choose Lambdalith vs micro-Lambda deliberately (see above).
140
+ - **Secrets in env vars** visible in console/API, 4 KB total cap. Use Secrets Manager with Powertools caching.
141
+ - **Skipping idempotency** at-least-once delivery causes duplicate records.
142
+ - **VPC when not needed** adds cold-start latency. Only for private resources; use VPC endpoints for AWS services.
143
+ - **Default 3s timeout** — legitimate requests fail silently. Set SDK/HTTP client timeouts shorter than the Lambda timeout for meaningful errors.
144
+ - **Missing DLQ** — failed async invocations / ESM messages are discarded silently.
145
+ - **Log retention = forever** — storage accumulates continuously.
379
146
 
380
147
  ---
381
148
 
@@ -384,110 +151,6 @@ export const handler = awslambda.streamifyResponse(
384
151
  - [AWS Lambda Best Practices](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
385
152
  - [Lambda Concurrency and Scaling](https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html)
386
153
  - [Response Streaming](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html)
387
- - [How to Test Serverless Functions](https://docs.aws.amazon.com/lambda/latest/dg/testing-guide.html)
154
+ - [Testing serverless functions](https://docs.aws.amazon.com/lambda/latest/dg/testing-guide.html)
388
155
  - [Serverless Applications Lens — Well-Architected](https://docs.aws.amazon.com/wellarchitected/latest/serverless-applications-lens/welcome.html)
389
156
  - [Powertools for AWS Lambda](https://docs.powertools.aws.dev/lambda/)
390
-
391
- ---
392
-
393
- ## Anti-patterns
394
-
395
- Common mistakes that cause production issues in serverless applications. Each pairs the problem with the correct alternative.
396
-
397
- ### Avoid: Lambda calling Lambda synchronously
398
-
399
- Synchronous Lambda-to-Lambda invocation doubles latency, creates tight coupling, and makes error handling fragile.
400
-
401
- ```python
402
- # BAD: Direct synchronous invocation
403
- lambda_client.invoke(FunctionName='downstream', InvocationType='RequestResponse', Payload=json.dumps(event))
404
- ```
405
-
406
- ### Instead: Use Step Functions or SQS
407
-
408
- ```python
409
- # GOOD: Decouple via SQS
410
- sqs.send_message(QueueUrl=QUEUE_URL, MessageBody=json.dumps(event))
411
- ```
412
-
413
- Or use Step Functions for orchestration when you need the result.
414
-
415
- ---
416
-
417
- ### Avoid: Monolithic handler without intentional design
418
-
419
- Routing logic stuffed into a single handler without considering trade-offs prevents independent scaling, broadens IAM blast radius, and increases cold start times.
420
-
421
- ```python
422
- # BAD: One function handling all routes without considering trade-offs
423
- def handler(event, context):
424
- path = event['path']
425
- if path == '/users': return handle_users(event)
426
- elif path == '/orders': return handle_orders(event)
427
- elif path == '/products': return handle_products(event)
428
- ```
429
-
430
- ### Instead: Choose deliberately
431
-
432
- For greenfield projects, prefer one function per route (least privilege, independent scaling, granular observability). For migrations from Express/FastAPI or small teams prioritizing deployment simplicity, a Lambdalith is a valid choice — see [Architecture decisions](#architecture-decisions) for trade-offs.
433
-
434
- ---
435
-
436
- ### Avoid: Secrets in environment variables
437
-
438
- Visible in console and API, 4 KB total limit for all environment variables combined.
439
-
440
- ```python
441
- # BAD: Secret in env var
442
- db_password = os.environ['DB_PASSWORD']
443
- ```
444
-
445
- ### Instead: Use Secrets Manager with Powertools caching
446
-
447
- ```python
448
- # GOOD: Cached secret retrieval
449
- from aws_lambda_powertools.utilities import parameters
450
- db_password = parameters.get_secret("my-db-secret", max_age=300)
451
- ```
452
-
453
- ---
454
-
455
- ### Avoid: Skipping idempotency
456
-
457
- Lambda delivers at-least-once; duplicates cause duplicate records.
458
-
459
- ### Instead: Use Powertools Idempotency
460
-
461
- ```python
462
- from aws_lambda_powertools.utilities.idempotency import idempotent, DynamoDBPersistenceLayer
463
-
464
- persistence = DynamoDBPersistenceLayer(table_name="IdempotencyTable")
465
-
466
- @idempotent(persistence_store=persistence)
467
- def handler(event, context):
468
- return process_payment(event)
469
- ```
470
-
471
- ---
472
-
473
- ### Avoid: VPC when not needed
474
-
475
- Adds cold start latency. Only attach Lambda to a VPC for private resources (RDS, ElastiCache, Elasticsearch). Use VPC endpoints for AWS service access instead.
476
-
477
- ---
478
-
479
- ### Avoid: Default 3s timeout
480
-
481
- Legitimate requests fail silently. Set timeout based on load-test P99 + buffer. Set SDK/HTTP client timeouts shorter than Lambda timeout to get meaningful errors instead of generic timeouts.
482
-
483
- ---
484
-
485
- ### Avoid: Missing DLQ
486
-
487
- Failed async invocations and event source messages are discarded without notification. Configure dead-letter queues on all async invocations and event source mappings.
488
-
489
- ---
490
-
491
- ### Avoid: CloudWatch Logs retention = forever
492
-
493
- Storage accumulates continuously. Set a retention period — do not leave at unlimited.