@geek-fun/serverlessinsight 0.4.0 → 0.5.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/.gitattributes +1 -0
- package/README.md +108 -8
- package/README.zh-CN.md +52 -8
- package/dist/package.json +37 -35
- package/dist/src/commands/deploy.js +17 -7
- package/dist/src/commands/destroy.js +27 -4
- package/dist/src/commands/forceUnlock.js +61 -0
- package/dist/src/commands/index.js +86 -14
- package/dist/src/commands/local.js +10 -1
- package/dist/src/commands/plan.js +33 -0
- package/dist/src/commands/template.js +3 -1
- package/dist/src/commands/validate.js +2 -1
- package/dist/src/common/aliyunClient/apigwOperations.js +652 -0
- package/dist/src/common/aliyunClient/dnsOperations.js +90 -0
- package/dist/src/common/aliyunClient/ecsOperations.js +141 -0
- package/dist/src/common/aliyunClient/esOperations.js +219 -0
- package/dist/src/common/aliyunClient/fc3Operations.js +270 -0
- package/dist/src/common/aliyunClient/index.js +141 -0
- package/dist/src/common/aliyunClient/nasOperations.js +233 -0
- package/dist/src/common/aliyunClient/ossOperations.js +237 -0
- package/dist/src/common/aliyunClient/ramOperations.js +205 -0
- package/dist/src/common/aliyunClient/rdsOperations.js +206 -0
- package/dist/src/common/aliyunClient/slsOperations.js +218 -0
- package/dist/src/common/aliyunClient/tablestoreOperations.js +199 -0
- package/dist/src/common/aliyunClient/types.js +2 -0
- package/dist/src/common/constants.js +7 -1
- package/dist/src/common/context.js +32 -14
- package/dist/src/common/credentials.js +39 -0
- package/dist/src/common/dependencyGraph/graph.js +280 -0
- package/dist/src/common/dependencyGraph/index.js +18 -0
- package/dist/src/common/dependencyGraph/types.js +2 -0
- package/dist/src/common/fileUtils.js +16 -0
- package/dist/src/common/hashUtils.js +121 -0
- package/dist/src/common/iacHelper.js +25 -97
- package/dist/src/common/imsClient.js +4 -0
- package/dist/src/common/index.js +7 -2
- package/dist/src/common/lockManager.js +212 -0
- package/dist/src/common/logger.js +89 -6
- package/dist/src/common/providerEnum.js +2 -3
- package/dist/src/common/runtimeMapper.js +160 -0
- package/dist/src/common/scfClient.js +84 -0
- package/dist/src/common/stateManager.js +107 -0
- package/dist/src/common/tencentClient/cosOperations.js +287 -0
- package/dist/src/common/tencentClient/esOperations.js +156 -0
- package/dist/src/common/tencentClient/index.js +116 -0
- package/dist/src/common/tencentClient/scfOperations.js +141 -0
- package/dist/src/common/tencentClient/tdsqlcOperations.js +211 -0
- package/dist/src/common/tencentClient/types.js +17 -0
- package/dist/src/lang/en.js +254 -0
- package/dist/src/lang/index.js +28 -8
- package/dist/src/lang/zh-CN.js +229 -0
- package/dist/src/parser/bucketParser.js +25 -12
- package/dist/src/parser/databaseParser.js +14 -10
- package/dist/src/parser/functionParser.js +19 -6
- package/dist/src/parser/parseUtils.js +74 -0
- package/dist/src/parser/tableParser.js +19 -17
- package/dist/src/stack/aliyunStack/apigwExecutor.js +84 -0
- package/dist/src/stack/aliyunStack/apigwPlanner.js +118 -0
- package/dist/src/stack/aliyunStack/apigwResource.js +339 -0
- package/dist/src/stack/aliyunStack/apigwTypes.js +125 -0
- package/dist/src/stack/aliyunStack/databaseExecutor.js +112 -0
- package/dist/src/stack/aliyunStack/databasePlanner.js +128 -0
- package/dist/src/stack/aliyunStack/databaseResource.js +228 -0
- package/dist/src/stack/aliyunStack/deployer.js +133 -0
- package/dist/src/stack/aliyunStack/destroyer.js +114 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +141 -0
- package/dist/src/stack/aliyunStack/fc3Executor.js +91 -0
- package/dist/src/stack/aliyunStack/fc3Planner.js +77 -0
- package/dist/src/stack/aliyunStack/fc3Resource.js +511 -0
- package/dist/src/stack/aliyunStack/fc3Types.js +76 -0
- package/dist/src/stack/aliyunStack/index.js +40 -0
- package/dist/src/stack/aliyunStack/ossExecutor.js +91 -0
- package/dist/src/stack/aliyunStack/ossPlanner.js +76 -0
- package/dist/src/stack/aliyunStack/ossResource.js +196 -0
- package/dist/src/stack/aliyunStack/ossTypes.js +50 -0
- package/dist/src/stack/aliyunStack/planner.js +37 -0
- package/dist/src/stack/aliyunStack/rdsTypes.js +217 -0
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +92 -0
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +94 -0
- package/dist/src/stack/aliyunStack/tablestoreResource.js +120 -0
- package/dist/src/stack/aliyunStack/tablestoreTypes.js +77 -0
- package/dist/src/stack/bucketTypes.js +17 -0
- package/dist/src/stack/deploy.js +24 -77
- package/dist/src/stack/localStack/bucket.js +11 -6
- package/dist/src/stack/localStack/event.js +10 -5
- package/dist/src/stack/localStack/function.js +13 -7
- package/dist/src/stack/localStack/functionRunner.js +1 -1
- package/dist/src/stack/localStack/localServer.js +7 -6
- package/dist/src/stack/scfStack/cosExecutor.js +91 -0
- package/dist/src/stack/scfStack/cosPlanner.js +76 -0
- package/dist/src/stack/scfStack/cosResource.js +126 -0
- package/dist/src/stack/scfStack/cosTypes.js +46 -0
- package/dist/src/stack/scfStack/deployer.js +91 -0
- package/dist/src/stack/scfStack/destroyer.js +88 -0
- package/dist/src/stack/scfStack/esServerlessExecutor.js +105 -0
- package/dist/src/stack/scfStack/esServerlessPlanner.js +86 -0
- package/dist/src/stack/scfStack/esServerlessResource.js +94 -0
- package/dist/src/stack/scfStack/esServerlessTypes.js +48 -0
- package/dist/src/stack/scfStack/index.js +35 -0
- package/dist/src/stack/scfStack/planner.js +91 -0
- package/dist/src/stack/scfStack/scfExecutor.js +91 -0
- package/dist/src/stack/scfStack/scfPlanner.js +78 -0
- package/dist/src/stack/scfStack/scfResource.js +216 -0
- package/dist/src/stack/scfStack/scfTypes.js +41 -0
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +105 -0
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +90 -0
- package/dist/src/stack/scfStack/tdsqlcResource.js +146 -0
- package/dist/src/stack/scfStack/tdsqlcTypes.js +59 -0
- package/dist/src/types/domains/lock.js +2 -0
- package/dist/src/types/domains/resolvable.js +2 -0
- package/dist/src/types/domains/state.js +19 -0
- package/dist/src/types/index.js +4 -0
- package/dist/src/validator/bucketSchema.js +4 -10
- package/dist/src/validator/databaseSchema.js +36 -36
- package/dist/src/validator/eventSchema.js +3 -2
- package/dist/src/validator/functionSchema.js +51 -46
- package/dist/src/validator/iacSchema.js +52 -3
- package/dist/src/validator/rootSchema.js +47 -1
- package/dist/src/validator/tableschema.js +9 -8
- package/dist/src/validator/templateRefSchema.js +23 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -35
- package/samples/README_TENCENT_COS.md +486 -0
- package/samples/README_TENCENT_SCF.md +272 -0
- package/samples/aliyun-poc-api.yml +1 -1
- package/samples/aliyun-poc-bucket.yml +0 -1
- package/samples/aliyun-poc-domain.yml +0 -1
- package/samples/aliyun-poc-es.yml +14 -13
- package/samples/aliyun-poc-rds.yml +0 -2
- package/samples/aliyun-poc-table.yml +1 -3
- package/samples/tencent-poc-cos.yml +20 -0
- package/samples/tencent-poc-scf.yml +36 -0
- package/dist/src/commands/index.d.ts +0 -2
- package/dist/src/common/index.d.ts +0 -11
- package/dist/src/common/rosAssets.js +0 -178
- package/dist/src/common/rosClient.js +0 -198
- package/dist/src/index.d.ts +0 -1
- package/dist/src/lang/index.d.ts +0 -3
- package/dist/src/parser/index.d.ts +0 -3
- package/dist/src/stack/index.d.ts +0 -1
- package/dist/src/stack/localStack/index.d.ts +0 -5
- package/dist/src/stack/rfsStack/index.d.ts +0 -9
- package/dist/src/stack/rosStack/bootstrap.js +0 -187
- package/dist/src/stack/rosStack/bucket.js +0 -127
- package/dist/src/stack/rosStack/database.js +0 -313
- package/dist/src/stack/rosStack/event.js +0 -143
- package/dist/src/stack/rosStack/function.js +0 -259
- package/dist/src/stack/rosStack/index.d.ts +0 -7
- package/dist/src/stack/rosStack/index.js +0 -75
- package/dist/src/stack/rosStack/stage.js +0 -46
- package/dist/src/stack/rosStack/table.js +0 -95
- package/dist/src/stack/rosStack/tag.js +0 -11
- package/dist/src/stack/rosStack/vars.js +0 -49
- package/dist/src/types/index.d.ts +0 -55
- package/dist/src/types/localStack/index.d.ts +0 -81
- package/dist/src/validator/index.d.ts +0 -1
- package/layers/si-bootstrap-sdk/Dockerfile-aliyuncli +0 -12
- package/layers/si-bootstrap-sdk/README.md +0 -1
- package/layers/si-bootstrap-sdk/package-lock.json +0 -875
- package/layers/si-bootstrap-sdk/package.json +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Full life cycle cross providers serverless application management for your fast-growing business.",
|
|
5
5
|
"homepage": "https://serverlessinsight.geekfun.club",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"si": "dist/src/commands/index.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "DEBUG=ServerlessInsight jest --runInBand --detectOpenHandles --coverage --coverageReporters json-summary text html lcov",
|
|
12
|
+
"test": "cross-env DEBUG=ServerlessInsight jest --runInBand --detectOpenHandles --coverage --coverageReporters json-summary text html lcov",
|
|
13
13
|
"test:ci": "jest --runInBand --ci --coverage --coverageReporters json-summary text html lcov",
|
|
14
14
|
"build": "tsc --build",
|
|
15
15
|
"lint:fix": "eslint --fix ./",
|
|
@@ -49,54 +49,56 @@
|
|
|
49
49
|
"function"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@alicloud/
|
|
52
|
+
"@alicloud/alidns20150109": "^4.3.1",
|
|
53
|
+
"@alicloud/cloudapi20160714": "^4.7.9",
|
|
54
|
+
"@alicloud/ecs20140526": "^7.6.0",
|
|
55
|
+
"@alicloud/es-serverless20230627": "^2.3.0",
|
|
56
|
+
"@alicloud/fc20230330": "^4.6.8",
|
|
57
|
+
"@alicloud/ims20190815": "^2.3.3",
|
|
58
|
+
"@alicloud/nas20170626": "^3.3.1",
|
|
53
59
|
"@alicloud/openapi-client": "^0.4.15",
|
|
54
|
-
"@alicloud/
|
|
55
|
-
"@alicloud/
|
|
56
|
-
"@alicloud/
|
|
57
|
-
"
|
|
58
|
-
"@alicloud/ros-cdk-elasticsearchserverless": "^1.11.0",
|
|
59
|
-
"@alicloud/ros-cdk-fc3": "^1.11.0",
|
|
60
|
-
"@alicloud/ros-cdk-nas": "^1.11.0",
|
|
61
|
-
"@alicloud/ros-cdk-oss": "^1.11.0",
|
|
62
|
-
"@alicloud/ros-cdk-ossdeployment": "^1.11.0",
|
|
63
|
-
"@alicloud/ros-cdk-ots": "^1.11.0",
|
|
64
|
-
"@alicloud/ros-cdk-ram": "^1.11.0",
|
|
65
|
-
"@alicloud/ros-cdk-rds": "^1.11.0",
|
|
66
|
-
"@alicloud/ros-cdk-ros": "^1.11.0",
|
|
67
|
-
"@alicloud/ros-cdk-sls": "^1.11.0",
|
|
68
|
-
"@alicloud/ros-cdk-vpc": "^1.11.0",
|
|
69
|
-
"@alicloud/ros20190910": "^3.6.0",
|
|
70
|
-
"ajv": "^8.17.1",
|
|
60
|
+
"@alicloud/ram20150501": "^1.2.0",
|
|
61
|
+
"@alicloud/rds20140815": "^15.5.1",
|
|
62
|
+
"@alicloud/sls20201230": "^5.9.0",
|
|
63
|
+
"ajv": "^8.18.0",
|
|
71
64
|
"ali-oss": "^6.23.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"i": "^0.3.7",
|
|
65
|
+
"commander": "^14.0.3",
|
|
66
|
+
"cos-nodejs-sdk-v5": "^2.16.0-beta.8",
|
|
75
67
|
"i18n": "^0.15.3",
|
|
68
|
+
"iconv-lite": "^0.7.2",
|
|
76
69
|
"jszip": "^3.10.1",
|
|
77
|
-
"lodash": "^4.17.
|
|
78
|
-
"
|
|
79
|
-
"pino": "^10.1.0",
|
|
70
|
+
"lodash": "^4.17.23",
|
|
71
|
+
"pino": "^10.3.1",
|
|
80
72
|
"pino-pretty": "^13.1.3",
|
|
73
|
+
"tablestore": "^5.6.3",
|
|
74
|
+
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.188",
|
|
75
|
+
"tencentcloud-sdk-nodejs-es": "^4.1.183",
|
|
76
|
+
"tencentcloud-sdk-nodejs-scf": "^4.1.168",
|
|
81
77
|
"yaml": "^2.8.2"
|
|
82
78
|
},
|
|
83
79
|
"devDependencies": {
|
|
84
|
-
"@
|
|
80
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
81
|
+
"@eslint/js": "^10.0.1",
|
|
82
|
+
"@types/ali-oss": "^6.23.3",
|
|
85
83
|
"@types/i18n": "^0.13.12",
|
|
86
84
|
"@types/jest": "^30.0.0",
|
|
87
|
-
"@types/lodash": "^4.17.
|
|
88
|
-
"@types/node": "^25.
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
90
|
-
"@typescript-eslint/parser": "^8.
|
|
91
|
-
"
|
|
85
|
+
"@types/lodash": "^4.17.24",
|
|
86
|
+
"@types/node": "^25.3.2",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
88
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
89
|
+
"cross-env": "^10.1.0",
|
|
90
|
+
"eslint": "^10.0.2",
|
|
92
91
|
"eslint-config-prettier": "^10.1.8",
|
|
93
|
-
"eslint-plugin-prettier": "^5.5.
|
|
94
|
-
"globals": "^
|
|
92
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
93
|
+
"globals": "^17.3.0",
|
|
95
94
|
"husky": "^9.1.7",
|
|
96
95
|
"jest": "^30.2.0",
|
|
97
|
-
"prettier": "^3.
|
|
96
|
+
"prettier": "^3.8.1",
|
|
98
97
|
"ts-jest": "^29.4.6",
|
|
99
98
|
"ts-node": "^10.9.2",
|
|
100
99
|
"typescript": "^5.9.3"
|
|
100
|
+
},
|
|
101
|
+
"overrides": {
|
|
102
|
+
"fast-xml-parser": ">=5.3.8"
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
# Tencent Cloud COS (Cloud Object Storage) Support
|
|
2
|
+
|
|
3
|
+
This guide demonstrates how to use ServerlessInsight with Tencent Cloud COS buckets using the state-based deployment engine.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Tencent COS support provides full lifecycle management for cloud storage buckets with:
|
|
8
|
+
|
|
9
|
+
- **State Management**: Local state tracking in `.serverlessinsight/state.json`
|
|
10
|
+
- **Plan & Apply Flow**: Preview changes before applying them
|
|
11
|
+
- **Drift Detection**: Detect manual changes made outside ServerlessInsight
|
|
12
|
+
- **Website Hosting**: Configure static website hosting with error pages
|
|
13
|
+
- **Access Control**: Configure bucket ACL (private, public-read, public-read-write)
|
|
14
|
+
- **Idempotent Operations**: Safe to re-run deployments
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
1. Tencent Cloud account with API credentials
|
|
19
|
+
2. ServerlessInsight CLI installed
|
|
20
|
+
3. Bucket name must be globally unique across all Tencent Cloud users
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
Create a `serverless-insight.yml` file:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
version: 0.0.1
|
|
28
|
+
provider:
|
|
29
|
+
name: tencent
|
|
30
|
+
region: ap-guangzhou
|
|
31
|
+
|
|
32
|
+
service: my-service
|
|
33
|
+
|
|
34
|
+
buckets:
|
|
35
|
+
my_bucket:
|
|
36
|
+
name: my-unique-bucket-name-123456 # Must be globally unique
|
|
37
|
+
security:
|
|
38
|
+
acl: PUBLIC_READ # Optional: PRIVATE, PUBLIC_READ, or PUBLIC_READ_WRITE
|
|
39
|
+
website: # Optional: Enable static website hosting
|
|
40
|
+
code: dist # Local directory to deploy (not implemented yet)
|
|
41
|
+
index: index.html
|
|
42
|
+
error_page: 404.html
|
|
43
|
+
error_code: 404
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Bucket Naming Requirements
|
|
47
|
+
|
|
48
|
+
Bucket names in Tencent COS must:
|
|
49
|
+
|
|
50
|
+
- Be globally unique across all Tencent Cloud users
|
|
51
|
+
- Be 1-50 characters long
|
|
52
|
+
- Contain only lowercase letters, numbers, and hyphens (-)
|
|
53
|
+
- Start and end with a lowercase letter or number
|
|
54
|
+
|
|
55
|
+
Example valid names:
|
|
56
|
+
|
|
57
|
+
- `my-app-bucket-20250101`
|
|
58
|
+
- `company-static-assets`
|
|
59
|
+
- `user123-data-bucket`
|
|
60
|
+
|
|
61
|
+
## Supported Regions
|
|
62
|
+
|
|
63
|
+
Common Tencent Cloud regions:
|
|
64
|
+
|
|
65
|
+
- `ap-guangzhou` - Guangzhou
|
|
66
|
+
- `ap-shanghai` - Shanghai
|
|
67
|
+
- `ap-beijing` - Beijing
|
|
68
|
+
- `ap-chengdu` - Chengdu
|
|
69
|
+
- `ap-hongkong` - Hong Kong
|
|
70
|
+
- `ap-singapore` - Singapore
|
|
71
|
+
- `na-siliconvalley` - Silicon Valley
|
|
72
|
+
- `na-ashburn` - Virginia
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
### Plan
|
|
77
|
+
|
|
78
|
+
Preview changes before deployment:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
si plan my-stack \
|
|
82
|
+
-f serverless-insight.yml \
|
|
83
|
+
-r ap-guangzhou \
|
|
84
|
+
-k YOUR_SECRET_ID \
|
|
85
|
+
-x YOUR_SECRET_KEY
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Output shows:
|
|
89
|
+
|
|
90
|
+
- Buckets to be **created** (green `+`)
|
|
91
|
+
- Buckets to be **updated** (yellow `~`)
|
|
92
|
+
- Buckets to be **deleted** (red `-`)
|
|
93
|
+
- Buckets with **no changes** (blue `=`)
|
|
94
|
+
|
|
95
|
+
### Deploy
|
|
96
|
+
|
|
97
|
+
Apply the infrastructure changes:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
si deploy my-stack \
|
|
101
|
+
-f serverless-insight.yml \
|
|
102
|
+
-r ap-guangzhou \
|
|
103
|
+
-k YOUR_SECRET_ID \
|
|
104
|
+
-x YOUR_SECRET_KEY
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The deploy command will:
|
|
108
|
+
|
|
109
|
+
1. Generate a plan for all resources (functions + buckets)
|
|
110
|
+
2. Execute the plan (create/update/delete buckets)
|
|
111
|
+
3. Save the state to `.serverlessinsight/state.json`
|
|
112
|
+
|
|
113
|
+
### Validate
|
|
114
|
+
|
|
115
|
+
Validate your YAML configuration:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
si validate my-stack -f serverless-insight.yml
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## State Management
|
|
122
|
+
|
|
123
|
+
State is stored locally in `.serverlessinsight/state.json`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"version": "0.1",
|
|
128
|
+
"provider": "tencent",
|
|
129
|
+
"resources": {
|
|
130
|
+
"buckets.my_bucket": {
|
|
131
|
+
"type": "COS_BUCKET",
|
|
132
|
+
"physicalId": "my-unique-bucket-name-123456",
|
|
133
|
+
"region": "ap-guangzhou",
|
|
134
|
+
"configHash": "abc123...",
|
|
135
|
+
"lastUpdated": "2025-01-01T12:00:00Z"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Important**: Add `.serverlessinsight/` to your `.gitignore` if you don't want to commit state files.
|
|
142
|
+
|
|
143
|
+
## Access Control (ACL)
|
|
144
|
+
|
|
145
|
+
Configure bucket permissions using the `security.acl` field:
|
|
146
|
+
|
|
147
|
+
### Private Bucket
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
buckets:
|
|
151
|
+
my_bucket:
|
|
152
|
+
name: my-private-bucket
|
|
153
|
+
security:
|
|
154
|
+
acl: PRIVATE # Only bucket owner has access
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Public Read Bucket
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
buckets:
|
|
161
|
+
my_bucket:
|
|
162
|
+
name: my-public-bucket
|
|
163
|
+
security:
|
|
164
|
+
acl: PUBLIC_READ # Anyone can read, only owner can write
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Public Read-Write Bucket (Not Recommended)
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
buckets:
|
|
171
|
+
my_bucket:
|
|
172
|
+
name: my-open-bucket
|
|
173
|
+
security:
|
|
174
|
+
acl: PUBLIC_READ_WRITE # Anyone can read and write
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Security Note**: `PUBLIC_READ_WRITE` allows anyone to upload files to your bucket, which may incur unexpected costs. Use with caution.
|
|
178
|
+
|
|
179
|
+
## Website Hosting
|
|
180
|
+
|
|
181
|
+
Enable static website hosting for your bucket:
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
buckets:
|
|
185
|
+
my_website_bucket:
|
|
186
|
+
name: my-website-bucket
|
|
187
|
+
security:
|
|
188
|
+
acl: PUBLIC_READ # Website content must be publicly readable
|
|
189
|
+
website:
|
|
190
|
+
index: index.html # Default page
|
|
191
|
+
error_page: 404.html # Error page
|
|
192
|
+
error_code: 404 # HTTP error code
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
After deployment, your website will be accessible at:
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
http://my-website-bucket.cos-website.ap-guangzhou.myqcloud.com
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Note**: The `website.code` field is defined but automatic file upload is not yet implemented. You'll need to manually upload your website files using the Tencent COS console or CLI.
|
|
202
|
+
|
|
203
|
+
## Combining Functions and Buckets
|
|
204
|
+
|
|
205
|
+
You can deploy functions and buckets together:
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
version: 0.0.1
|
|
209
|
+
provider:
|
|
210
|
+
name: tencent
|
|
211
|
+
region: ap-guangzhou
|
|
212
|
+
|
|
213
|
+
service: my-full-app
|
|
214
|
+
|
|
215
|
+
functions:
|
|
216
|
+
api_function:
|
|
217
|
+
name: my-api-function
|
|
218
|
+
code:
|
|
219
|
+
runtime: nodejs18
|
|
220
|
+
handler: index.handler
|
|
221
|
+
path: functions/api.zip
|
|
222
|
+
memory: 512
|
|
223
|
+
timeout: 10
|
|
224
|
+
|
|
225
|
+
buckets:
|
|
226
|
+
static_assets:
|
|
227
|
+
name: my-static-assets-123
|
|
228
|
+
security:
|
|
229
|
+
acl: PUBLIC_READ
|
|
230
|
+
website:
|
|
231
|
+
index: index.html
|
|
232
|
+
error_page: 404.html
|
|
233
|
+
error_code: 404
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Idempotency
|
|
237
|
+
|
|
238
|
+
Running `si deploy` multiple times with the same configuration is safe:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# First run - creates the bucket
|
|
242
|
+
si deploy my-stack -f serverless-insight.yml
|
|
243
|
+
|
|
244
|
+
# Second run - detects no changes needed
|
|
245
|
+
si deploy my-stack -f serverless-insight.yml
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Drift Detection
|
|
249
|
+
|
|
250
|
+
If someone modifies the bucket in Tencent Cloud Console, the plan command will detect the drift:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
si plan my-stack -f serverless-insight.yml
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Output will show:
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
[UPDATE] Resources to be updated:
|
|
260
|
+
~ buckets.my_bucket (COS_BUCKET)
|
|
261
|
+
[DRIFTED] Remote configuration differs from state
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Updating Buckets
|
|
265
|
+
|
|
266
|
+
### Change ACL
|
|
267
|
+
|
|
268
|
+
Update the access control:
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
buckets:
|
|
272
|
+
my_bucket:
|
|
273
|
+
name: my-bucket
|
|
274
|
+
security:
|
|
275
|
+
acl: PRIVATE # Changed from PUBLIC_READ to PRIVATE
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Run `si deploy` to apply the change.
|
|
279
|
+
|
|
280
|
+
### Add Website Hosting
|
|
281
|
+
|
|
282
|
+
Add website configuration to an existing bucket:
|
|
283
|
+
|
|
284
|
+
```yaml
|
|
285
|
+
buckets:
|
|
286
|
+
my_bucket:
|
|
287
|
+
name: my-bucket
|
|
288
|
+
security:
|
|
289
|
+
acl: PUBLIC_READ
|
|
290
|
+
website: # Added website configuration
|
|
291
|
+
index: index.html
|
|
292
|
+
error_page: 404.html
|
|
293
|
+
error_code: 404
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Run `si deploy` to apply the change.
|
|
297
|
+
|
|
298
|
+
## Deleting Buckets
|
|
299
|
+
|
|
300
|
+
To delete a bucket, remove it from your YAML file and run deploy:
|
|
301
|
+
|
|
302
|
+
```yaml
|
|
303
|
+
# Before
|
|
304
|
+
buckets:
|
|
305
|
+
my_bucket:
|
|
306
|
+
name: my-bucket
|
|
307
|
+
|
|
308
|
+
# After - bucket removed
|
|
309
|
+
buckets: {}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Run `si deploy` to delete the bucket.
|
|
313
|
+
|
|
314
|
+
**Warning**: The bucket must be empty before it can be deleted. If the bucket contains objects, the deletion will fail.
|
|
315
|
+
|
|
316
|
+
## Examples
|
|
317
|
+
|
|
318
|
+
### Simple Public Bucket
|
|
319
|
+
|
|
320
|
+
```yaml
|
|
321
|
+
version: 0.0.1
|
|
322
|
+
provider:
|
|
323
|
+
name: tencent
|
|
324
|
+
region: ap-guangzhou
|
|
325
|
+
|
|
326
|
+
service: simple-bucket
|
|
327
|
+
|
|
328
|
+
buckets:
|
|
329
|
+
assets:
|
|
330
|
+
name: my-assets-bucket-20250101
|
|
331
|
+
security:
|
|
332
|
+
acl: PUBLIC_READ
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Website Hosting Bucket
|
|
336
|
+
|
|
337
|
+
```yaml
|
|
338
|
+
version: 0.0.1
|
|
339
|
+
provider:
|
|
340
|
+
name: tencent
|
|
341
|
+
region: ap-guangzhou
|
|
342
|
+
|
|
343
|
+
service: my-website
|
|
344
|
+
|
|
345
|
+
buckets:
|
|
346
|
+
website:
|
|
347
|
+
name: my-website-bucket-20250101
|
|
348
|
+
security:
|
|
349
|
+
acl: PUBLIC_READ
|
|
350
|
+
website:
|
|
351
|
+
index: index.html
|
|
352
|
+
error_page: error.html
|
|
353
|
+
error_code: 404
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Multiple Buckets
|
|
357
|
+
|
|
358
|
+
```yaml
|
|
359
|
+
version: 0.0.1
|
|
360
|
+
provider:
|
|
361
|
+
name: tencent
|
|
362
|
+
region: ap-guangzhou
|
|
363
|
+
|
|
364
|
+
service: multi-bucket-app
|
|
365
|
+
|
|
366
|
+
buckets:
|
|
367
|
+
public_assets:
|
|
368
|
+
name: public-assets-20250101
|
|
369
|
+
security:
|
|
370
|
+
acl: PUBLIC_READ
|
|
371
|
+
|
|
372
|
+
private_data:
|
|
373
|
+
name: private-data-20250101
|
|
374
|
+
security:
|
|
375
|
+
acl: PRIVATE
|
|
376
|
+
|
|
377
|
+
website:
|
|
378
|
+
name: website-20250101
|
|
379
|
+
security:
|
|
380
|
+
acl: PUBLIC_READ
|
|
381
|
+
website:
|
|
382
|
+
index: index.html
|
|
383
|
+
error_page: 404.html
|
|
384
|
+
error_code: 404
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Troubleshooting
|
|
388
|
+
|
|
389
|
+
### Bucket Name Already Exists
|
|
390
|
+
|
|
391
|
+
Error: `BucketAlreadyExists` or `BucketAlreadyOwnedByYou`
|
|
392
|
+
|
|
393
|
+
**Solution**: Bucket names must be globally unique. Try a different name with random suffix:
|
|
394
|
+
|
|
395
|
+
```yaml
|
|
396
|
+
name: my-bucket-a1b2c3d4e5
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Authentication Errors
|
|
400
|
+
|
|
401
|
+
Error: `AuthFailure.SecretIdNotFound`
|
|
402
|
+
|
|
403
|
+
**Solution**: Ensure your Secret ID and Secret Key are correct:
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
export TENCENTCLOUD_SECRET_ID=your_secret_id
|
|
407
|
+
export TENCENTCLOUD_SECRET_KEY=your_secret_key
|
|
408
|
+
|
|
409
|
+
si deploy my-stack -f serverless-insight.yml
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Bucket Not Empty
|
|
413
|
+
|
|
414
|
+
Error: `BucketNotEmpty` when deleting
|
|
415
|
+
|
|
416
|
+
**Solution**: Empty the bucket before deletion using Tencent Cloud Console or CLI:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# Using Tencent Cloud CLI (coscmd)
|
|
420
|
+
coscmd delete -r -f /
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Website Not Accessible
|
|
424
|
+
|
|
425
|
+
If your website is not accessible after deployment:
|
|
426
|
+
|
|
427
|
+
1. Verify ACL is set to `PUBLIC_READ`
|
|
428
|
+
2. Check that `index` and `error_page` files exist in the bucket
|
|
429
|
+
3. Access the website using the correct URL format:
|
|
430
|
+
```
|
|
431
|
+
http://{bucket-name}.cos-website.{region}.myqcloud.com
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### State File Conflicts
|
|
435
|
+
|
|
436
|
+
If you encounter state conflicts, you can:
|
|
437
|
+
|
|
438
|
+
1. Delete `.serverlessinsight/state.json` and re-deploy (will recreate resources)
|
|
439
|
+
2. Manually edit the state file (advanced users only)
|
|
440
|
+
|
|
441
|
+
## Limitations
|
|
442
|
+
|
|
443
|
+
Current limitations:
|
|
444
|
+
|
|
445
|
+
- No automatic file upload from `website.code` directory (planned)
|
|
446
|
+
- No support for bucket lifecycle policies
|
|
447
|
+
- No support for bucket replication
|
|
448
|
+
- No support for bucket logging
|
|
449
|
+
- No support for bucket tags
|
|
450
|
+
- No support for bucket encryption (SSE)
|
|
451
|
+
- No cross-resource dependencies
|
|
452
|
+
|
|
453
|
+
These features will be added in future releases.
|
|
454
|
+
|
|
455
|
+
## Cost Considerations
|
|
456
|
+
|
|
457
|
+
Tencent COS charges for:
|
|
458
|
+
|
|
459
|
+
- **Storage**: Amount of data stored (GB/month)
|
|
460
|
+
- **Requests**: Number of API requests (read/write)
|
|
461
|
+
- **Traffic**: Data transfer out (GB)
|
|
462
|
+
- **Website Hosting**: No additional charge for hosting feature
|
|
463
|
+
|
|
464
|
+
Public buckets (`PUBLIC_READ` or `PUBLIC_READ_WRITE`) can incur higher traffic costs if content is heavily accessed. Consider using CDN for high-traffic websites.
|
|
465
|
+
|
|
466
|
+
## Security Best Practices
|
|
467
|
+
|
|
468
|
+
1. **Use PRIVATE for sensitive data**: Don't expose confidential data publicly
|
|
469
|
+
2. **Enable encryption**: Use server-side encryption for sensitive data (coming soon)
|
|
470
|
+
3. **Limit bucket permissions**: Use least privilege principle
|
|
471
|
+
4. **Monitor access**: Enable access logging to track who accesses your buckets (coming soon)
|
|
472
|
+
5. **Use CDN**: Serve public content through Tencent Cloud CDN for better security and performance
|
|
473
|
+
|
|
474
|
+
## Next Steps
|
|
475
|
+
|
|
476
|
+
1. Try the example: `samples/tencent-poc-cos.yml`
|
|
477
|
+
2. Combine with functions: See `samples/tencent-poc-scf.yml`
|
|
478
|
+
3. Read the [main documentation](../README.md)
|
|
479
|
+
4. Explore other cloud providers (Aliyun, Huawei)
|
|
480
|
+
5. Check Tencent Cloud COS documentation: https://cloud.tencent.com/document/product/436
|
|
481
|
+
|
|
482
|
+
## Related Documentation
|
|
483
|
+
|
|
484
|
+
- [Tencent SCF Support](./README_TENCENT_SCF.md) - Serverless functions
|
|
485
|
+
- [Main README](../README.md) - General documentation
|
|
486
|
+
- [Aliyun Bucket Support](../samples/aliyun-poc-bucket.yml) - Compare with Aliyun implementation
|