@geek-fun/serverlessinsight 0.4.1 → 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.
Files changed (164) hide show
  1. package/.gitattributes +1 -0
  2. package/README.md +108 -8
  3. package/README.zh-CN.md +52 -8
  4. package/dist/package.json +37 -35
  5. package/dist/src/commands/deploy.js +17 -7
  6. package/dist/src/commands/destroy.js +27 -4
  7. package/dist/src/commands/forceUnlock.js +61 -0
  8. package/dist/src/commands/index.js +41 -5
  9. package/dist/src/commands/local.js +10 -1
  10. package/dist/src/commands/plan.js +33 -0
  11. package/dist/src/commands/template.js +1 -1
  12. package/dist/src/commands/validate.js +2 -1
  13. package/dist/src/common/aliyunClient/apigwOperations.js +652 -0
  14. package/dist/src/common/aliyunClient/dnsOperations.js +90 -0
  15. package/dist/src/common/aliyunClient/ecsOperations.js +141 -0
  16. package/dist/src/common/aliyunClient/esOperations.js +219 -0
  17. package/dist/src/common/aliyunClient/fc3Operations.js +270 -0
  18. package/dist/src/common/aliyunClient/index.js +141 -0
  19. package/dist/src/common/aliyunClient/nasOperations.js +233 -0
  20. package/dist/src/common/aliyunClient/ossOperations.js +237 -0
  21. package/dist/src/common/aliyunClient/ramOperations.js +205 -0
  22. package/dist/src/common/aliyunClient/rdsOperations.js +206 -0
  23. package/dist/src/common/aliyunClient/slsOperations.js +218 -0
  24. package/dist/src/common/aliyunClient/tablestoreOperations.js +199 -0
  25. package/dist/src/common/aliyunClient/types.js +2 -0
  26. package/dist/src/common/constants.js +6 -1
  27. package/dist/src/common/context.js +13 -3
  28. package/dist/src/common/credentials.js +30 -6
  29. package/dist/src/common/dependencyGraph/graph.js +280 -0
  30. package/dist/src/common/dependencyGraph/index.js +18 -0
  31. package/dist/src/common/dependencyGraph/types.js +2 -0
  32. package/dist/src/common/fileUtils.js +16 -0
  33. package/dist/src/common/hashUtils.js +121 -0
  34. package/dist/src/common/iacHelper.js +25 -97
  35. package/dist/src/common/imsClient.js +4 -0
  36. package/dist/src/common/index.js +6 -2
  37. package/dist/src/common/lockManager.js +212 -0
  38. package/dist/src/common/logger.js +87 -10
  39. package/dist/src/common/providerEnum.js +2 -3
  40. package/dist/src/common/runtimeMapper.js +160 -0
  41. package/dist/src/common/scfClient.js +84 -0
  42. package/dist/src/common/stateManager.js +107 -0
  43. package/dist/src/common/tencentClient/cosOperations.js +287 -0
  44. package/dist/src/common/tencentClient/esOperations.js +156 -0
  45. package/dist/src/common/tencentClient/index.js +116 -0
  46. package/dist/src/common/tencentClient/scfOperations.js +141 -0
  47. package/dist/src/common/tencentClient/tdsqlcOperations.js +211 -0
  48. package/dist/src/common/tencentClient/types.js +17 -0
  49. package/dist/src/lang/en.js +254 -0
  50. package/dist/src/lang/index.js +28 -8
  51. package/dist/src/lang/zh-CN.js +229 -0
  52. package/dist/src/parser/bucketParser.js +25 -12
  53. package/dist/src/parser/databaseParser.js +14 -10
  54. package/dist/src/parser/functionParser.js +19 -6
  55. package/dist/src/parser/parseUtils.js +74 -0
  56. package/dist/src/parser/tableParser.js +19 -17
  57. package/dist/src/stack/aliyunStack/apigwExecutor.js +84 -0
  58. package/dist/src/stack/aliyunStack/apigwPlanner.js +118 -0
  59. package/dist/src/stack/aliyunStack/apigwResource.js +339 -0
  60. package/dist/src/stack/aliyunStack/apigwTypes.js +125 -0
  61. package/dist/src/stack/aliyunStack/databaseExecutor.js +112 -0
  62. package/dist/src/stack/aliyunStack/databasePlanner.js +128 -0
  63. package/dist/src/stack/aliyunStack/databaseResource.js +228 -0
  64. package/dist/src/stack/aliyunStack/deployer.js +133 -0
  65. package/dist/src/stack/aliyunStack/destroyer.js +114 -0
  66. package/dist/src/stack/aliyunStack/esServerlessTypes.js +141 -0
  67. package/dist/src/stack/aliyunStack/fc3Executor.js +91 -0
  68. package/dist/src/stack/aliyunStack/fc3Planner.js +77 -0
  69. package/dist/src/stack/aliyunStack/fc3Resource.js +511 -0
  70. package/dist/src/stack/aliyunStack/fc3Types.js +76 -0
  71. package/dist/src/stack/aliyunStack/index.js +40 -0
  72. package/dist/src/stack/aliyunStack/ossExecutor.js +91 -0
  73. package/dist/src/stack/aliyunStack/ossPlanner.js +76 -0
  74. package/dist/src/stack/aliyunStack/ossResource.js +196 -0
  75. package/dist/src/stack/aliyunStack/ossTypes.js +50 -0
  76. package/dist/src/stack/aliyunStack/planner.js +37 -0
  77. package/dist/src/stack/aliyunStack/rdsTypes.js +217 -0
  78. package/dist/src/stack/aliyunStack/tablestoreExecutor.js +92 -0
  79. package/dist/src/stack/aliyunStack/tablestorePlanner.js +94 -0
  80. package/dist/src/stack/aliyunStack/tablestoreResource.js +120 -0
  81. package/dist/src/stack/aliyunStack/tablestoreTypes.js +77 -0
  82. package/dist/src/stack/bucketTypes.js +17 -0
  83. package/dist/src/stack/deploy.js +24 -77
  84. package/dist/src/stack/localStack/bucket.js +11 -6
  85. package/dist/src/stack/localStack/event.js +10 -5
  86. package/dist/src/stack/localStack/function.js +13 -7
  87. package/dist/src/stack/localStack/functionRunner.js +1 -1
  88. package/dist/src/stack/localStack/localServer.js +7 -6
  89. package/dist/src/stack/scfStack/cosExecutor.js +91 -0
  90. package/dist/src/stack/scfStack/cosPlanner.js +76 -0
  91. package/dist/src/stack/scfStack/cosResource.js +126 -0
  92. package/dist/src/stack/scfStack/cosTypes.js +46 -0
  93. package/dist/src/stack/scfStack/deployer.js +91 -0
  94. package/dist/src/stack/scfStack/destroyer.js +88 -0
  95. package/dist/src/stack/scfStack/esServerlessExecutor.js +105 -0
  96. package/dist/src/stack/scfStack/esServerlessPlanner.js +86 -0
  97. package/dist/src/stack/scfStack/esServerlessResource.js +94 -0
  98. package/dist/src/stack/scfStack/esServerlessTypes.js +48 -0
  99. package/dist/src/stack/scfStack/index.js +35 -0
  100. package/dist/src/stack/scfStack/planner.js +91 -0
  101. package/dist/src/stack/scfStack/scfExecutor.js +91 -0
  102. package/dist/src/stack/scfStack/scfPlanner.js +78 -0
  103. package/dist/src/stack/scfStack/scfResource.js +216 -0
  104. package/dist/src/stack/scfStack/scfTypes.js +41 -0
  105. package/dist/src/stack/scfStack/tdsqlcExecutor.js +105 -0
  106. package/dist/src/stack/scfStack/tdsqlcPlanner.js +90 -0
  107. package/dist/src/stack/scfStack/tdsqlcResource.js +146 -0
  108. package/dist/src/stack/scfStack/tdsqlcTypes.js +59 -0
  109. package/dist/src/types/domains/lock.js +2 -0
  110. package/dist/src/types/domains/resolvable.js +2 -0
  111. package/dist/src/types/domains/state.js +19 -0
  112. package/dist/src/types/index.js +4 -0
  113. package/dist/src/validator/bucketSchema.js +4 -10
  114. package/dist/src/validator/databaseSchema.js +36 -36
  115. package/dist/src/validator/eventSchema.js +3 -2
  116. package/dist/src/validator/functionSchema.js +51 -46
  117. package/dist/src/validator/iacSchema.js +35 -1
  118. package/dist/src/validator/rootSchema.js +1 -1
  119. package/dist/src/validator/tableschema.js +9 -8
  120. package/dist/src/validator/templateRefSchema.js +23 -0
  121. package/dist/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +37 -35
  123. package/samples/README_TENCENT_COS.md +486 -0
  124. package/samples/README_TENCENT_SCF.md +272 -0
  125. package/samples/aliyun-poc-api.yml +1 -1
  126. package/samples/aliyun-poc-bucket.yml +0 -1
  127. package/samples/aliyun-poc-domain.yml +0 -1
  128. package/samples/aliyun-poc-es.yml +4 -7
  129. package/samples/aliyun-poc-rds.yml +0 -2
  130. package/samples/aliyun-poc-table.yml +1 -3
  131. package/samples/tencent-poc-cos.yml +20 -0
  132. package/samples/tencent-poc-scf.yml +36 -0
  133. package/dist/src/commands/index.d.ts +0 -2
  134. package/dist/src/common/index.d.ts +0 -12
  135. package/dist/src/common/rosAssets.js +0 -178
  136. package/dist/src/common/rosClient.js +0 -201
  137. package/dist/src/index.d.ts +0 -1
  138. package/dist/src/lang/index.d.ts +0 -3
  139. package/dist/src/parser/index.d.ts +0 -3
  140. package/dist/src/stack/index.d.ts +0 -1
  141. package/dist/src/stack/localStack/index.d.ts +0 -5
  142. package/dist/src/stack/rfsStack/index.d.ts +0 -9
  143. package/dist/src/stack/rosStack/bootstrap.js +0 -187
  144. package/dist/src/stack/rosStack/bucket.js +0 -127
  145. package/dist/src/stack/rosStack/database.js +0 -313
  146. package/dist/src/stack/rosStack/event.js +0 -143
  147. package/dist/src/stack/rosStack/function.js +0 -259
  148. package/dist/src/stack/rosStack/index.d.ts +0 -7
  149. package/dist/src/stack/rosStack/index.js +0 -75
  150. package/dist/src/stack/rosStack/stage.js +0 -46
  151. package/dist/src/stack/rosStack/table.js +0 -95
  152. package/dist/src/stack/rosStack/tag.js +0 -11
  153. package/dist/src/stack/rosStack/vars.js +0 -49
  154. package/dist/src/types/index.d.ts +0 -55
  155. package/dist/src/types/localStack/index.d.ts +0 -81
  156. package/dist/src/validator/index.d.ts +0 -1
  157. package/layers/si-bootstrap-sdk/Dockerfile-aliyuncli +0 -12
  158. package/layers/si-bootstrap-sdk/README.md +0 -64
  159. package/layers/si-bootstrap-sdk/package-lock.json +0 -881
  160. package/layers/si-bootstrap-sdk/package.json +0 -33
  161. package/layers/si-bootstrap-sdk/support/operation-collection/README.md +0 -47
  162. package/layers/si-bootstrap-sdk/support/operation-collection/package-lock.json +0 -298
  163. package/layers/si-bootstrap-sdk/support/operation-collection/package.json +0 -18
  164. package/layers/si-bootstrap-sdk/support/operation-collection/publish.js +0 -257
