aws-lambda-devkit 0.1.0
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.
- package/CHANGELOG.md +72 -0
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/dist/aws/batch-response.d.ts +8 -0
- package/dist/aws/batch-response.d.ts.map +1 -0
- package/dist/aws/batch-response.js +12 -0
- package/dist/aws/batch-response.js.map +1 -0
- package/dist/aws/clients.d.ts +6 -0
- package/dist/aws/clients.d.ts.map +1 -0
- package/dist/aws/clients.js +30 -0
- package/dist/aws/clients.js.map +1 -0
- package/dist/aws/sns-publish.d.ts +10 -0
- package/dist/aws/sns-publish.d.ts.map +1 -0
- package/dist/aws/sns-publish.js +17 -0
- package/dist/aws/sns-publish.js.map +1 -0
- package/dist/aws/sqs-listen.d.ts +17 -0
- package/dist/aws/sqs-listen.d.ts.map +1 -0
- package/dist/aws/sqs-listen.js +113 -0
- package/dist/aws/sqs-listen.js.map +1 -0
- package/dist/aws/sqs-process.d.ts +39 -0
- package/dist/aws/sqs-process.d.ts.map +1 -0
- package/dist/aws/sqs-process.js +95 -0
- package/dist/aws/sqs-process.js.map +1 -0
- package/dist/aws/sqs-send.d.ts +15 -0
- package/dist/aws/sqs-send.d.ts.map +1 -0
- package/dist/aws/sqs-send.js +27 -0
- package/dist/aws/sqs-send.js.map +1 -0
- package/dist/aws/sqs-visibility.d.ts +10 -0
- package/dist/aws/sqs-visibility.d.ts.map +1 -0
- package/dist/aws/sqs-visibility.js +29 -0
- package/dist/aws/sqs-visibility.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +187 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +5 -0
- package/dist/commands/config-cmd.d.ts.map +1 -0
- package/dist/commands/config-cmd.js +8 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +24 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +59 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +23 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/listen.d.ts +20 -0
- package/dist/commands/listen.d.ts.map +1 -0
- package/dist/commands/listen.js +36 -0
- package/dist/commands/listen.js.map +1 -0
- package/dist/commands/send.d.ts +17 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +51 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/test.d.ts +23 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +123 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/config/env.d.ts +8 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +16 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/load.d.ts +9 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/load.js +72 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/merge.d.ts +36 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +89 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/project-env.d.ts +34 -0
- package/dist/config/project-env.d.ts.map +1 -0
- package/dist/config/project-env.js +90 -0
- package/dist/config/project-env.js.map +1 -0
- package/dist/config/schema.d.ts +27 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +123 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/types.d.ts +167 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/events/apigw.d.ts +41 -0
- package/dist/events/apigw.d.ts.map +1 -0
- package/dist/events/apigw.js +43 -0
- package/dist/events/apigw.js.map +1 -0
- package/dist/events/eventbridge.d.ts +16 -0
- package/dist/events/eventbridge.d.ts.map +1 -0
- package/dist/events/eventbridge.js +19 -0
- package/dist/events/eventbridge.js.map +1 -0
- package/dist/events/index.d.ts +17 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +50 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/s3.d.ts +45 -0
- package/dist/events/s3.d.ts.map +1 -0
- package/dist/events/s3.js +44 -0
- package/dist/events/s3.js.map +1 -0
- package/dist/events/schedule.d.ts +12 -0
- package/dist/events/schedule.d.ts.map +1 -0
- package/dist/events/schedule.js +15 -0
- package/dist/events/schedule.js.map +1 -0
- package/dist/events/sns.d.ts +24 -0
- package/dist/events/sns.d.ts.map +1 -0
- package/dist/events/sns.js +31 -0
- package/dist/events/sns.js.map +1 -0
- package/dist/events/sqs-record.d.ts +44 -0
- package/dist/events/sqs-record.d.ts.map +1 -0
- package/dist/events/sqs-record.js +75 -0
- package/dist/events/sqs-record.js.map +1 -0
- package/dist/events/sqs.d.ts +21 -0
- package/dist/events/sqs.d.ts.map +1 -0
- package/dist/events/sqs.js +28 -0
- package/dist/events/sqs.js.map +1 -0
- package/dist/events/util.d.ts +2 -0
- package/dist/events/util.d.ts.map +1 -0
- package/dist/events/util.js +7 -0
- package/dist/events/util.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/peer-resolve.d.ts +5 -0
- package/dist/peer-resolve.d.ts.map +1 -0
- package/dist/peer-resolve.js +44 -0
- package/dist/peer-resolve.js.map +1 -0
- package/dist/runtime/asset-links.d.ts +15 -0
- package/dist/runtime/asset-links.d.ts.map +1 -0
- package/dist/runtime/asset-links.js +42 -0
- package/dist/runtime/asset-links.js.map +1 -0
- package/dist/runtime/clear-caches.d.ts +5 -0
- package/dist/runtime/clear-caches.d.ts.map +1 -0
- package/dist/runtime/clear-caches.js +8 -0
- package/dist/runtime/clear-caches.js.map +1 -0
- package/dist/runtime/context.d.ts +10 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +42 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/handler-cache.d.ts +6 -0
- package/dist/runtime/handler-cache.d.ts.map +1 -0
- package/dist/runtime/handler-cache.js +14 -0
- package/dist/runtime/handler-cache.js.map +1 -0
- package/dist/runtime/invoke.d.ts +32 -0
- package/dist/runtime/invoke.d.ts.map +1 -0
- package/dist/runtime/invoke.js +111 -0
- package/dist/runtime/invoke.js.map +1 -0
- package/dist/runtime/loader.d.ts +17 -0
- package/dist/runtime/loader.d.ts.map +1 -0
- package/dist/runtime/loader.js +76 -0
- package/dist/runtime/loader.js.map +1 -0
- package/dist/runtime/logs.d.ts +19 -0
- package/dist/runtime/logs.d.ts.map +1 -0
- package/dist/runtime/logs.js +125 -0
- package/dist/runtime/logs.js.map +1 -0
- package/dist/util/payload.d.ts +13 -0
- package/dist/util/payload.d.ts.map +1 -0
- package/dist/util/payload.js +40 -0
- package/dist/util/payload.js.map +1 -0
- package/dist/util/tsx-register.d.ts +4 -0
- package/dist/util/tsx-register.d.ts.map +1 -0
- package/dist/util/tsx-register.js +27 -0
- package/dist/util/tsx-register.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/docs/README.md +23 -0
- package/docs/commands.md +294 -0
- package/docs/configuration.md +652 -0
- package/docs/getting-started.md +400 -0
- package/docs/recipes.md +743 -0
- package/docs/troubleshooting.md +393 -0
- package/package.json +76 -0
- package/templates/.env.example +5 -0
- package/templates/.vscode/launch.json +14 -0
- package/templates/events/sample.json +4 -0
- package/templates/lamkit.config.js +38 -0
- package/templates/lamkit.config.ts +27 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
Step-by-step fixes for common problems. Each section: **symptom → cause → fix → verify**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick diagnosis
|
|
8
|
+
|
|
9
|
+
Run these first from your Lambda package directory (where `lamkit.config.*` lives):
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx lamkit config # resolved config + env
|
|
13
|
+
npx lamkit list # registered functions
|
|
14
|
+
npx lamkit test --dry-run # no handler execution — checks paths only
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If `config` or `list` fails, fix config before testing handlers.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## `Cannot find module` for handler entry
|
|
22
|
+
|
|
23
|
+
**Symptom:**
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
Error: Cannot find module '/path/to/dist/handler.js'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Causes:**
|
|
30
|
+
|
|
31
|
+
1. `entry` points to `dist/` but you have not built yet.
|
|
32
|
+
2. Wrong relative path from config file location.
|
|
33
|
+
3. Typo in filename (`handler.js` vs `handlers.js`).
|
|
34
|
+
|
|
35
|
+
**Fix:**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# TypeScript project
|
|
39
|
+
npm run build
|
|
40
|
+
ls -la dist/handler.js
|
|
41
|
+
|
|
42
|
+
# Or point entry at source and use tsx
|
|
43
|
+
# entry: './src/handler.ts'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Verify:**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx lamkit test --dry-run worker
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## `Cannot find module '../../contracts/abi.json'`
|
|
55
|
+
|
|
56
|
+
**Symptom:** Handler loads from `dist/` but JSON/ABI files live under `src/`.
|
|
57
|
+
|
|
58
|
+
**Cause:** Production layout expects sibling folders next to `dist/`; dev layout keeps assets under `src/`.
|
|
59
|
+
|
|
60
|
+
**Fix — use `assetLinks` in config:**
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
export default {
|
|
64
|
+
assetLinks: [{ path: 'contracts', target: 'src/contracts' }],
|
|
65
|
+
functions: [
|
|
66
|
+
{ name: 'worker', entry: './dist/handler.js', trigger: 'sqs' },
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Lamkit creates `contracts → src/contracts` before invoke if `contracts/` does not exist.
|
|
72
|
+
|
|
73
|
+
**Verify:**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ls -la contracts # should be a symlink
|
|
77
|
+
npx lamkit test worker
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Manual alternative:**
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ln -s src/contracts contracts
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Wrong or missing environment variables
|
|
89
|
+
|
|
90
|
+
**Symptom:** Handler works in AWS but fails locally with `undefined` env, connection errors, or wrong region.
|
|
91
|
+
|
|
92
|
+
**Causes:**
|
|
93
|
+
|
|
94
|
+
1. `.env` not in the directory you run from.
|
|
95
|
+
2. Monorepo: secrets in root `.env`, but lamkit loads only cwd `.env`.
|
|
96
|
+
3. Variable names differ between `.env` and handler (`APP_DB_HOST` vs `DB_HOST`).
|
|
97
|
+
|
|
98
|
+
**Fix — `loadProjectEnv` at top of config:**
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import { loadProjectEnv } from 'aws-lambda-devkit';
|
|
102
|
+
|
|
103
|
+
loadProjectEnv({
|
|
104
|
+
files: ['../../.env'], // paths relative to config file
|
|
105
|
+
skipDotenv: true, // do not also load ./.env
|
|
106
|
+
aliases: {
|
|
107
|
+
APP_DB_HOST: 'DB_HOST',
|
|
108
|
+
APP_DB_NAME: 'DB_NAME',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Verify:**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npx lamkit config | grep -E 'DB_|AWS_'
|
|
117
|
+
npx lamkit test worker --env LOG_LEVEL=debug
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Per-run override without editing files:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx lamkit test worker --env DB_HOST=localhost --data '{}'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## `lamkit: command not found`
|
|
129
|
+
|
|
130
|
+
**Symptom:** Shell cannot find `lamkit` after `npm install`.
|
|
131
|
+
|
|
132
|
+
**Fix:** Use `npx` or an npm script:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npx lamkit test
|
|
136
|
+
# or in package.json:
|
|
137
|
+
# "test:lambda": "lamkit test"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Install as dev dependency in the **same package** as your config:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm install -D aws-lambda-devkit
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Config file not found
|
|
149
|
+
|
|
150
|
+
**Symptom:**
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
No lamkit.config.js / .mjs / .ts found
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Fix:**
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx lamkit init
|
|
160
|
+
# creates lamkit.config.js + sample handler + events/
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Supported names: `lamkit.config.js`, `lamkit.config.mjs`, `lamkit.config.ts`, `lamkit.config.cjs`.
|
|
164
|
+
|
|
165
|
+
Run commands from the directory that contains the config (or pass `--config path/to/lamkit.config.mjs` if your CLI supports it — check `lamkit test --help`).
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Handler throws but AWS “works”
|
|
170
|
+
|
|
171
|
+
**Symptom:** Local test fails; deployed Lambda succeeds with same payload.
|
|
172
|
+
|
|
173
|
+
**Checklist:**
|
|
174
|
+
|
|
175
|
+
| Check | What to do |
|
|
176
|
+
|-------|------------|
|
|
177
|
+
| Event shape | Compare `--event` file vs built event: `lamkit test --dry-run` shows trigger |
|
|
178
|
+
| Batch size | AWS may send multiple `Records`; test with `--batch-size 3` |
|
|
179
|
+
| Env / secrets | `lamkit config` — compare to Lambda console env |
|
|
180
|
+
| IAM / network | Local code may reach RDS/VPC; Lambda uses VPC config |
|
|
181
|
+
| Time / IDs | Payload uses real DB IDs in prod, fake IDs locally |
|
|
182
|
+
|
|
183
|
+
**Capture production event:**
|
|
184
|
+
|
|
185
|
+
1. Log full `event` in Lambda (temporarily).
|
|
186
|
+
2. Save to `events/prod-sample.json`.
|
|
187
|
+
3. `npx lamkit test --event events/prod-sample.json`
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## SQS `listen` receives nothing
|
|
192
|
+
|
|
193
|
+
**Symptom:** `lamkit listen worker` runs but no messages processed.
|
|
194
|
+
|
|
195
|
+
**Causes:**
|
|
196
|
+
|
|
197
|
+
1. Wrong `queueUrl` in config or `.env`.
|
|
198
|
+
2. Message sent to a different queue/region/account.
|
|
199
|
+
3. Deployed Lambda still consuming messages (race).
|
|
200
|
+
4. Empty queue.
|
|
201
|
+
|
|
202
|
+
**Fix:**
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Confirm URL
|
|
206
|
+
npx lamkit config
|
|
207
|
+
|
|
208
|
+
# Send then listen (one-shot)
|
|
209
|
+
npx lamkit send sqs worker --data '{"ping":true}'
|
|
210
|
+
npx lamkit listen worker --once --expect-messages
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**AWS CLI cross-check:**
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
aws sqs get-queue-attributes \
|
|
217
|
+
--queue-url "$WORKER_QUEUE_URL" \
|
|
218
|
+
--attribute-names ApproximateNumberOfMessages
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Safety:** Pause Lambda event source mapping on dev queues while using `listen`.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## `send sqs` / `send sns` fails with credentials
|
|
226
|
+
|
|
227
|
+
**Symptom:**
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
CredentialsProviderError / UnrecognizedClientException
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Fix:**
|
|
234
|
+
|
|
235
|
+
```env
|
|
236
|
+
AWS_REGION=us-east-1
|
|
237
|
+
AWS_ACCESS_KEY_ID=...
|
|
238
|
+
AWS_SECRET_ACCESS_KEY=...
|
|
239
|
+
# Optional for LocalStack / custom gateway:
|
|
240
|
+
# AWS_ENDPOINT_URL=http://localhost:4566
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Install peer:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npm install -D @aws-sdk/client-sqs
|
|
247
|
+
# and/or
|
|
248
|
+
npm install -D @aws-sdk/client-sns
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Verify:**
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
aws sts get-caller-identity
|
|
255
|
+
npx lamkit send sqs worker --data '{"test":true}'
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## FIFO queue errors
|
|
261
|
+
|
|
262
|
+
**Symptom:**
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
MissingParameter: The request must contain the parameter MessageGroupId
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Cause:** Standard send flags used against a `.fifo` queue.
|
|
269
|
+
|
|
270
|
+
**Fix:** Lamkit auto-sets group/dedup IDs when queue URL ends with `.fifo`. Ensure `queueUrl` in config is the full FIFO URL.
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npx lamkit send sqs worker --data '{"orderId":"1"}'
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## TypeScript: `Unexpected token` or import errors
|
|
279
|
+
|
|
280
|
+
**Symptom:** Parsing error when `entry` is `.ts`.
|
|
281
|
+
|
|
282
|
+
**Fix:**
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm install -D tsx
|
|
286
|
+
# entry: './src/handler.ts'
|
|
287
|
+
npx lamkit test
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Or build first and point `entry` at `./dist/handler.js`.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## `strict-batch` exits 1 unexpectedly
|
|
295
|
+
|
|
296
|
+
**Symptom:** Test fails with `--strict-batch` but handler “looks fine”.
|
|
297
|
+
|
|
298
|
+
**Cause:** Handler returns `batchItemFailures` for one or more records (correct SQS partial failure response).
|
|
299
|
+
|
|
300
|
+
**Verify:**
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
npx lamkit test worker --data '[{"id":"1"},{"id":"2"}]'
|
|
304
|
+
# without --strict-batch — inspect returned batchItemFailures in output
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Use `--strict-batch` only when you want CI to fail on any partial failure.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Stale code after edits
|
|
312
|
+
|
|
313
|
+
**Symptom:** You changed handler but test runs old logic.
|
|
314
|
+
|
|
315
|
+
**Fix:**
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
npx lamkit test worker --reload --data '{}'
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Or rebuild for `dist/`:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm run build && npx lamkit test worker
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## `assetLinks` did not create symlink
|
|
330
|
+
|
|
331
|
+
**Symptom:** Link missing; still get module not found.
|
|
332
|
+
|
|
333
|
+
**Causes:**
|
|
334
|
+
|
|
335
|
+
1. `path` already exists as a real directory (Lamkit does not overwrite).
|
|
336
|
+
2. `target` path wrong relative to project root.
|
|
337
|
+
|
|
338
|
+
**Fix:**
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
rm -rf contracts # only if safe — not production data
|
|
342
|
+
npx lamkit test --dry-run # triggers asset link setup
|
|
343
|
+
ls -la contracts
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Check `target` exists:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
ls -la src/contracts
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Custom endpoint hits real AWS (or vice versa)
|
|
355
|
+
|
|
356
|
+
**Symptom:** `AWS_ENDPOINT_URL` set but SDK calls `amazonaws.com`.
|
|
357
|
+
|
|
358
|
+
**Cause:** `loadProjectEnv()` strips custom endpoints when it detects real `AKIA*` access keys (safety default).
|
|
359
|
+
|
|
360
|
+
**Fix:**
|
|
361
|
+
|
|
362
|
+
```js
|
|
363
|
+
loadProjectEnv({
|
|
364
|
+
stripCustomEndpointForRealAws: false,
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Or use test credentials / LocalStack keys with endpoint URL.
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Debug checklist (printable)
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
[ ] cd to directory with lamkit.config.*
|
|
376
|
+
[ ] npm install && npm run build (if using dist/)
|
|
377
|
+
[ ] npx lamkit list
|
|
378
|
+
[ ] npx lamkit config
|
|
379
|
+
[ ] npx lamkit test --dry-run
|
|
380
|
+
[ ] npx lamkit test --data '{...}' or --event file.json
|
|
381
|
+
[ ] Compare env to Lambda console
|
|
382
|
+
[ ] For real queue: send + listen --once --expect-messages
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Still stuck?
|
|
388
|
+
|
|
389
|
+
1. Minimal repro: one handler, one `test.data`, no AWS calls.
|
|
390
|
+
2. Add `console.log(JSON.stringify(event, null, 2))` at handler start.
|
|
391
|
+
3. Compare with [Getting started](getting-started.md) and matching [Recipe](recipes.md).
|
|
392
|
+
|
|
393
|
+
Report issues with: lamkit version (`npx lamkit --version`), config (redact secrets), command line, and full error stack.
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aws-lambda-devkit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local AWS Lambda development toolkit (npm: aws-lambda-devkit, CLI: lamkit) — invoke handlers locally with AWS-shaped events",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"lamkit": "dist/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"templates",
|
|
16
|
+
"docs",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./config": {
|
|
28
|
+
"types": "./dist/config/types.d.ts",
|
|
29
|
+
"import": "./dist/config/types.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
36
|
+
"test": "npm run build && node --test tests/**/*.test.js",
|
|
37
|
+
"pack:check": "npm run build && node scripts/pack-check.mjs",
|
|
38
|
+
"publish:dry-run": "bash scripts/publish-dry-run.sh",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@types/aws-lambda": "^8.10.162",
|
|
43
|
+
"commander": "^15.0.0",
|
|
44
|
+
"picocolors": "^1.1.1",
|
|
45
|
+
"zod": "^3.24.2"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@aws-sdk/client-sns": "^3.0.0",
|
|
49
|
+
"@aws-sdk/client-sqs": "^3.0.0",
|
|
50
|
+
"tsx": "^4.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@aws-sdk/client-sns": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@aws-sdk/client-sqs": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"tsx": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^22.13.10",
|
|
65
|
+
"tsx": "^4.19.0",
|
|
66
|
+
"typescript": "^5.8.2"
|
|
67
|
+
},
|
|
68
|
+
"keywords": [
|
|
69
|
+
"aws",
|
|
70
|
+
"lambda",
|
|
71
|
+
"local",
|
|
72
|
+
"development",
|
|
73
|
+
"sqs",
|
|
74
|
+
"cli"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "lamkit test (inspect)",
|
|
8
|
+
"runtimeExecutable": "lamkit",
|
|
9
|
+
"runtimeArgs": ["test", "--inspect-brk"],
|
|
10
|
+
"console": "integratedTerminal",
|
|
11
|
+
"skipFiles": ["<node_internals>/**"]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lambda DevKit — starter config.
|
|
3
|
+
*
|
|
4
|
+
* Docs (after npm install):
|
|
5
|
+
* node_modules/aws-lambda-devkit/docs/getting-started.md
|
|
6
|
+
* node_modules/aws-lambda-devkit/docs/commands.md
|
|
7
|
+
*
|
|
8
|
+
* Quick start:
|
|
9
|
+
* npx lamkit test --data '{"orderId":"1"}'
|
|
10
|
+
* npx lamkit list
|
|
11
|
+
* npx lamkit config
|
|
12
|
+
*/
|
|
13
|
+
export default {
|
|
14
|
+
// defaults: {
|
|
15
|
+
// runtime: 'nodejs20.x',
|
|
16
|
+
// memorySize: 512,
|
|
17
|
+
// timeout: 30,
|
|
18
|
+
// logFormat: 'text', // or 'json'
|
|
19
|
+
// aws: { region: process.env.AWS_REGION ?? 'us-east-1' },
|
|
20
|
+
// },
|
|
21
|
+
|
|
22
|
+
// Symlink assets before invoke (e.g. dist/ code reads ../../contracts/*.json)
|
|
23
|
+
// assetLinks: [{ path: 'contracts', target: 'src/contracts' }],
|
|
24
|
+
|
|
25
|
+
functions: [
|
|
26
|
+
{
|
|
27
|
+
name: 'worker',
|
|
28
|
+
entry: './src/lambda/handler.js', // or './dist/handler.js' after build
|
|
29
|
+
trigger: 'sqs', // sqs | http | sns | s3 | eventbridge | schedule
|
|
30
|
+
|
|
31
|
+
// Default payload when you run `lamkit test` with no --data
|
|
32
|
+
// test: { data: { orderId: 'ord_local_1' } },
|
|
33
|
+
|
|
34
|
+
// Real dev queue (optional — for `lamkit send sqs` / `lamkit listen`)
|
|
35
|
+
// aws: { queueUrl: process.env.WORKER_QUEUE_URL },
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from 'aws-lambda-devkit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript config — hover any field for docs and autocomplete.
|
|
5
|
+
* Requires: npm install -D aws-lambda-devkit tsx
|
|
6
|
+
*/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
// defaults: {
|
|
9
|
+
// runtime: 'nodejs20.x',
|
|
10
|
+
// memorySize: 512,
|
|
11
|
+
// timeout: 30,
|
|
12
|
+
// logFormat: 'text',
|
|
13
|
+
// aws: { region: process.env.AWS_REGION ?? 'us-east-1' },
|
|
14
|
+
// },
|
|
15
|
+
|
|
16
|
+
// assetLinks: [{ path: 'contracts', target: 'src/contracts' }],
|
|
17
|
+
|
|
18
|
+
functions: [
|
|
19
|
+
{
|
|
20
|
+
name: 'worker',
|
|
21
|
+
entry: './src/lambda/handler.js',
|
|
22
|
+
trigger: 'sqs',
|
|
23
|
+
// test: { data: { orderId: 'ord_local_1' } },
|
|
24
|
+
// aws: { queueUrl: process.env.WORKER_QUEUE_URL },
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|