@geek-fun/serverlessinsight 0.9.3 → 0.9.5

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 (82) hide show
  1. package/AGENTS.md +5 -2
  2. package/CHANGELOG.md +56 -0
  3. package/README.md +266 -179
  4. package/README.zh-CN.md +264 -147
  5. package/codecov +0 -0
  6. package/codecov.SHA256SUM +1 -1
  7. package/codecov.SHA256SUM.sig +13 -13
  8. package/dist/package.json +22 -19
  9. package/dist/src/commands/deploy.js +7 -2
  10. package/dist/src/commands/destroy.js +6 -3
  11. package/dist/src/commands/forceUnlock.js +16 -21
  12. package/dist/src/commands/index.js +26 -63
  13. package/dist/src/commands/migrate.js +105 -132
  14. package/dist/src/commands/plan.js +27 -3
  15. package/dist/src/commands/show.js +17 -6
  16. package/dist/src/common/aggregateState.js +185 -0
  17. package/dist/src/common/aggregateStore.js +247 -0
  18. package/dist/src/common/aliyunClient/apigwOperations.js +32 -9
  19. package/dist/src/common/apiClient.js +35 -12
  20. package/dist/src/common/constants.js +2 -1
  21. package/dist/src/common/context.js +22 -15
  22. package/dist/src/common/effectiveConfig.js +48 -0
  23. package/dist/src/common/index.js +5 -0
  24. package/dist/src/common/jsonOutput.js +2 -13
  25. package/dist/src/common/migrationMarker.js +0 -7
  26. package/dist/src/common/nameBuilder.js +2 -3
  27. package/dist/src/common/regionalMigration.js +261 -0
  28. package/dist/src/common/saasProtocol.js +41 -0
  29. package/dist/src/common/stateBackend/cosStateBackend.js +88 -8
  30. package/dist/src/common/stateBackend/index.js +42 -18
  31. package/dist/src/common/stateBackend/localStateBackend.js +61 -26
  32. package/dist/src/common/stateBackend/ossStateBackend.js +62 -9
  33. package/dist/src/common/stateBackend/remoteStateBackend.js +94 -94
  34. package/dist/src/common/stateBackend/saasStateBackend.js +327 -92
  35. package/dist/src/common/stateBackend/types.js +9 -0
  36. package/dist/src/common/stateManager.js +38 -11
  37. package/dist/src/common/stateScope.js +34 -0
  38. package/dist/src/common/stateStorageIO.js +31 -0
  39. package/dist/src/lang/en.js +48 -6
  40. package/dist/src/lang/index.js +28 -14
  41. package/dist/src/lang/zh-CN.js +48 -6
  42. package/dist/src/parser/index.js +25 -4
  43. package/dist/src/stack/aliyunStack/apigwDomainPlan.js +82 -0
  44. package/dist/src/stack/aliyunStack/apigwExecutor.js +4 -1
  45. package/dist/src/stack/aliyunStack/apigwPlanner.js +115 -55
  46. package/dist/src/stack/aliyunStack/apigwResource.js +169 -124
  47. package/dist/src/stack/aliyunStack/deployer.js +5 -5
  48. package/dist/src/stack/aliyunStack/destroyer.js +5 -5
  49. package/dist/src/stack/aliyunStack/fc3Planner.js +1 -1
  50. package/dist/src/stack/aliyunStack/fc3Resource.js +2 -2
  51. package/dist/src/stack/aliyunStack/planner.js +1 -1
  52. package/dist/src/stack/aliyunStack/sharedLogProject.js +2 -2
  53. package/dist/src/stack/ownershipTag.js +34 -26
  54. package/dist/src/stack/scfStack/deployer.js +5 -5
  55. package/dist/src/stack/scfStack/destroyer.js +5 -6
  56. package/dist/src/stack/scfStack/planner.js +1 -1
  57. package/dist/src/stack/scfStack/scfResource.js +1 -1
  58. package/dist/src/stack/scfStack/sharedLogset.js +5 -2
  59. package/dist/src/stack/volcengineStack/deployer.js +3 -3
  60. package/dist/src/stack/volcengineStack/destroyer.js +2 -3
  61. package/dist/src/stack/volcengineStack/planner.js +1 -1
  62. package/dist/src/stack/volcengineStack/sharedLogProject.js +4 -4
  63. package/dist/src/stack/volcengineStack/vefaasResource.js +1 -1
  64. package/dist/src/types/domains/state.js +28 -2
  65. package/dist/src/validator/rootSchema.js +8 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +22 -19
  68. package/release-notes.md +27 -56
  69. package/samples/README_TENCENT_COS.md +68 -26
  70. package/samples/README_TENCENT_SCF.md +47 -29
  71. package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +0 -14
  72. package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +0 -32
  73. package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +0 -90
  74. package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +0 -118
  75. package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +0 -215
  76. package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +0 -14
  77. package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +0 -132
  78. package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +0 -55
  79. package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +0 -1
  80. package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +0 -93
  81. package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +0 -163
  82. package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +0 -148
