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,711 +1,184 @@
1
1
  # Serverless Troubleshooting Reference
2
2
 
3
- Actionable error lookup tables: exact error string cause fix with CLI commands.
4
-
5
- ## Contents
6
-
7
- - [Quick fixes](#quick-fixes)
8
- - [Lambda Error Lookup](#lambda-error-lookup)
9
- - [API Gateway Error Lookup](#api-gateway-error-lookup)
10
- - [Step Functions Error Lookup](#step-functions-error-lookup)
11
- - [SAM/CDK Error Lookup](#samcdk-error-lookup)
12
- - [Timeout Debugging](#timeout-debugging)
13
- - [OOM Debugging](#out-of-memory-oom-debugging)
14
- - [Throttling Diagnosis](#throttling-diagnosis)
15
- - [CloudWatch Logs Insights Queries](#cloudwatch-logs-insights-queries)
16
- - [X-Ray Tracing](#x-ray-tracing)
17
-
18
- ---
3
+ Error cause fix, focused on non-obvious gotchas and exact CLI commands. The five most common fixes are first.
19
4
 
20
5
  ## Quick fixes
21
6
 
22
- ### 502 Bad Gateway from API Gateway
23
- Lambda proxy integration requires `{ statusCode: int, headers: {}, body: "string" }`.
24
- The `body` must be a string (`JSON.stringify()`), not an object. API Gateway returns 502 when it cannot parse the Lambda response the function ran successfully but the response shape was wrong. Note: string statusCode (e.g., "200") is silently coerced to integer, and missing statusCode defaults to 200.
25
-
26
- ### CORS errors
27
- With Lambda proxy integration, Lambda must return CORS headers — the API Gateway console "Enable CORS" button does not work for Lambda proxy integration. Add `Access-Control-Allow-Origin`, `Access-Control-Allow-Methods`, `Access-Control-Allow-Headers` to every Lambda response including errors. For HTTP API, use the built-in `CorsConfiguration` instead. CORS is enforced by the browser, not the server — missing headers cause the browser to block the response even though the API call succeeded.
28
-
29
- ### Lambda timeout + API Gateway 504
30
- API Gateway has a hard integration timeout: REST API default 29s (configurable 50ms–29s; Regional/private APIs can request higher), HTTP API max 30s (can be lowered, cannot be raised). This is independent of Lambda's 15-min limit. The 504 means API Gateway gave up waiting, not that Lambda failed. For long operations, return 202 immediately, process via SQS or Step Functions, poll or use WebSocket for results.
31
-
32
- ### VPC Lambda cannot reach internet
33
- Lambda in a VPC needs a **private** subnet + NAT Gateway in a **public** subnet. Placing Lambda in a public subnet does NOT give it a public IP — Lambda never gets a public IP regardless of subnet type because Lambda's network interface is managed by the service and doesn't support public IP assignment. For AWS services only, use VPC endpoints (free for S3 and DynamoDB gateway endpoints).
34
-
35
- ### ImportModuleError / MODULE_NOT_FOUND
36
- Handler path doesn't match file structure, or dependencies weren't bundled. Lambda extracts code to `/var/task` and layers to `/opt` — if the handler path doesn't match the file's location relative to `/var/task`, the runtime can't find it. Python: `pip install -r requirements.txt -t ./package --platform manylinux2014_x86_64 --only-binary=:all:`. Node: verify `exports.handler` exists and `node_modules` is included. Use `sam build` to handle cross-platform packaging automatically.
7
+ - **502 Bad Gateway (proxy):** Lambda response must be `{ statusCode: int, headers: {}, body: "string" }`. `body` must be a `JSON.stringify`'d **string**, not an object. The function ran fine — only the response shape was wrong. (String statusCode is coerced. Under **HTTP API** payload format 2.0 a missing statusCode defaults to 200, but under **REST** proxy a missing statusCode is itself a malformed response and triggers the 502.)
8
+ - **CORS errors:** under proxy integration the **Lambda** returns CORS headers on **every** response including errors; the console "Enable CORS" button doesn't apply. HTTP API: use `CorsConfiguration`. CORS is browser-enforced — the API call itself succeeded. **Never use `AllowOrigin: '*'` in production** — wildcard CORS is a security risk (CWE-942); specify your exact domain (e.g. `https://app.example.com`).
9
+ - **504 from API Gateway:** integration timeout (REST 29s default; HTTP 30s max), independent of Lambda's 15-min limit. For long ops: return 202 immediately, process via SQS/Step Functions, poll or use WebSocket.
10
+ - **VPC Lambda can't reach internet:** needs **private** subnet + NAT Gateway in a **public** subnet. A public subnet does NOT give Lambda a public IP. For AWS services use VPC endpoints (free for S3/DynamoDB gateway endpoints).
11
+ - **ImportModuleError / MODULE_NOT_FOUND:** handler path doesn't match file structure, or deps weren't bundled for the right platform. Python: `pip install -r requirements.txt -t ./package --platform manylinux2014_x86_64 --only-binary=:all:`. Use `sam build` for cross-platform packaging.
37
12
 
38
13
  ---
39
14
 
40
- ## Lambda Error Lookup
41
-
42
- ### Runtime.ImportModuleError
43
-
44
- **Error:** `Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'lambda_function'`
45
- **Cause:** Handler references a module missing from the deployment package.
46
-
47
- ```bash
48
- pip install -r requirements.txt -t ./package
49
- cd package && zip -r ../deployment.zip . && cd .. && zip deployment.zip lambda_function.py
50
- # Or: sam build && sam deploy
51
- ```
52
-
53
- ### Runtime.HandlerNotFound
54
-
55
- **Error:** `Runtime.HandlerNotFound: Handler 'handler' missing on module 'function'`
56
- **Cause:** File exists but function/method name doesn't match handler setting.
57
-
58
- ```bash
59
- aws lambda update-function-configuration --function-name my-func --handler app.lambda_handler
60
- # Python: file.function Node: file.export Java: package.Class::method
61
- ```
62
-
63
- ### Task timed out
64
-
65
- **Error:** `Task timed out after 3.00 seconds`
66
- **Cause:** Execution exceeded configured timeout. Slow downstream calls, low memory/CPU, or VPC delays.
67
-
68
- ```bash
69
- aws lambda update-function-configuration --function-name my-func --timeout 30
70
- aws lambda update-function-configuration --function-name my-func --memory-size 512
71
- # Set SDK/HTTP timeouts shorter than Lambda timeout for meaningful errors
72
- ```
73
-
74
- ### Runtime.OutOfMemory (OOM)
75
-
76
- **Error:** `Runtime.OutOfMemory: ... signal: killed` or `Runtime exited without providing a reason`
77
- **Cause:** Function exceeded allocated memory — kernel sent SIGKILL.
78
-
79
- ```bash
80
- # Check REPORT lines: Max Memory Used vs Memory Size
81
- aws lambda update-function-configuration --function-name my-func --memory-size 1024
82
- # Stream large files instead of loading into memory; bound global caches
83
- ```
84
-
85
- ### AccessDeniedException
86
-
87
- **Error:** `AccessDeniedException: ... not authorized to perform: lambda:InvokeFunction`
88
- **Cause:** Calling IAM principal lacks `lambda:InvokeFunction` permission.
89
-
90
- ```bash
91
- aws lambda add-permission --function-name my-func \
92
- --statement-id AllowInvoke --action lambda:InvokeFunction \
93
- --principal s3.amazonaws.com --source-arn arn:aws:s3:::my-bucket
94
- ```
95
-
96
- ### TooManyRequestsException
97
-
98
- **Error:** `TooManyRequestsException: Rate Exceeded.`
99
- **Cause:** Function exceeded account concurrency limit (default 1,000).
100
-
101
- ```bash
102
- aws lambda get-account-settings
103
- aws service-quotas request-service-quota-increase \
104
- --service-code lambda --quota-code L-B99A9384 --desired-value 3000
105
- aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 100
106
- ```
15
+ ## Lambda errors (gotchas)
107
16
 
108
- ### InvalidParameterValueException (size)
17
+ ### Function URL 403 Forbidden (`AuthType=NONE`)
109
18
 
110
- **Error:** `Unzipped size must be smaller than 262144000 bytes`
111
- **Cause:** Package exceeds 50 MB zipped / 250 MB unzipped.
19
+ A public Function URL returns **403 Forbidden** even with `AuthType=NONE` when the resource-based policy grants only `lambda:InvokeFunctionUrl`. Invoking a Function URL **always requires both `lambda:InvokeFunctionUrl` and `lambda:InvokeFunction`** — the console and SAM add both statements automatically, but with the CLI/API you must add each yourself (two separate `add-permission` calls):
112
20
 
113
21
  ```bash
114
- find ./package -name "*.pyc" -delete && find ./package -name "*.dist-info" -type d -exec rm -rf {} +
115
- aws lambda publish-layer-version --layer-name my-deps --zip-file fileb://layer.zip --compatible-runtimes python3.13
116
- # Or upload via S3, or switch to container image packaging (10 GB limit)
117
- ```
118
-
119
- ### ETIMEDOUT (VPC)
120
-
121
- **Error:** `Error: connect ETIMEDOUT 176.32.98.189:443`
122
- **Cause:** VPC Lambda can't reach internet — missing NAT Gateway or VPC Endpoint.
22
+ # Statement 1: allow invoking via the Function URL (public)
23
+ aws lambda add-permission --function-name my-function \
24
+ --statement-id FunctionURLAllowPublicAccess \
25
+ --action lambda:InvokeFunctionUrl --principal '*' \
26
+ --function-url-auth-type NONE
123
27
 
124
- ```bash
125
- aws ec2 describe-route-tables --filters "Name=association.subnet-id,Values=subnet-xxx"
126
- aws ec2 create-route --route-table-id rtb-xxx --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-xxx
127
- # Or use VPC Endpoints for AWS services:
128
- aws ec2 create-vpc-endpoint --vpc-id vpc-xxx --service-name com.amazonaws.us-east-1.s3 --route-table-ids rtb-xxx
28
+ # Statement 2: REQUIRED — allow the underlying invoke, scoped to URL calls
29
+ aws lambda add-permission --function-name my-function \
30
+ --statement-id FunctionURLInvokeAllowPublicAccess \
31
+ --action lambda:InvokeFunction --principal '*' \
32
+ --invoked-via-function-url
129
33
  ```
130
34
 
131
- ### MODULE_NOT_FOUND
132
-
133
- **Error:** `Error: Cannot find module 'my-module'`
134
- **Cause:** Node.js dependency missing — not bundled or built on incompatible platform.
135
-
136
- ```bash
137
- npm install --production
138
- sam build --use-container # for native modules
139
- unzip -l deployment.zip | grep my-module # verify inclusion
140
- ```
35
+ The `--invoked-via-function-url` flag sets the `lambda:InvokedViaFunctionUrl` condition on statement 2, scoping it to Function URL calls so it does not open direct `Invoke` access. This 403 is **not** an org SCP/RCP block — Lambda does not support RCPs, so don't chase that path. See [Function URLs](lambda.md#function-urls) and [Lambda function URL auth](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html).
141
36
 
142
37
  ### RecursiveInvocationException
143
38
 
144
- **Error:** `RecursiveInvocationException: Recursive invocation detected`
145
- **Cause:** Function writes to a resource that triggers itself again (~16 invocations before halt).
39
+ A function writes to a resource that re-triggers it (Lambda halts after ~16 loops).
146
40
 
147
41
  ```bash
148
- # Emergency stop
42
+ # Emergency stop:
149
43
  aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 0
150
- # Fix: use separate input/output buckets or prefix filters in trigger config
44
+ # Fix: separate input/output buckets, or prefix filters in the trigger config
151
45
  ```
152
46
 
153
- ### SnapStart Errors
47
+ ### SnapStart errors
154
48
 
155
- **Error:** `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException`
156
- **Cause:** SnapStart failed during snapshot — init threw exception or uses non-snapshottable resources (e.g., open network connections).
49
+ `SnapStartException` / `SnapStartNotReadyException` / `SnapStartTimeoutException` — init threw, or it uses non-snapshottable resources (open network connections).
157
50
 
158
51
  ```bash
159
52
  aws lambda get-function --function-name my-func --query 'Configuration.SnapStart'
160
- # Java: Use CRaC hooks — beforeCheckpoint() to close connections, afterRestore() to reopen
161
- # Python: Use snapshot_restore runtime hooks to re-establish connections after restore
162
- # .NET: Use SnapshotRestore register hooks for before-snapshot and after-restore actions
53
+ # Java: CRaC hooks — beforeCheckpoint() closes connections, afterRestore() reopens
54
+ # Python: snapshot_restore runtime hooks to re-establish connections after restore
55
+ # .NET: SnapshotRestore.Register hooks for before-snapshot / after-restore
163
56
  ```
164
57
 
165
58
  ### Sandbox.Timedout
166
59
 
167
- **Error:** `Sandbox.Timedout`
168
- **Cause:** Function exceeded its timeout. In newer runtimes, this covers both init-phase and invoke-phase timeouts. A suppressed init failure consumes the invoke timeout.
169
-
170
- ```bash
171
- aws lambda update-function-configuration --function-name my-func --timeout 60 --memory-size 1024
172
- # Move heavy initialization to lazy loading inside the handler
173
- ```
60
+ Exceeded the timeout. In newer runtimes this covers **both** init-phase and invoke-phase timeouts — a suppressed init failure consumes the invoke timeout. Move heavy init to lazy loading inside the handler; raise `--timeout`/`--memory-size`.
174
61
 
175
62
  ### ENILimitReachedException
176
63
 
177
- **Error:** `ENILimitReachedException`
178
- **Cause:** VPC reached network interface quota. Lambda Hyperplane ENIs have a default quota of 500 per VPC (see lambda.md); the overall VPC ENI quota is 5,000 per region. Check which limit applies.
64
+ VPC hit its network-interface quota. Two limits can apply — the Lambda-specific Hyperplane ENI-per-VPC quota and the broader VPC ENI-per-Region quota — so check which one was reached (Service Quotas / `describe-account-attributes`).
179
65
 
180
66
  ```bash
181
67
  aws service-quotas request-service-quota-increase --service-code vpc --quota-code L-DF5E4CA3 --desired-value 10000
182
- # Consolidate functions to use same subnet + security group combinations
68
+ # Consolidate functions onto the same subnet + security group combinations
183
69
  ```
184
70
 
185
- ### InvalidZipFileException
186
-
187
- **Error:** `InvalidZipFileException: Could not unzip uploaded file.`
188
- **Cause:** Invalid ZIP or handler nested in subdirectory instead of at root.
71
+ ### TooManyRequestsException / throttling
189
72
 
190
73
  ```bash
191
- unzip -t deployment.zip # verify integrity
192
- cd my-folder && zip -r ../deployment.zip . && cd .. # files at root, not nested
74
+ aws lambda get-account-settings
75
+ aws service-quotas request-service-quota-increase --service-code lambda --quota-code L-B99A9384 --desired-value 3000
76
+ aws lambda put-function-concurrency --function-name my-func --reserved-concurrent-executions 100
193
77
  ```
194
78
 
195
- ### CodeStorageExceededException
79
+ Throttle behavior by invocation type: **Sync (API GW)** → 429 (may surface as 500); **Async (S3, SNS)** → auto-retries up to 6h; **SQS** → returns to queue, backs off; **Kinesis/DynamoDB Streams** → retries batch, blocks shard.
196
80
 
197
- **Error:** `CodeStorageExceededException: Code storage limit exceeded.`
198
- **Cause:** Account exceeded 75 GB code storage per region (all versions + layers).
81
+ ### CodeStorageExceededException
199
82
 
200
- ```bash
201
- aws lambda list-versions-by-function --function-name my-func
202
- aws lambda delete-function --function-name my-func --qualifier 1
203
- aws lambda list-layers # delete unused layers too
204
- ```
83
+ Account exceeded its per-Region code storage quota (unzipped; all versions + layers). Check the current limit with `aws service-quotas get-service-quota --service-code lambda --quota-code L-2ACBD22F` (it is adjustable and has changed over time). Delete old versions and unused layers (`aws lambda list-versions-by-function`, `delete-function --qualifier`).
205
84
 
206
85
  ---
207
86
 
208
- ## API Gateway Error Lookup
209
-
210
- ### Malformed Lambda Proxy Response (502)
87
+ ## API Gateway errors (gotchas)
211
88
 
212
- **Error:** `Malformed Lambda proxy response` → 502
213
- **Cause:** Lambda response missing required format — `body` must be a string, response must be a JSON object (not a plain string or array).
214
-
215
- ```python
216
- return {"statusCode": 200, "headers": {"Content-Type": "application/json"}, "body": json.dumps({"msg": "ok"})}
217
- ```
218
-
219
- ```javascript
220
- return { statusCode: 200, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ msg: "ok" }) };
221
- ```
222
-
223
- ### Missing Authentication Token (403)
224
-
225
- **Error:** `403 Forbidden: Missing Authentication Token`
226
- **Cause:** URL doesn't match any resource/method, or API not deployed to stage. Usually routing, not auth.
227
-
228
- ```bash
229
- aws apigateway create-deployment --rest-api-id abc123 --stage-name prod
230
- # Verify: https://{api-id}.execute-api.{region}.amazonaws.com/{stage}/{resource}
231
- ```
232
-
233
- ### Invalid Permissions on Lambda (500)
234
-
235
- **Error:** `Invalid permissions on Lambda function`
236
- **Cause:** API Gateway lacks `lambda:InvokeFunction` permission on the target function.
237
-
238
- ```bash
239
- aws lambda add-permission --function-name my-func --statement-id apigw-invoke \
240
- --action lambda:InvokeFunction --principal apigateway.amazonaws.com \
241
- --source-arn "arn:aws:execute-api:us-east-1:123456789012:api-id/*/GET/resource"
242
- ```
243
-
244
- ### Endpoint Request Timed Out (504)
245
-
246
- **Error:** `Endpoint request timed out` → 504
247
- **Cause:** Lambda didn't respond within 29s (REST) / 30s (HTTP) integration timeout.
248
-
249
- ```bash
250
- aws lambda update-function-configuration --function-name my-func --memory-size 1024
251
- # For long operations: return 202 immediately, process async, poll for results
252
- ```
253
-
254
- ### Authorizer Unauthorized (401)
255
-
256
- **Error:** `Unauthorized` (401)
257
- **Cause:** Lambda authorizer returned deny, threw error, or timed out.
258
-
259
- ```bash
260
- aws logs tail /aws/lambda/my-authorizer --since 1h --filter-pattern ERROR
261
- # Verify authorizer returns: { principalId, policyDocument: { Statement: [{ Effect: "Allow" }] } }
262
- ```
263
-
264
- ### WAF Access Denied (403)
265
-
266
- **Error:** `403 Forbidden` with `x-amzn-errortype: ForbiddenException`
267
- **Cause:** AWS WAF rule matched — IP denylist, rate limit, or injection detection.
268
-
269
- ```bash
270
- # Check WAF sampled requests in console to identify blocking rule
271
- # Test rules in Count mode before switching to Block
272
- ```
273
-
274
- ### CORS Errors
275
-
276
- **Error:** `blocked by CORS policy: No 'Access-Control-Allow-Origin' header`
277
- **Cause:** Lambda proxy integration must return CORS headers; HTTP APIs can configure at API level.
278
-
279
- ```yaml
280
- # SAM Globals
281
- Globals:
282
- Api:
283
- Cors:
284
- AllowOrigin: "'*'"
285
- AllowMethods: "'GET,POST,OPTIONS'"
286
- AllowHeaders: "'Content-Type,Authorization'"
287
- ```
288
-
289
- ```bash
290
- # HTTP API
291
- aws apigatewayv2 update-api --api-id abc123 \
292
- --cors-configuration AllowOrigins="*",AllowMethods="GET,POST",AllowHeaders="Content-Type"
293
- ```
294
-
295
- ### Internal Server Error — Lambda Throttled (500)
296
-
297
- **Error:** 500 with CloudWatch log `Lambda invocation failed with status 429`
298
- **Cause:** Lambda throttled but API Gateway surfaces as 500.
299
-
300
- ```bash
301
- # Increase Lambda concurrency (see TooManyRequestsException above)
302
- aws apigateway update-stage --rest-api-id abc123 --stage-name prod \
303
- --patch-operations op=replace,path=/*/*/throttling/rateLimit,value=1000
304
- ```
89
+ | Error | Cause | Fix |
90
+ |---|---|---|
91
+ | `403 Missing Authentication Token` | URL doesn't match a resource/method, or API not deployed | Usually routing, not auth — verify path and `create-deployment` to the stage |
92
+ | `Invalid permissions on Lambda function` (500) | API GW lacks `lambda:InvokeFunction` | `aws lambda add-permission --principal apigateway.amazonaws.com --source-arn "arn:aws:execute-api:...:api-id/*/GET/resource"` (add `--source-account <account-id>` to scope cross-service triggers like S3 to your account) |
93
+ | `Unauthorized` (401) | Lambda authorizer denied/errored/timed out | Check authorizer logs; verify it returns a valid Allow policy |
94
+ | `403` + `x-amzn-errortype: ForbiddenException` | WAF rule matched | Check WAF sampled requests; test rules in Count mode first |
95
+ | 500 with log `status 429` | Lambda throttled, surfaced as 500 | Increase Lambda concurrency |
305
96
 
306
97
  ---
307
98
 
308
- ## Step Functions Error Lookup
309
-
310
- ### States.TaskFailed
311
-
312
- **Error:** `States.TaskFailed`
313
- **Cause:** Task failed — unhandled Lambda exception, service error, or missing permissions.
314
-
315
- ```json
316
- "Retry": [{"ErrorEquals": ["States.TaskFailed","Lambda.ServiceException","Lambda.SdkClientException"], "IntervalSeconds": 2, "MaxAttempts": 3, "BackoffRate": 2.0}],
317
- "Catch": [{"ErrorEquals": ["States.TaskFailed"], "Next": "HandleError", "ResultPath": "$.error"}]
318
- ```
319
-
320
- ### States.Timeout
321
-
322
- **Error:** `States.Timeout`
323
- **Cause:** Task exceeded `TimeoutSeconds` or missed `HeartbeatSeconds` deadline.
324
-
325
- ```json
326
- {"Type": "Task", "Resource": "arn:aws:lambda:...", "TimeoutSeconds": 300, "HeartbeatSeconds": 60, "Next": "NextState"}
327
- ```
328
-
329
- ### States.DataLimitExceeded
330
-
331
- **Error:** `States.DataLimitExceeded`
332
- **Cause:** State input/output exceeded 256 KB. Cannot be caught by `States.ALL`.
333
-
334
- **Fix:** Store large data in S3, pass only S3 keys between states. Use `InputPath`/`OutputPath` to filter.
335
-
336
- ### ExecutionAlreadyExists
337
-
338
- **Error:** `ExecutionAlreadyExists`
339
- **Cause:** Execution name must be unique per state machine for 90 days.
340
-
341
- ```bash
342
- aws stepfunctions start-execution --state-machine-arn arn:aws:states:... \
343
- --name "exec-$(date +%s)" --input '{}'
344
- # Or omit --name for auto-generated names
345
- ```
99
+ ## Step Functions errors
346
100
 
347
- ### States.Permissions
348
-
349
- **Error:** `States.Permissions: insufficient privileges`
350
- **Cause:** Execution role lacks permission to invoke target service.
351
-
352
- ```bash
353
- aws iam list-attached-role-policies --role-name StepFunctionsRole
354
- # Add lambda:InvokeFunction, dynamodb:PutItem, etc. to the execution role
355
- ```
101
+ | Error | Cause / Fix |
102
+ |---|---|
103
+ | `States.TaskFailed` | Add `Retry` for `States.TaskFailed`/`Lambda.ServiceException`/`Lambda.SdkClientException`; `Catch` to a handler |
104
+ | `States.Timeout` | Set `TimeoutSeconds` (and `HeartbeatSeconds` for long tasks) |
105
+ | `States.DataLimitExceeded` | Input/output > 256 KiB — **cannot be caught by `States.ALL`**. Store in S3, pass keys |
106
+ | `ExecutionAlreadyExists` | Names unique per state machine for 90 days — use `--name "exec-$(date +%s)"` or omit `--name` |
107
+ | `States.Permissions` | Execution role lacks target-service permission |
356
108
 
357
109
  ---
358
110
 
359
- ## SAM/CDK Error Lookup
111
+ ## SAM/CDK errors
360
112
 
361
- ### Stale Build Cache
362
-
363
- **Error:** `sam build` uses old dependencies after updating requirements.txt, or `--clear-cache` flag unrecognized.
364
- **Cause:** SAM caches build artifacts. There is no `--clear-cache` flag.
113
+ ### Stale build cache
365
114
 
366
115
  ```bash
367
- sam build --no-cached # Force clean build (correct flag)
368
- rm -rf .aws-sam/cache # Or manually delete cache directory
116
+ sam build --no-cached # correct flag there is NO --clear-cache
117
+ rm -rf .aws-sam/cache # or delete the cache directory
369
118
  ```
370
119
 
371
120
  ### PythonPipBuilder:ResolveDependencies
372
121
 
373
- **Error:** `PythonPipBuilder:ResolveDependencies - pip install returned a non-zero exit code`
374
- **Cause:** Dependency version conflicts or missing native libraries.
375
-
376
- ```bash
377
- sam build --use-container --no-cached
378
- # Use binary wheels: psycopg2-binary instead of psycopg2
379
- ```
380
-
381
- ### DockerBuildFailed
382
-
383
- **Error:** `DockerBuildFailed: Docker build failed.`
384
- **Cause:** Docker not running or Dockerfile errors.
385
-
386
- ```bash
387
- docker info # verify running
388
- sudo systemctl start docker # start if needed
389
- ```
390
-
391
- ### Cannot find module 'esbuild'
392
-
393
- **Error:** `Cannot find module 'esbuild'`
394
- **Cause:** CDK `NodejsFunction` needs esbuild for bundling.
122
+ Version conflicts or missing native libs: `sam build --use-container --no-cached`; use binary wheels (`psycopg2-binary`).
395
123
 
396
- ```bash
397
- npm install --save-dev esbuild
398
- ```
124
+ ### CDK NodejsFunction: `Cannot find module 'esbuild'`
399
125
 
400
- ### CREATE_FAILED
126
+ `npm install --save-dev esbuild`.
401
127
 
402
- **Error:** `CREATE_FAILED: AWS::Lambda::Function`
403
- **Cause:** Invalid runtime, missing S3 code, role not ready, or package too large.
128
+ ### CREATE_FAILED / UPDATE_ROLLBACK_FAILED
404
129
 
405
130
  ```bash
406
131
  aws cloudformation describe-stack-events --stack-name my-stack \
407
132
  --query "StackEvents[?ResourceStatus=='CREATE_FAILED'].[LogicalResourceId,ResourceStatusReason]" --output table
408
- ```
409
-
410
- ### UPDATE_ROLLBACK_FAILED
411
-
412
- **Error:** `UPDATE_ROLLBACK_FAILED`
413
- **Cause:** Update failed and rollback also failed — resource manually deleted or permissions changed.
414
-
415
- ```bash
416
- aws cloudformation continue-update-rollback --stack-name my-stack
133
+ # Rollback also failed (resource manually deleted / perms changed):
417
134
  aws cloudformation continue-update-rollback --stack-name my-stack --resources-to-skip MyFunction
418
135
  ```
419
136
 
420
- ### Security Constraints Not Satisfied
421
-
422
- **Error:** `Security Constraints Not Satisfied`
423
- **Cause:** SAM template missing required properties (Handler, Runtime, CodeUri).
424
-
425
- ```bash
426
- sam validate --lint
427
- ```
428
-
429
- ### CDK Bootstrap Required
430
-
431
- **Error:** `This stack uses assets, so the toolkit stack must be deployed`
432
- **Cause:** Target account/region not bootstrapped.
433
-
434
- ```bash
435
- cdk bootstrap aws://123456789012/us-east-1
436
- ```
437
-
438
- ### Circular Dependency
439
-
440
- **Error:** `Circular dependency between resources: [MyFunction, MyRole, ...]`
441
- **Cause:** Resources reference each other in a cycle.
442
-
443
- ```yaml
444
- # Break cycle: give the function an explicit name and hardcode the ARN
445
- MyFunction:
446
- Type: AWS::Lambda::Function
447
- Properties:
448
- FunctionName: my-function-name # explicit name
449
-
450
- MyRole:
451
- Type: AWS::IAM::Role
452
- Properties:
453
- Policies:
454
- - PolicyDocument:
455
- Statement:
456
- - Effect: Allow
457
- Action: lambda:InvokeFunction
458
- # No ${MyFunction} reference — no implicit dependency
459
- Resource: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-function-name"
460
- # Or restructure to eliminate the cycle (extract IAM role/policy into a separate resource)
461
- ```
462
-
463
- ---
464
-
465
- ## Timeout Debugging
466
-
467
- ```
468
- Function times out
469
- ├── INIT phase? (Sandbox.Timedout)
470
- │ ├── YES → Increase timeout + memory, lazy-load heavy deps
471
- │ └── NO → INVOKE phase
472
- │ ├── Timeout ≈ avg duration? → Set to 2-3x average
473
- │ ├── Calling external services? → Set SDK timeouts < Lambda timeout
474
- │ ├── CPU-bound? → Increase memory (1,769 MB = 1 vCPU)
475
- │ └── VPC? → Check NAT Gateway / security group / VPC Endpoints
476
- ```
477
-
478
- ```bash
479
- aws lambda get-function-configuration --function-name my-func --query '[Timeout,MemorySize]'
480
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Duration \
481
- --dimensions Name=FunctionName,Value=my-func --period 300 --statistics Average Maximum \
482
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
483
- # For percentiles, use a separate call:
484
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Duration \
485
- --dimensions Name=FunctionName,Value=my-func --period 300 --extended-statistics p99 \
486
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
487
- ```
488
-
489
- ---
137
+ ### Circular dependency
490
138
 
491
- ## Out-of-Memory (OOM) Debugging
139
+ `Circular dependency between resources: [MyFunction, MyRole, ...]` — break the cycle by giving the function an explicit `FunctionName` and referencing the hardcoded ARN (`!Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-function-name"`) instead of `!Ref`/`!GetAtt`, or extract the IAM role/policy into a separate resource.
492
140
 
493
- ```
494
- Runtime.OutOfMemory / signal: killed
495
- ├── Check REPORT: Max Memory Used ≈ Memory Size? → OOM confirmed
496
- ├── Immediate? → Payload/dependency too large → increase memory
497
- ├── Gradual? → Memory leak → check global vars accumulating across warm invocations
498
- └── Fix: increase memory, stream large files, bound caches
499
- ```
141
+ ### Other quick ones
500
142
 
501
- | Memory (MB) | vCPUs | Use Case |
502
- |-------------|-------|----------|
503
- | 128 | ~0.08 | Simple transforms |
504
- | 512 | ~0.3 | Moderate processing |
505
- | 1,769 | 1.0 | CPU-intensive single-threaded |
506
- | 3,538 | 2.0 | Multi-threaded |
507
- | 10,240 | ~5.8 | Heavy compute, ML inference |
143
+ - `DockerBuildFailed` `docker info` / start Docker.
144
+ - `Security Constraints Not Satisfied` (missing Handler/Runtime/CodeUri) → `sam validate --lint`.
145
+ - `This stack uses assets, so the toolkit stack must be deployed` → `cdk bootstrap aws://ACCOUNT/REGION`.
508
146
 
509
147
  ---
510
148
 
511
- ## Throttling Diagnosis
149
+ ## Diagnostics
512
150
 
513
- | Concept | Default | Notes |
514
- |---------|---------|-------|
515
- | Account concurrency | 1,000/region | Request increase via Service Quotas |
516
- | Reserved concurrency | None | Guarantees AND caps function concurrency |
517
- | Concurrency scaling rate | 1,000 envs/10s | Per function, uniform across regions |
151
+ For systematic timeout investigation (config logs → metrics → VPC → cold start → memory → downstream), use the **debugging-lambda-timeouts** skill (see SKILL.md routing).
518
152
 
519
- | Invocation Type | Throttle Behavior |
520
- |-----------------|-------------------|
521
- | Synchronous (API GW) | Returns 429 (API GW may show 500) |
522
- | Async (S3, SNS) | Auto-retries up to 6 hours |
523
- | SQS trigger | Returns to queue, backs off |
524
- | Kinesis/DDB Streams | Retries batch, blocks shard |
153
+ CloudWatch Logs Insights run against `/aws/lambda/FUNCTION_NAME` (API Gateway uses the access log group). Useful fields on `@type = "REPORT"` lines: `@initDuration` (cold start), `@duration`, `@billedDuration`, `@maxMemoryUsed`, `@memorySize`. Examples:
525
154
 
526
- ```bash
527
- aws lambda get-account-settings
528
- aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Throttles \
529
- --dimensions Name=FunctionName,Value=my-func --period 60 --statistics Sum \
530
- --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) --end-time $(date -u +%Y-%m-%dT%H:%M:%S)
531
155
  ```
156
+ # Cold start rate + init latency
157
+ filter @type="REPORT" | stats count() as total, sum(ispresent(@initDuration)) as coldStarts,
158
+ avg(@initDuration) as avgInitMs, pct(@initDuration,99) as p99InitMs by bin(1h)
532
159
 
533
- ---
534
-
535
- ## CloudWatch Logs Insights Queries
160
+ # Out-of-memory (>90% used)
161
+ filter @type="REPORT" | filter @maxMemoryUsed/@memorySize > 0.9
162
+ | fields @timestamp, @requestId, @maxMemoryUsed/1e6 as usedMB | sort @timestamp desc
536
163
 
537
- Run against `/aws/lambda/FUNCTION_NAME`. For API Gateway, use the access log group.
538
-
539
- ### Cold Starts
540
-
541
- ```
542
- filter @type = "REPORT" | filter ispresent(@initDuration)
543
- | stats count() as coldStarts, avg(@initDuration) as avgInitMs, max(@initDuration) as maxInitMs, pct(@initDuration, 99) as p99InitMs by bin(1h)
544
- ```
164
+ # Latency percentiles
165
+ filter @type="REPORT" | stats pct(@duration,50) as p50, pct(@duration,90) as p90,
166
+ pct(@duration,99) as p99, max(@duration) as max by bin(1h)
545
167
 
546
- ### Cold Start Percentage
547
-
548
- ```
549
- filter @type = "REPORT"
550
- | stats count() as total, sum(ispresent(@initDuration)) as coldStarts, sum(ispresent(@initDuration)) * 100.0 / count() as pct by bin(1h)
551
- ```
552
-
553
- ### Errors by Type
554
-
555
- ```
556
- filter @message like /(?i)error|exception/
557
- | parse @message /(?<errorType>[A-Za-z]+Error|[A-Za-z]+Exception)/
558
- | stats count() as cnt by errorType | sort cnt desc
559
- ```
560
-
561
- ### Timeouts
562
-
563
- ```
564
- filter @message like /Task timed out/ | stats count() as timeouts by bin(1h) | sort bin desc
565
- ```
566
-
567
- ### Memory Utilization
568
-
569
- ```
570
- filter @type = "REPORT"
571
- | stats max(@memorySize/1e6) as provisionedMB, avg(@maxMemoryUsed/1e6) as avgUsedMB, max(@maxMemoryUsed/1e6) as maxUsedMB, pct(@maxMemoryUsed/1e6, 99) as p99UsedMB
572
- ```
573
-
574
- ### Out-of-Memory Detection (>90% memory)
575
-
576
- ```
577
- filter @type = "REPORT" | filter @maxMemoryUsed / @memorySize > 0.9
578
- | fields @timestamp, @requestId, @maxMemoryUsed/1e6 as usedMB, @memorySize/1e6 as allocatedMB | sort @timestamp desc | limit 50
579
- ```
580
-
581
- ### Overprovisioned Memory (<50% used)
582
-
583
- ```
584
- filter @type = "REPORT"
585
- | stats max(@memorySize/1e6) as provMB, max(@maxMemoryUsed/1e6) as peakMB, max(@maxMemoryUsed)*100.0/max(@memorySize) as pct
586
- | filter pct < 50
587
- ```
588
-
589
- ### Memory Growth (Leak Detection)
590
-
591
- ```
592
- filter @type = "REPORT" | stats avg(@maxMemoryUsed/1e6) as avgMemMB by bin(5m) | sort bin asc
593
- ```
594
-
595
- ### Latency Percentiles
596
-
597
- ```
598
- filter @type = "REPORT"
599
- | stats avg(@duration) as avg, pct(@duration,50) as p50, pct(@duration,90) as p90, pct(@duration,95) as p95, pct(@duration,99) as p99, max(@duration) as max by bin(1h)
600
- ```
601
-
602
- ### Slowest Invocations
603
-
604
- ```
605
- filter @type = "REPORT"
606
- | fields @timestamp, @requestId, @duration, @maxMemoryUsed/1000000 as memMB, ispresent(@initDuration) as coldStart
607
- | sort @duration desc | limit 20
608
- ```
609
-
610
- ### API Gateway 5xx
611
-
612
- ```
168
+ # API Gateway 5xx (access log group)
613
169
  filter status >= 500 | stats count() as errors by status, path, httpMethod | sort errors desc
614
170
  ```
615
171
 
616
- ### API Gateway 5xx Over Time
172
+ ### Memory vCPU (for OOM / CPU tuning)
617
173
 
618
- ```
619
- filter status >= 500 | stats count() by bin(5m) | sort bin desc
620
- ```
621
-
622
- ### Throttle Events
174
+ | Memory | vCPUs | Use case |
175
+ |---|---|---|
176
+ | 128 MB | ~0.08 | Simple transforms |
177
+ | 512 MB | ~0.3 | Moderate processing |
178
+ | 1,769 MB | 1.0 | CPU-intensive single-threaded |
179
+ | 3,538 MB | 2.0 | Multi-threaded |
180
+ | 10,240 MB | ~5.8 (up to 6 vCPU) | Heavy compute / ML inference |
623
181
 
624
- ```
625
- filter @message like /Rate Exceeded|TooManyRequestsException|Throttl/
626
- | fields @timestamp, @requestId, @message | sort @timestamp desc | limit 50
627
- ```
182
+ ### X-Ray
628
183
 
629
- ### Billed Duration
630
-
631
- ```
632
- filter @type = "REPORT"
633
- | stats count() as invocations, sum(@billedDuration)/1000 as totalBilledSec, avg(@billedDuration) as avgBilledMs by bin(1d)
634
- ```
635
-
636
- ### Error Messages with Request IDs
637
-
638
- ```
639
- filter @message like /(?i)error|exception|fail/
640
- | fields @timestamp, @requestId, @message | sort @timestamp desc | limit 50
641
- ```
642
-
643
- ---
644
-
645
- ## X-Ray Tracing
646
-
647
- ### Enable in SAM
648
-
649
- ```yaml
650
- Globals:
651
- Function:
652
- Tracing: Active
653
- ```
654
-
655
- ### Enable in CDK
656
-
657
- ```typescript
658
- new lambda.Function(this, 'Fn', {
659
- tracing: lambda.Tracing.ACTIVE, // adds AWSXRayDaemonWriteAccess automatically
660
- });
661
- ```
662
-
663
- ### Required IAM
664
- `AWSXRayDaemonWriteAccess` managed policy on the execution role. SAM/CDK add this automatically.
665
-
666
- ### Default Sampling
667
- 1 request/second (reservoir) + 5% of additional requests.
668
-
669
- ### Instrument SDK Calls
670
-
671
- ```python
672
- from aws_xray_sdk.core import patch_all
673
- patch_all()
674
- ```
675
-
676
- ```javascript
677
- // SDK v3 (Node.js 18+)
678
- const { captureAWSv3Client } = require('aws-xray-sdk-core');
679
- const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
680
- const ddb = captureAWSv3Client(new DynamoDBClient({}));
681
- ```
682
-
683
- ### Query Traces
684
-
685
- ```bash
686
- aws xray get-trace-summaries --start-time $(date -u -d '1 hour ago' +%s) --end-time $(date -u +%s) \
687
- --filter-expression 'service("my-func") AND fault'
688
- aws xray batch-get-traces --trace-ids "1-xxx-yyy"
689
- ```
690
-
691
- ### Enable for API Gateway
692
-
693
- ```yaml
694
- Resources:
695
- MyApi:
696
- Type: AWS::Serverless::Api
697
- Properties:
698
- StageName: prod
699
- TracingEnabled: true
700
- ```
701
-
702
- ### Enable for Step Functions
703
-
704
- ```yaml
705
- Resources:
706
- MyStateMachine:
707
- Type: AWS::Serverless::StateMachine
708
- Properties:
709
- Tracing:
710
- Enabled: true
711
- ```
184
+ Enable via SAM `Tracing: Active` (Function) / `TracingEnabled: true` (Api) or CDK `tracing: lambda.Tracing.ACTIVE` (adds `AWSXRayDaemonWriteAccess` automatically). Default sampling: 1 req/s reservoir + 5%. Instrument SDK calls with `patch_all()` (Python) / `captureAWSv3Client` (Node).