cdk-local-lambda 0.0.6 → 0.0.8
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/README.md +38 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cdk-local-lambda
|
|
2
2
|
|
|
3
|
-
Run
|
|
4
|
-
improves the DX as you can edit lambdas and see changes and fixes
|
|
5
|
-
immediately.
|
|
3
|
+
Run Lambda functions from your CDK stack locally. Edit your code and see changes immediately—no redeployment required.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
## Supported Runtimes
|
|
6
|
+
|
|
7
|
+
| Runtime | Status |
|
|
8
|
+
|---------|--------|
|
|
9
|
+
| TypeScript / JavaScript | Supported |
|
|
10
|
+
| Docker | Supported |
|
|
11
|
+
| Python | Not yet supported |
|
|
12
|
+
| Java | Not yet supported |
|
|
8
13
|
|
|
9
14
|
## Installation
|
|
10
15
|
|
|
@@ -12,18 +17,21 @@ Needs two minor changes to a CDK stack, and the supplied cli to launch it.
|
|
|
12
17
|
npm install cdk-local-lambda
|
|
13
18
|
```
|
|
14
19
|
|
|
15
|
-
##
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
Setting up local Lambda development requires three steps:
|
|
23
|
+
|
|
24
|
+
1. Load the bootstrap module
|
|
25
|
+
2. Apply the LiveLambda aspect
|
|
26
|
+
3. Start the local daemon
|
|
16
27
|
|
|
17
|
-
### 1.
|
|
28
|
+
### 1. Load the bootstrap module
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
CDK accepts our patch to improve this, you need to live patch
|
|
21
|
-
CDK. This depends on how you run your CDK app.
|
|
30
|
+
The bootstrap module patches CDK internals to enable local execution. The loading method depends on your runtime.
|
|
22
31
|
|
|
23
|
-
#### tsx/ts-node
|
|
32
|
+
#### tsx / ts-node
|
|
24
33
|
|
|
25
|
-
In your CDK app entry point (e.g., `bin/app.ts`),
|
|
26
|
-
the every first entry:
|
|
34
|
+
In your CDK app entry point (e.g., `bin/app.ts`), import the bootstrap module before any other imports:
|
|
27
35
|
|
|
28
36
|
```typescript
|
|
29
37
|
import "cdk-local-lambda/bootstrap" // Must be first import!
|
|
@@ -32,9 +40,9 @@ import * as cdk from "aws-cdk-lib"
|
|
|
32
40
|
|
|
33
41
|
#### Bun
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
Bun requires preloading the bootstrap module because it snapshots CommonJS exports during static ESM import linking. A regular import statement runs too late.
|
|
36
44
|
|
|
37
|
-
Add
|
|
45
|
+
Add the `--preload` flag to your `cdk.json`:
|
|
38
46
|
|
|
39
47
|
```json
|
|
40
48
|
{
|
|
@@ -42,9 +50,9 @@ Add a `--preload` command to `cdk.json`:
|
|
|
42
50
|
}
|
|
43
51
|
```
|
|
44
52
|
|
|
45
|
-
### 2.
|
|
53
|
+
### 2. Apply the LiveLambda aspect
|
|
46
54
|
|
|
47
|
-
In your CDK app entry point (e.g., `bin/app.ts`):
|
|
55
|
+
In your CDK app entry point (e.g., `bin/app.ts`), apply the aspect after defining your stacks:
|
|
48
56
|
|
|
49
57
|
```typescript
|
|
50
58
|
import "cdk-local-lambda/bootstrap" // Must be first import!
|
|
@@ -61,19 +69,19 @@ app.synth()
|
|
|
61
69
|
|
|
62
70
|
### 3. Start the local daemon
|
|
63
71
|
|
|
64
|
-
The daemon deploys your stack with live mode enabled and runs
|
|
72
|
+
The daemon deploys your stack with live mode enabled and runs Lambda functions locally:
|
|
65
73
|
|
|
66
74
|
```bash
|
|
67
75
|
npx cll local
|
|
68
76
|
```
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
For multiple stacks, specify which one to use:
|
|
71
79
|
|
|
72
80
|
```bash
|
|
73
81
|
npx cll local --stacks MyStack
|
|
74
82
|
```
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
To specify AWS credentials:
|
|
77
85
|
|
|
78
86
|
```bash
|
|
79
87
|
npx cll local --stacks MyStack --profile my-profile --region us-west-2
|
|
@@ -81,14 +89,20 @@ npx cll local --stacks MyStack --profile my-profile --region us-west-2
|
|
|
81
89
|
|
|
82
90
|
### Manual bootstrap (optional)
|
|
83
91
|
|
|
84
|
-
|
|
92
|
+
To deploy the bootstrap stack separately:
|
|
85
93
|
|
|
86
94
|
```bash
|
|
87
95
|
npx cll bootstrap --profile my-profile --region us-west-2
|
|
88
96
|
```
|
|
89
97
|
|
|
90
|
-
##
|
|
98
|
+
## Troubleshooting
|
|
99
|
+
|
|
100
|
+
### "No functions found with live-lambda tags yet"
|
|
101
|
+
|
|
102
|
+
This error appears when the bootstrap module or aspect is not configured correctly.
|
|
91
103
|
|
|
92
|
-
|
|
104
|
+
**Checklist:**
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
- Verify that `cdk-local-lambda/bootstrap` is loaded (use `--preload` for Bun)
|
|
107
|
+
- Confirm that `applyLiveLambdaAspect(app)` is called in your app entry point
|
|
108
|
+
- Ensure the aspect is applied after all stacks are defined
|