package/release-notes.md CHANGED
@@ -1,40 +1,34 @@
1
1
 
2
+ ### 🔧 Changed
3
+
4
+ - Deployment state is now isolated per stage/provider/region: the first
5
+ deploy/destroy/migrate upgrades the legacy state file in place to a V4
6
+ aggregate (original backup kept), so deploying to a second region or
7
+ provider no longer touches another deployment's resources
8
+ ([#280](https://github.com/geek-fun/serverlessinsight/issues/280)). CLI
9
+ versions older than this release refuse the upgraded state — upgrade all
10
+ writers together.
11
+ - SaaS deployments now require a Console with regional scope enabled (scope
12
+ protocol 3) and fail closed with guidance against older servers
13
+ ([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
14
+
2
15
  ### ✨ Added
3
16
 
4
- - `si local` now invokes veFaaS functions with a veFaaS-native HTTP event and fires
5
- `triggers.timer` schedules locally with the documented CloudEvents timer envelope,
6
- so veFaaS HTTP- and timer-driven handlers can be debugged without deploying
7
- ([#268](https://github.com/geek-fun/serverlessinsight/issues/268),
8
- [#261](https://github.com/geek-fun/serverlessinsight/issues/261)).
9
- - `si local` runs Tencent SCF functions with an SCF-native invocation context and
10
- simulates the HTTP trigger contract si deploys (function URL delivering an
11
- API-Gateway-compatible event), instead of falling back to a generic non-Aliyun
12
- shape; unsupported contracts are reported clearly rather than silently substituted
13
- ([#267](https://github.com/geek-fun/serverlessinsight/issues/267)).
14
- - Plans now enforce lifecycle ownership for what si created: removing a bucket `iam`
15
- policy, a bucket domain, a function HTTP trigger or custom domain, or
16
- `triggers.timer` from the YAML deletes the corresponding cloud resources (and their
17
- recorded dependents) on the next deploy instead of silently retaining them, and the
18
- removals show up in the plan before/after
19
- ([#264](https://github.com/geek-fun/serverlessinsight/issues/264)).
17
+ - `--bind-unknown-region <region>` on `deploy`, `destroy` and `migrate` to
18
+ explicitly bind legacy state entries that carry no region evidence, instead
19
+ of letting the CLI guess where historical resources live
20
+ ([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
20
21
 
21
22
  ### 🐛 Fixed
22
23
 
23
- - `si plan` and `si diff` now work for Volcengine stacks.
24
- - Deployment diffs now reflect changes made to managed resources directly in the
25
- cloud, restore documented defaults on update, and repair drifted dependents
26
- ([#264](https://github.com/geek-fun/serverlessinsight/issues/264)).
27
- - veFaaS functions with `logEnabled` or HTTP/domain triggers no longer crash during
28
- planning.
29
- - Bucket planning no longer fails when the account lacks permission to read ACL or
30
- CORS settings: those optional sub-config values are treated as absent, while
31
- identity and existence checks remain strict.
32
- - `si local` no longer fails on non-JSON response metadata in function logs.
24
+ - Console/server conflict messages (state or protocol conflicts) are now
25
+ shown verbatim instead of a generic "HTTP Error 409"
26
+ ([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
33
27
 
34
28
  ## 👥 Contributors
35
29
 
36
- - **AnnChord** (3 commits)
37
- - **blankll** (22 commits)
30
+ - **blankll** (1 commit)
31
+ - **seven** (1 commit)
38
32
 
39
33
 
40
34
  ---
@@ -42,33 +36,10 @@
42
36
  <details>
43
37
  <summary>📋 Full commit history</summary>
44
38
 
45
- _Changes from v0.9.2 to v0.9.3_
46
-
47
- - 05c6c54 release: v0.9.3 (blankll, 17 minutes ago)
48
- - cdc112b refactor(local): import ProviderEnum via the common barrel (blankll, 53 minutes ago)
49
- - 9f07eb2 feat(local): add Tencent SCF-native invocation context and HTTP trigger simulation (AnnChord, 33 hours ago)
50
- - 20d5057 test: build compiled output before every run so `npm test` works unbuilt (AnnChord, 23 hours ago)
51
- - fe520c7 fix(local): tolerate non-JSON response metadata in logs (blankll, 26 hours ago)
52
- - f4b4df0 fix(local): simulate veFaaS timers, share exact route matching, sync docs (AnnChord, 32 hours ago)
53
- - 4661633 feat(local): add veFaaS-native HTTP invocation (blankll, 2 days ago)
54
- - 1e0604d docs: update WeChat official account QR code (blankll, 2 hours ago)
55
- - c951ffd fix(cli): enable Volcengine plan and diff commands (blankll, 3 days ago)
56
- - 17db698 fix(plan): restore defaults and complete dependent drift repairs (blankll, 3 days ago)
57
- - 9e8d1fc docs: consolidate plan implementation notes in issue 264 (blankll, 3 days ago)
58
- - 7110f55 fix(plan): preserve cloud read and dependent repair contracts (blankll, 3 days ago)
59
- - 7f17375 feat(plan): apply lifecycle ownership to recorded timer triggers (blankll, 4 days ago)
60
- - fb888f8 docs(plan): replace the stale omission-preservation contract with state ownership (blankll, 4 days ago)
61
- - d390fdf feat(plan): delete state-owned dependents omitted from yaml (blankll, 4 days ago)
62
- - 159f202 fix(oss,cos): fall back to stored intent when bucket sub-config reads are denied (blankll, 4 days ago)
63
- - 4541c92 fix(plan): opt providers out of unsupported lifecycle intent and reconcile vefaas logEnabled (blankll, 4 days ago)
64
- - bfd1985 test(plan): cover lifecycle drift and failed cloud reads (blankll, 5 days ago)
65
- - 585f3dc fix(plan): align deployment diffs with managed cloud changes (blankll, 5 days ago)
66
- - 5b4b265 docs: add the WeChat sponsor QR to the READMEs (blankll, 8 days ago)
67
- - 9328e64 docs: add the WeChat Official Account QR to the READMEs (blankll, 8 days ago)
68
- - caa474d docs: drop the WeChat group, Discord and Star History from the READMEs (blankll, 8 days ago)
69
- - eb25c82 fix: audit fix (blankll, 9 days ago)
70
- - e041126 docs: add the ServerlessInsight brand lockup to the READMEs (blankll, 9 days ago)
71
- - 5f31433 ci: build GitHub release notes from CHANGELOG.md (align with dockit/sqlkit) (blankll, 2 weeks ago)
39
+ _Changes from v0.9.4 to v0.9.5_
40
+
41
+ - d1a757a release: v0.9.5 (blankll, 34 minutes ago)
42
+ - 288718e refactor(state): isolate provider and region deployments in aggregate state (#281) (seven, 40 minutes ago)
72
43
 
73
44
  </details>
74
45
 
@@ -76,4 +47,4 @@ _Changes from v0.9.2 to v0.9.3_
76
47
 
77
48
  ## 📦 Install
78
49
 
79
- `npm install -g @geek-fun/serverlessinsight@0.9.3`
50
+ `npm install -g @geek-fun/serverlessinsight@0.9.5`
@@ -6,7 +6,7 @@ This guide demonstrates how to use ServerlessInsight with Tencent Cloud COS buck
6
6
 
7
7
  The Tencent COS support provides full lifecycle management for cloud storage buckets with:
8
8
 
9
- - **State Management**: Local state tracking in `.serverlessinsight/state.json`
9
+ - **State Management**: Local state tracking in `.serverlessinsight/state-example-app-my-service.json`
10
10
  - **Plan & Apply Flow**: Preview changes before applying them
11
11
  - **Drift Detection**: Detect manual changes made outside ServerlessInsight
12
12
  - **Website Hosting**: Configure static website hosting
@@ -29,8 +29,13 @@ provider:
29
29
  name: tencent
30
30
  region: ap-guangzhou
31
31
 
32
+ app: example-app
32
33
  service: my-service
33
34
 
35
+ backend:
36
+ state_manager:
37
+ type: LOCAL
38
+
34
39
  buckets:
35
40
  my_bucket:
36
41
  name: my-unique-bucket-name-123456 # Must be globally unique
@@ -76,7 +81,7 @@ Common Tencent Cloud regions:
76
81
  Preview changes before deployment:
77
82
 
78
83
  ```bash
79
- si plan my-stack \
84
+ si diff \
80
85
  -f serverless-insight.yml \
81
86
  -r ap-guangzhou \
82
87
  -k YOUR_SECRET_ID \
@@ -95,7 +100,7 @@ Output shows:
95
100
  Apply the infrastructure changes:
96
101
 
97
102
  ```bash
98
- si deploy my-stack \
103
+ si deploy \
99
104
  -f serverless-insight.yml \
100
105
  -r ap-guangzhou \
101
106
  -k YOUR_SECRET_ID \
@@ -106,37 +111,50 @@ The deploy command will:
106
111
 
107
112
  1. Generate a plan for all resources (functions + buckets)
108
113
  2. Execute the plan (create/update/delete buckets)
109
- 3. Save the state to `.serverlessinsight/state.json`
114
+ 3. Save the state to `.serverlessinsight/state-example-app-my-service.json`
110
115
 
111
116
  ### Validate
112
117
 
113
118
  Validate your YAML configuration:
114
119
 
115
120
  ```bash
116
- si validate my-stack -f serverless-insight.yml
121
+ si validate -f serverless-insight.yml
117
122
  ```
118
123
 
119
124
  ## State Management
120
125
 
121
- State is stored locally in `.serverlessinsight/state.json`:
126
+ With the explicit LOCAL backend above, state remains at
127
+ `.serverlessinsight/state-example-app-my-service.json`. The V4 aggregate contains
128
+ independent stage/provider/region partitions, for example after selecting `-s prod`:
122
129
 
123
130
  ```json
124
131
  {
125
- "version": "0.1",
126
- "provider": "tencent",
127
- "resources": {
128
- "buckets.my_bucket": {
129
- "type": "COS_BUCKET",
130
- "physicalId": "my-unique-bucket-name-123456",
131
- "region": "ap-guangzhou",
132
- "configHash": "abc123...",
133
- "lastUpdated": "2025-01-01T12:00:00Z"
132
+ "version": "4.0",
133
+ "app": "example-app",
134
+ "service": "my-service",
135
+ "stages": {
136
+ "prod": {
137
+ "providers": {
138
+ "tencent": {
139
+ "regions": {
140
+ "ap-guangzhou": {
141
+ "lineage": "deployment-uuid",
142
+ "serial": 1,
143
+ "resources": {},
144
+ "shared": {}
145
+ }
146
+ }
147
+ }
148
+ }
134
149
  }
135
150
  }
136
151
  }
137
152
  ```
138
153
 
139
- **Important**: Add `.serverlessinsight/` to your `.gitignore` if you don't want to commit state files.
154
+ The executor works with only the selected partition. Its native IDs and revision are
155
+ preserved when another provider/region is deployed. All partitions in this file share
156
+ one deployment lock. See [deployment state and migration](../docs/regional-deployment-state.md).
157
+ Keep state and credentials out of version control.
140
158
 
141
159
  ## Access Control (ACL)
142
160
 
@@ -185,6 +203,7 @@ buckets:
185
203
  security:
186
204
  acl: PUBLIC_READ # Website content must be publicly readable
187
205
  website:
206
+ code: ./public
188
207
  index: index.html # Default page (also used as error document for SPA routing)
189
208
  ```
190
209
 
@@ -206,8 +225,13 @@ provider:
206
225
  name: tencent
207
226
  region: ap-guangzhou
208
227
 
228
+ app: example-app
209
229
  service: my-full-app
210
230
 
231
+ backend:
232
+ state_manager:
233
+ type: LOCAL
234
+
211
235
  functions:
212
236
  api_function:
213
237
  name: my-api-function
@@ -224,6 +248,7 @@ buckets:
224
248
  security:
225
249
  acl: PUBLIC_READ
226
250
  website:
251
+ code: ./public
227
252
  index: index.html
228
253
  ```
229
254
 
@@ -233,18 +258,18 @@ Running `si deploy` multiple times with the same configuration is safe:
233
258
 
234
259
  ```bash
235
260
  # First run - creates the bucket
236
- si deploy my-stack -f serverless-insight.yml
261
+ si deploy -f serverless-insight.yml
237
262
 
238
263
  # Second run - detects no changes needed
239
- si deploy my-stack -f serverless-insight.yml
264
+ si deploy -f serverless-insight.yml
240
265
  ```
241
266
 
242
267
  ## Drift Detection
243
268
 
244
- If someone modifies the bucket in Tencent Cloud Console, the plan command will detect the drift:
269
+ If someone modifies the bucket in Tencent Cloud Console, the diff command will detect the drift:
245
270
 
246
271
  ```bash
247
- si plan my-stack -f serverless-insight.yml
272
+ si diff -f serverless-insight.yml
248
273
  ```
249
274
 
250
275
  Output will show:
@@ -291,7 +316,7 @@ Run `si deploy` to apply the change.
291
316
 
292
317
  To delete a bucket, remove it from your YAML file and run deploy:
293
318
 
294
- ```yaml
319
+ ```text
295
320
  # Before
296
321
  buckets:
297
322
  my_bucket:
@@ -315,8 +340,13 @@ provider:
315
340
  name: tencent
316
341
  region: ap-guangzhou
317
342
 
343
+ app: example-app
318
344
  service: simple-bucket
319
345
 
346
+ backend:
347
+ state_manager:
348
+ type: LOCAL
349
+
320
350
  buckets:
321
351
  assets:
322
352
  name: my-assets-bucket-20250101
@@ -332,14 +362,20 @@ provider:
332
362
  name: tencent
333
363
  region: ap-guangzhou
334
364
 
365
+ app: example-app
335
366
  service: my-website
336
367
 
368
+ backend:
369
+ state_manager:
370
+ type: LOCAL
371
+
337
372
  buckets:
338
373
  website:
339
374
  name: my-website-bucket-20250101
340
375
  security:
341
376
  acl: PUBLIC_READ
342
377
  website:
378
+ code: ./public
343
379
  index: index.html
344
380
  ```
345
381
 
@@ -351,8 +387,13 @@ provider:
351
387
  name: tencent
352
388
  region: ap-guangzhou
353
389
 
390
+ app: example-app
354
391
  service: multi-bucket-app
355
392
 
393
+ backend:
394
+ state_manager:
395
+ type: LOCAL
396
+
356
397
  buckets:
357
398
  public_assets:
358
399
  name: public-assets-20250101
@@ -369,6 +410,7 @@ buckets:
369
410
  security:
370
411
  acl: PUBLIC_READ
371
412
  website:
413
+ code: ./public
372
414
  index: index.html
373
415
  ```
374
416
 
@@ -394,7 +436,7 @@ Error: `AuthFailure.SecretIdNotFound`
394
436
  export TENCENTCLOUD_SECRET_ID=your_secret_id
395
437
  export TENCENTCLOUD_SECRET_KEY=your_secret_key
396
438
 
397
- si deploy my-stack -f serverless-insight.yml
439
+ si deploy -f serverless-insight.yml
398
440
  ```
399
441
 
400
442
  ### Bucket Not Empty
@@ -421,10 +463,10 @@ If your website is not accessible after deployment:
421
463
 
422
464
  ### State File Conflicts
423
465
 
424
- If you encounter state conflicts, you can:
425
-
426
- 1. Delete `.serverlessinsight/state.json` and re-deploy (will recreate resources)
427
- 2. Manually edit the state file (advanced users only)
466
+ Keep the current state and backups. Confirm App/Service/Stage/Provider/Region and the
467
+ backend location, wait for the active writer, then refetch and re-plan. Write commands
468
+ automatically upgrade released V3 state in place; rerun the original operation to resume
469
+ an interrupted upgrade. Deleting or hand-editing state can lose sibling ownership.
428
470
 
429
471
  ## Limitations
430
472
 
@@ -6,7 +6,7 @@ This guide demonstrates how to use ServerlessInsight with Tencent Cloud SCF usin
6
6
 
7
7
  The Tencent SCF support introduces a Terraform-like infrastructure management approach with:
8
8
 
9
- - **State Management**: Local state tracking in `.serverlessinsight/state.json`
9
+ - **State Management**: Local state tracking in `.serverlessinsight/state-example-app-my-service.json`
10
10
  - **Plan & Apply Flow**: Preview changes before applying them
11
11
  - **Drift Detection**: Detect manual changes made outside ServerlessInsight
12
12
  - **Idempotent Operations**: Safe to re-run deployments
@@ -38,13 +38,18 @@ stages:
38
38
  prod:
39
39
  node_env: production
40
40
 
41
+ app: example-app
41
42
  service: my-service
42
43
 
44
+ backend:
45
+ state_manager:
46
+ type: LOCAL
47
+
43
48
  functions:
44
49
  my_function:
45
50
  name: my-function-name
46
51
  code:
47
- runtime: Nodejs18.15
52
+ runtime: nodejs18
48
53
  handler: index.handler
49
54
  path: path/to/function.zip
50
55
  memory: 512
@@ -69,7 +74,7 @@ functions:
69
74
  Preview changes before deployment:
70
75
 
71
76
  ```bash
72
- si plan my-stack \
77
+ si diff \
73
78
  -f serverless-insight.yml \
74
79
  -r ap-guangzhou \
75
80
  -k YOUR_SECRET_ID \
@@ -88,7 +93,7 @@ Output shows:
88
93
  Apply the infrastructure changes:
89
94
 
90
95
  ```bash
91
- si deploy my-stack \
96
+ si deploy \
92
97
  -f serverless-insight.yml \
93
98
  -r ap-guangzhou \
94
99
  -k YOUR_SECRET_ID \
@@ -99,37 +104,50 @@ The deploy command will:
99
104
 
100
105
  1. Generate a plan
101
106
  2. Execute the plan (create/update/delete functions)
102
- 3. Save the state to `.serverlessinsight/state.json`
107
+ 3. Save the state to `.serverlessinsight/state-example-app-my-service.json`
103
108
 
104
109
  ### Validate
105
110
 
106
111
  Validate your YAML configuration:
107
112
 
108
113
  ```bash
109
- si validate my-stack -f serverless-insight.yml
114
+ si validate -f serverless-insight.yml
110
115
  ```
111
116
 
112
117
  ## State Management
113
118
 
114
- State is stored locally in `.serverlessinsight/state.json`:
119
+ With the explicit LOCAL backend above, state remains at
120
+ `.serverlessinsight/state-example-app-my-service.json`. The V4 aggregate contains
121
+ independent stage/provider/region partitions, for example after selecting `-s prod`:
115
122
 
116
123
  ```json
117
124
  {
118
- "version": "0.1",
119
- "provider": "tencent",
120
- "resources": {
121
- "functions.my_function": {
122
- "type": "SCF",
123
- "physicalId": "my-function-name",
124
- "region": "ap-guangzhou",
125
- "configHash": "abc123...",
126
- "lastUpdated": "2025-01-01T12:00:00Z"
125
+ "version": "4.0",
126
+ "app": "example-app",
127
+ "service": "my-service",
128
+ "stages": {
129
+ "prod": {
130
+ "providers": {
131
+ "tencent": {
132
+ "regions": {
133
+ "ap-guangzhou": {
134
+ "lineage": "deployment-uuid",
135
+ "serial": 1,
136
+ "resources": {},
137
+ "shared": {}
138
+ }
139
+ }
140
+ }
141
+ }
127
142
  }
128
143
  }
129
144
  }
130
145
  ```
131
146
 
132
- **Important**: Add `.serverlessinsight/` to your `.gitignore` if you don't want to commit state files.
147
+ The executor works with only the selected partition. Its native IDs and revision are
148
+ preserved when another provider/region is deployed. All partitions in this file share
149
+ one deployment lock. See [deployment state and migration](../docs/regional-deployment-state.md).
150
+ Keep state and credentials out of version control.
133
151
 
134
152
  ## Idempotency
135
153
 
@@ -137,18 +155,18 @@ Running `si deploy` multiple times with the same configuration is safe:
137
155
 
138
156
  ```bash
139
157
  # First run - creates the function
140
- si deploy my-stack -f serverless-insight.yml
158
+ si deploy -f serverless-insight.yml
141
159
 
142
160
  # Second run - detects no changes needed
143
- si deploy my-stack -f serverless-insight.yml
161
+ si deploy -f serverless-insight.yml
144
162
  ```
145
163
 
146
164
  ## Drift Detection
147
165
 
148
- If someone modifies the function in Tencent Cloud Console, the plan command will detect the drift:
166
+ If someone modifies the function in Tencent Cloud Console, the diff command will detect the drift:
149
167
 
150
168
  ```bash
151
- si plan my-stack -f serverless-insight.yml
169
+ si diff -f serverless-insight.yml
152
170
  ```
153
171
 
154
172
  Output will show:
@@ -186,10 +204,10 @@ Deploy to different stages:
186
204
 
187
205
  ```bash
188
206
  # Deploy to dev
189
- si deploy my-stack -f serverless-insight.yml --stage dev
207
+ si deploy -f serverless-insight.yml --stage dev
190
208
 
191
209
  # Deploy to prod
192
- si deploy my-stack -f serverless-insight.yml --stage prod
210
+ si deploy -f serverless-insight.yml --stage prod
193
211
  ```
194
212
 
195
213
  ## Function Configuration
@@ -239,7 +257,7 @@ Ensure your Secret ID and Secret Key are correct:
239
257
  export TENCENTCLOUD_SECRET_ID=your_secret_id
240
258
  export TENCENTCLOUD_SECRET_KEY=your_secret_key
241
259
 
242
- si deploy my-stack -f serverless-insight.yml
260
+ si deploy -f serverless-insight.yml
243
261
  ```
244
262
 
245
263
  ### Function Not Found
@@ -248,10 +266,10 @@ If you see "ResourceNotFound.FunctionName", the function doesn't exist yet. Run
248
266
 
249
267
  ### State File Conflicts
250
268
 
251
- If you encounter state conflicts, you can:
252
-
253
- 1. Delete `.serverlessinsight/state.json` and re-deploy (will recreate resources)
254
- 2. Manually edit the state file (advanced users only)
269
+ Keep the current state and backups. Confirm App/Service/Stage/Provider/Region and the
270
+ backend location, wait for the active writer, then refetch and re-plan. Write commands
271
+ automatically upgrade released V3 state in place; rerun the original operation to resume
272
+ an interrupted upgrade. Deleting or hand-editing state can lose sibling ownership.
255
273
 
256
274
  ## Limitations
257
275
 
@@ -260,7 +278,7 @@ Current limitations:
260
278
  - No support for VPC configuration
261
279
  - No support for triggers (API Gateway, COS, etc.)
262
280
  - No support for layers
263
- - No remote state backends
281
+ - Local, Bucket and SaaS backends have different lock scopes; choose the backend explicitly when following this Local example.
264
282
  - No cross-resource dependencies
265
283
 
266
284
  These features will be added in future releases.
@@ -1,14 +0,0 @@
1
- {
2
- "version": "3.0",
3
- "provider": "aliyun",
4
- "app": "cdn-flow-app",
5
- "service": "cdn-flow-service",
6
- "stages": {
7
- "dev": {
8
- "resources": {},
9
- "shared": {}
10
- }
11
- },
12
- "lineage": "6d2a231a-895d-4113-a6dc-0a8956d0d700",
13
- "serial": 5
14
- }
@@ -1,32 +0,0 @@
1
- {
2
- "version": "3.0",
3
- "provider": "aliyun",
4
- "app": "iam-test-app",
5
- "service": "iam-test-service",
6
- "stages": {
7
- "dev": {
8
- "resources": {},
9
- "shared": {
10
- "logs.project": {
11
- "mode": "managed",
12
- "region": "cn-hangzhou",
13
- "definition": {
14
- "projectName": "iam-test-app-dev-sls",
15
- "region": "cn-hangzhou",
16
- "stage": "dev"
17
- },
18
- "instances": [
19
- {
20
- "sid": "si:aliyun:sls_project:dev:iam-test-app-dev-sls",
21
- "type": "ALIYUN_SLS_PROJECT",
22
- "id": "iam-test-app-dev-sls"
23
- }
24
- ],
25
- "lastUpdated": "2026-10-24T09:46:08.930Z"
26
- }
27
- }
28
- }
29
- },
30
- "lineage": "85e03b0b-0403-48e5-ba77-e1204bc0bd7f",
31
- "serial": 3
32
- }
@@ -1,90 +0,0 @@
1
- {
2
- "version": "3.0",
3
- "provider": "tencent",
4
- "app": "insight-poc-app",
5
- "service": "insight-poc-tencent",
6
- "stages": {
7
- "default": {
8
- "resources": {
9
- "functions.test_fn": {
10
- "mode": "managed",
11
- "region": "ap-guangzhou",
12
- "definition": {
13
- "functionName": "test-fn",
14
- "runtime": "Nodejs18.15",
15
- "handler": "index.handler",
16
- "memorySize": 512,
17
- "timeout": 10,
18
- "environment": {},
19
- "codeHash": "c96b718fa999add5e047823c3d7abfa1397fa8d0075bc6a4f3592785fcd4b76f",
20
- "vpcConfig": null,
21
- "diskSize": null,
22
- "cfsConfig": null,
23
- "useGpu": null,
24
- "imageConfig": null,
25
- "logEnabled": false
26
- },
27
- "instances": [
28
- {
29
- "sid": "si:tencent:scf:default:test-fn",
30
- "id": "test-fn",
31
- "functionName": "test-fn",
32
- "runtime": "Nodejs18.15",
33
- "handler": "index.handler",
34
- "memorySize": 256,
35
- "timeout": 10,
36
- "environment": {},
37
- "modTime": null,
38
- "codeSha256": null,
39
- "codeInfo": null,
40
- "description": null,
41
- "triggers": [],
42
- "codeSize": null,
43
- "functionVersion": null,
44
- "vpcConfig": {},
45
- "useGpu": null,
46
- "codeResult": null,
47
- "codeError": null,
48
- "errNo": null,
49
- "namespace": null,
50
- "role": null,
51
- "installDependency": null,
52
- "status": "Active",
53
- "statusDesc": null,
54
- "clsLogsetId": null,
55
- "clsTopicId": null,
56
- "functionId": null,
57
- "tags": [],
58
- "eipConfig": {},
59
- "accessInfo": {},
60
- "type": null,
61
- "l5Enable": null,
62
- "layers": [],
63
- "deadLetterConfig": {},
64
- "addTime": null,
65
- "publicNetConfig": {},
66
- "onsEnable": null,
67
- "cfsConfig": {},
68
- "availableStatus": null,
69
- "qualifier": null,
70
- "initTimeout": null,
71
- "statusReasons": [],
72
- "asyncRunEnable": null,
73
- "traceEnable": null,
74
- "imageConfig": {},
75
- "protocolType": null,
76
- "protocolParams": {},
77
- "dnsCache": null,
78
- "intranetConfig": {},
79
- "instanceConcurrencyConfig": {}
80
- }
81
- ],
82
- "lastUpdated": "2026-10-24T09:46:45.563Z"
83
- }
84
- },
85
- "shared": {}
86
- }
87
- },
88
- "lineage": "bd0e7ed3-4d08-4ad7-9544-bff241577f5a",
89
- "serial": 4
90
- }