@@ -1,313 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.resolveDatabases = void 0;
37
- const rds = __importStar(require("@alicloud/ros-cdk-rds"));
38
- const common_1 = require("../../common");
39
- const lodash_1 = require("lodash");
40
- const esServerless = __importStar(require("@alicloud/ros-cdk-elasticsearchserverless"));
41
- const rdsEngineMap = new Map([
42
- [
43
- `${"RDS_MYSQL_SERVERLESS" /* DatabaseEnum.RDS_MYSQL_SERVERLESS */}-${"MYSQL_5.7" /* DatabaseVersionEnum['MYSQL_5.7'] */}`,
44
- {
45
- engine: 'MySQL',
46
- version: '5.7',
47
- category: 'serverless_basic',
48
- dbInstanceClass: 'mysql.n2.serverless.1c',
49
- quota: { minCapacity: 0.5, maxCapacity: 32, ha: false },
50
- storage: { type: 'general_essd', bursting: true, optimizedWrites: true, encryption: false },
51
- },
52
- ],
53
- [
54
- `${"RDS_MYSQL_SERVERLESS" /* DatabaseEnum.RDS_MYSQL_SERVERLESS */}-${"MYSQL_8.0" /* DatabaseVersionEnum['MYSQL_8.0'] */}`,
55
- {
56
- engine: 'MySQL',
57
- version: '8.0',
58
- category: 'serverless_basic',
59
- dbInstanceClass: 'mysql.n2.serverless.1c',
60
- quota: { minCapacity: 0.5, maxCapacity: 32, ha: false },
61
- storage: { type: 'general_essd', bursting: true, optimizedWrites: true, encryption: false },
62
- },
63
- ],
64
- [
65
- `${"RDS_MYSQL_SERVERLESS" /* DatabaseEnum.RDS_MYSQL_SERVERLESS */}-${"MYSQL_HA_5.7" /* DatabaseVersionEnum['MYSQL_HA_5.7'] */}`,
66
- {
67
- engine: 'MySQL',
68
- version: '5.7',
69
- category: 'serverless_standard',
70
- dbInstanceClass: 'mysql.n2.serverless.2c',
71
- quota: { minCapacity: 0.5, maxCapacity: 32, ha: true },
72
- storage: { type: 'general_essd', bursting: true, optimizedWrites: true, encryption: true },
73
- },
74
- ],
75
- [
76
- `${"RDS_MYSQL_SERVERLESS" /* DatabaseEnum.RDS_MYSQL_SERVERLESS */}-${"MYSQL_HA_8.0" /* DatabaseVersionEnum['MYSQL_HA_8.0'] */}`,
77
- {
78
- engine: 'MySQL',
79
- version: '8.0',
80
- category: 'serverless_standard',
81
- dbInstanceClass: 'mysql.n2.serverless.2c',
82
- quota: { minCapacity: 0.5, maxCapacity: 32, ha: true },
83
- storage: { type: 'general_essd', bursting: true, optimizedWrites: true, encryption: true },
84
- },
85
- ],
86
- [
87
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_14" /* DatabaseVersionEnum['PGSQL_14'] */}`,
88
- {
89
- engine: 'PostgreSQL',
90
- version: '14.0',
91
- category: 'serverless_basic',
92
- dbInstanceClass: 'pg.n2.serverless.1c',
93
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: false },
94
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
95
- },
96
- ],
97
- [
98
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_15" /* DatabaseVersionEnum['PGSQL_15'] */}`,
99
- {
100
- engine: 'PostgreSQL',
101
- version: '15.0',
102
- category: 'serverless_basic',
103
- dbInstanceClass: 'pg.n2.serverless.1c',
104
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: false },
105
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
106
- },
107
- ],
108
- [
109
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_16" /* DatabaseVersionEnum['PGSQL_16'] */}`,
110
- {
111
- engine: 'PostgreSQL',
112
- version: '16.0',
113
- category: 'serverless_basic',
114
- dbInstanceClass: 'pg.n2.serverless.1c',
115
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: false },
116
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
117
- },
118
- ],
119
- [
120
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_HA_14" /* DatabaseVersionEnum['PGSQL_HA_14'] */}`,
121
- {
122
- engine: 'PostgreSQL',
123
- version: '14.0',
124
- category: 'serverless_standard',
125
- dbInstanceClass: 'pg.n2.serverless.2c',
126
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: true },
127
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
128
- },
129
- ],
130
- [
131
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_HA_15" /* DatabaseVersionEnum['PGSQL_HA_15'] */}`,
132
- {
133
- engine: 'PostgreSQL',
134
- version: '15.0',
135
- category: 'serverless_standard',
136
- dbInstanceClass: 'pg.n2.serverless.2c',
137
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: true },
138
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
139
- },
140
- ],
141
- [
142
- `${"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */}-${"PGSQL_HA_16" /* DatabaseVersionEnum['PGSQL_HA_16'] */}`,
143
- {
144
- engine: 'PostgreSQL',
145
- version: '16.0',
146
- category: 'serverless_standard',
147
- dbInstanceClass: 'pg.n2.serverless.2c',
148
- quota: { minCapacity: 0.5, maxCapacity: 14, ha: true },
149
- storage: { type: 'general_essd', bursting: true, optimizedWrites: false, encryption: false },
150
- },
151
- ],
152
- [
153
- `${"RDS_MSSQL_SERVERLESS" /* DatabaseEnum.RDS_MSSQL_SERVERLESS */}-${"MSSQL_HA_2016" /* DatabaseVersionEnum['MSSQL_HA_2016'] */}`,
154
- {
155
- engine: 'SQLServer',
156
- version: '2016_std_sl',
157
- category: 'serverless_ha',
158
- dbInstanceClass: 'mssql.mem2.serverless.s2',
159
- quota: { minCapacity: 2, maxCapacity: 8, ha: true },
160
- storage: { type: 'cloud_essd', bursting: false, optimizedWrites: false, encryption: false },
161
- },
162
- ],
163
- [
164
- `${"RDS_MSSQL_SERVERLESS" /* DatabaseEnum.RDS_MSSQL_SERVERLESS */}-${"MSSQL_HA_2017" /* DatabaseVersionEnum['MSSQL_HA_2017'] */}`,
165
- {
166
- engine: 'SQLServer',
167
- version: '2017_std_sl',
168
- category: 'serverless_ha',
169
- dbInstanceClass: 'mssql.mem2.serverless.s2',
170
- quota: { minCapacity: 2, maxCapacity: 8, ha: true },
171
- storage: { type: 'cloud_essd', bursting: false, optimizedWrites: false, encryption: false },
172
- },
173
- ],
174
- [
175
- `${"RDS_MSSQL_SERVERLESS" /* DatabaseEnum.RDS_MSSQL_SERVERLESS */}-${"MSSQL_HA_2019" /* DatabaseVersionEnum['MSSQL_HA_2019'] */}`,
176
- {
177
- engine: 'SQLServer',
178
- version: '2019_std_sl',
179
- category: 'serverless_ha',
180
- dbInstanceClass: 'mssql.mem2.serverless.s2',
181
- quota: { minCapacity: 2, maxCapacity: 8, ha: true },
182
- storage: { type: 'cloud_essd', bursting: false, optimizedWrites: false, encryption: false },
183
- },
184
- ],
185
- [
186
- `${"ELASTICSEARCH_SERVERLESS" /* DatabaseEnum.ELASTICSEARCH_SERVERLESS */}-${"ES_SEARCH_7.10" /* DatabaseVersionEnum['ES_SEARCH_7.10'] */}`,
187
- {
188
- engine: 'Elasticsearch',
189
- version: '7.10',
190
- category: 'STANDARD',
191
- dbInstanceClass: '',
192
- quota: { minCapacity: 2, maxCapacity: 8, ha: false },
193
- storage: { type: 'cloud_essd', bursting: false, optimizedWrites: false, encryption: false },
194
- },
195
- ],
196
- [
197
- `${"ELASTICSEARCH_SERVERLESS" /* DatabaseEnum.ELASTICSEARCH_SERVERLESS */}-${"ES_TIME_SERIES_7.10" /* DatabaseVersionEnum['ES_TIME_SERIES_7.10'] */}`,
198
- {
199
- engine: 'Elasticsearch',
200
- version: '7.10',
201
- category: 'TRIAL',
202
- dbInstanceClass: '',
203
- quota: { minCapacity: 2, maxCapacity: 8, ha: false },
204
- storage: { type: 'cloud_essd', bursting: false, optimizedWrites: false, encryption: false },
205
- },
206
- ],
207
- ]);
208
- const resolveDatabases = (scope, databases, context) => {
209
- if ((0, lodash_1.isEmpty)(databases)) {
210
- return undefined;
211
- }
212
- databases.forEach((db) => {
213
- const { engine, version, category, dbInstanceClass, quota, storage } = rdsEngineMap.get(`${db.type}-${db.version}`) ?? {};
214
- if (["ELASTICSEARCH_SERVERLESS" /* DatabaseEnum.ELASTICSEARCH_SERVERLESS */].includes(db.type)) {
215
- new esServerless.App(scope, db.key, {
216
- appName: (0, common_1.calcRefs)(db.name, context),
217
- appVersion: version,
218
- authentication: {
219
- basicAuth: [
220
- {
221
- password: (0, common_1.calcRefs)(db.security.basicAuth.password, context),
222
- },
223
- ],
224
- },
225
- quotaInfo: {
226
- minCu: db.cu.min,
227
- appType: category,
228
- },
229
- // network: [
230
- // {
231
- // type: 'PUBLIC_KIBANA',
232
- // enabled: true,
233
- // whiteIpGroup: [{ groupName: 'default', ips: ['0.0.0.0/24'] }],
234
- // },
235
- // {
236
- // type: 'PUBLIC_ES',
237
- // enabled: true,
238
- // whiteIpGroup: [{ groupName: 'default', ips: ['0.0.0.0/24'] }],
239
- // },
240
- // ],
241
- }, true);
242
- }
243
- if ([
244
- "RDS_MYSQL_SERVERLESS" /* DatabaseEnum.RDS_MYSQL_SERVERLESS */,
245
- "RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */,
246
- "RDS_MSSQL_SERVERLESS" /* DatabaseEnum.RDS_MSSQL_SERVERLESS */,
247
- ].includes(db.type)) {
248
- new rds.DBInstance(scope, db.key, {
249
- engine: engine,
250
- /**
251
- * Serverless 实例
252
- * MySQL:5.7、8.0 - MYSQL_HA_5.7, MYSQL_5.7, MYSQL_HA_8.0, MYSQL_8.0
253
- * SQL Server:2016_std_sl、2017_std_sl、2019_std_sl - MSSQL_HA_2016, MSSQL_HA_2017, MSSQL_HA_2019
254
- * PostgreSQL:14.0、15.0、16.0 - PGSQL_HA_14, PGSQL_14 PGSQL_HA_15, PGSQL_15, PGSQL_HA_16,PGSQL_16
255
- */
256
- engineVersion: version,
257
- dbInstanceStorage: (0, common_1.calcRefs)(db.storage.min, context),
258
- /** Serverless 实例
259
- * serverless_basic:Serverless 基础系列。(仅适用 MySQL 和 PostgreSQL)
260
- * serverless_standard:Serverless 高可用系列。(仅适用 MySQL 和 PostgreSQL)
261
- * serverless_ha:SQL Server Serverless 高可用系列。
262
- */
263
- category,
264
- /**
265
- * MySQL:
266
- * MySQL 基础系列:mysql.n2.serverless.1c
267
- * MySQL 高可用系列:mysql.n2.serverless.2c
268
- * SQL Server:
269
- * mssql.mem2.serverless.s2
270
- * PostgreSQL
271
- * 基础系列:pg.n2.serverless.1c
272
- * 高可用系列:pg.n2.serverless.2c
273
- */
274
- dbInstanceClass: dbInstanceClass,
275
- /**
276
- * 实例存储类型,取值:
277
- * cloud_essd:ESSD PL1 云盘。
278
- * general_essd:通用云盘(推荐)。
279
- */
280
- dbInstanceStorageType: storage.type,
281
- burstingEnabled: storage.bursting,
282
- payType: 'Serverless',
283
- /**
284
- * MaxCapacity:
285
- * MySQL:1~32
286
- * SQL Server:2~8
287
- * PostgreSQL:1~14
288
- * MinCapacity:
289
- * MySQL:0.5~32
290
- * SQL Server:2~8(仅支持整数)
291
- * PostgreSQL:0.5~14
292
- */
293
- serverlessConfig: {
294
- // @TODO db.cu.min should get parameter value when it refer to a parameter
295
- minCapacity: (0, common_1.calcRefs)(db.cu.min === 0 ? quota.minCapacity : db.cu.min + quota.minCapacity, context),
296
- maxCapacity: (0, common_1.calcRefs)(db.cu.max + quota.minCapacity <= quota.maxCapacity
297
- ? db.cu.max + quota.minCapacity
298
- : quota.maxCapacity, context),
299
- autoPause: db.cu.min === 0,
300
- switchForce: false,
301
- },
302
- masterUsername: (0, common_1.calcRefs)(db.security.basicAuth.username, context),
303
- masterUserPassword: (0, common_1.calcRefs)(db.security.basicAuth.password, context),
304
- masterUserType: 'Super',
305
- multiAz: quota.ha,
306
- securityIpList: (0, common_1.calcRefs)(db.network.ingressRules.join(','), context),
307
- connectionStringType: db.network.type === 'PRIVATE' ? 'Inner' : 'Public',
308
- dbInstanceNetType: db.network.type === 'PRIVATE' ? 'Intranet' : 'Internet',
309
- }, true);
310
- }
311
- });
312
- };
313
- exports.resolveDatabases = resolveDatabases;
@@ -1,143 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.resolveEvents = void 0;
37
- const types_1 = require("../../types");
38
- const ram = __importStar(require("@alicloud/ros-cdk-ram"));
39
- const common_1 = require("../../common");
40
- const agw = __importStar(require("@alicloud/ros-cdk-apigateway"));
41
- const lodash_1 = require("lodash");
42
- const dns = __importStar(require("@alicloud/ros-cdk-dns"));
43
- const resolveEvents = (scope, events, tags, context, service) => {
44
- if ((0, lodash_1.isEmpty)(events)) {
45
- return undefined;
46
- }
47
- const apiGateway = events.filter((event) => event.type === types_1.EventTypes.API_GATEWAY);
48
- if (!apiGateway?.length)
49
- return;
50
- apiGateway.forEach((event) => {
51
- const gatewayAccessRole = new ram.RosRole(scope, (0, common_1.formatRosId)(`${event.key}_agw_role`), {
52
- roleName: (0, common_1.calcRefs)(`${event.name}-agw-access-role`, context),
53
- description: (0, common_1.calcRefs)(`${service} role`, context),
54
- assumeRolePolicyDocument: {
55
- version: '1',
56
- statement: [
57
- {
58
- action: 'sts:AssumeRole',
59
- effect: 'Allow',
60
- principal: {
61
- service: ['apigateway.aliyuncs.com'],
62
- },
63
- },
64
- ],
65
- },
66
- policies: [
67
- {
68
- policyName: (0, common_1.calcRefs)(`${service}-${event.name}-policy`, context),
69
- policyDocument: {
70
- version: '1',
71
- statement: [
72
- {
73
- action: ['fc:InvokeFunction'],
74
- effect: 'Allow',
75
- // @TODO implement at least permission granting
76
- resource: ['*'],
77
- },
78
- ],
79
- },
80
- },
81
- ],
82
- }, true);
83
- const apiGatewayGroup = new agw.RosGroup(scope, (0, common_1.formatRosId)(`${event.key}_agw_group`), {
84
- groupName: (0, common_1.calcRefs)(`${service}-agw-group`, context),
85
- tags: (0, common_1.calcRefs)(tags, context),
86
- passthroughHeaders: 'host',
87
- }, true);
88
- if (event.domain) {
89
- const dnsRecordId = (0, common_1.formatRosId)(`${event.key}_agw_custom_domain_record`);
90
- const { domainName, rr } = (0, common_1.splitDomain)(event.domain?.domain_name);
91
- new dns.DomainRecord(scope, dnsRecordId, {
92
- domainName,
93
- rr,
94
- type: 'CNAME',
95
- value: apiGatewayGroup.attrSubDomain,
96
- });
97
- const agwCustomDomain = new agw.RosCustomDomain(scope, (0, common_1.formatRosId)(`${event.key}_agw_custom_domain`), {
98
- groupId: apiGatewayGroup.attrGroupId,
99
- domainName: event.domain.domain_name,
100
- certificateName: event.domain.certificate_name,
101
- certificateBody: event.domain.certificate_body,
102
- certificatePrivateKey: event.domain.certificate_private_key,
103
- }, true);
104
- agwCustomDomain.addRosDependency(dnsRecordId);
105
- }
106
- event.triggers.forEach((trigger) => {
107
- const key = (0, common_1.formatRosId)((0, common_1.calcValue)(`${trigger.method}_${trigger.path}`, context));
108
- const api = new agw.RosApi(scope, (0, common_1.formatRosId)(`${event.key}_agw_api_${key}`), {
109
- apiName: (0, common_1.calcRefs)(`${event.name}-agw-api-${key.replace(/_/g, '-')}`, context),
110
- groupId: apiGatewayGroup.attrGroupId,
111
- visibility: 'PRIVATE',
112
- authType: 'ANONYMOUS',
113
- requestConfig: {
114
- requestProtocol: 'HTTP',
115
- requestHttpMethod: (0, common_1.calcRefs)(trigger.method, context),
116
- requestPath: (0, common_1.calcRefs)(trigger.path, context),
117
- requestMode: 'PASSTHROUGH',
118
- },
119
- serviceConfig: {
120
- serviceProtocol: 'FunctionCompute',
121
- functionComputeConfig: {
122
- fcRegionId: context.region,
123
- functionName: (0, common_1.calcRefs)(trigger.backend, context),
124
- roleArn: gatewayAccessRole.attrArn,
125
- fcVersion: '3.0',
126
- method: (0, common_1.calcRefs)(trigger.method, context),
127
- },
128
- },
129
- resultSample: 'ServerlessInsight resultSample',
130
- resultType: 'PASSTHROUGH',
131
- tags: (0, common_1.calcRefs)(tags, context),
132
- }, true);
133
- api.addDependsOn(apiGatewayGroup);
134
- new agw.Deployment(scope, (0, common_1.formatRosId)(`${event.key}_agw_api_deployment_${key}`), {
135
- apiId: api.attrApiId,
136
- groupId: apiGatewayGroup.attrGroupId,
137
- stageName: 'RELEASE',
138
- description: (0, common_1.calcRefs)(`${service} Api Gateway deployment for api: ${trigger.method} ${trigger.path}`, context),
139
- });
140
- });
141
- });
142
- };
143
- exports.resolveEvents = resolveEvents;