@geek-fun/serverlessinsight 0.3.0 → 0.3.1
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/dist/package.json +32 -31
- package/dist/src/commands/deploy.js +2 -2
- package/dist/src/commands/destroy.js +2 -1
- package/dist/src/commands/index.js +11 -10
- package/dist/src/commands/template.js +2 -2
- package/dist/src/commands/validate.js +2 -1
- package/dist/src/common/constants.js +2 -1
- package/dist/src/common/{actionContext.js → context.js} +19 -4
- package/dist/src/common/iacHelper.js +54 -27
- package/dist/src/common/index.d.ts +1 -1
- package/dist/src/common/index.js +1 -1
- package/dist/src/common/rosAssets.js +33 -8
- package/dist/src/common/rosClient.js +5 -3
- package/dist/src/stack/deploy.js +30 -13
- package/dist/src/stack/rfsStack/index.d.ts +2 -2
- package/dist/src/stack/rfsStack/index.js +2 -1
- package/dist/src/stack/rosStack/bootstrap.js +5 -4
- package/dist/src/stack/rosStack/bucket.js +12 -12
- package/dist/src/stack/rosStack/database.js +10 -10
- package/dist/src/stack/rosStack/event.js +21 -21
- package/dist/src/stack/rosStack/function.js +65 -44
- package/dist/src/stack/rosStack/index.d.ts +2 -2
- package/dist/src/stack/rosStack/index.js +3 -3
- package/dist/src/stack/rosStack/stage.js +1 -1
- package/dist/src/stack/rosStack/tag.js +1 -1
- package/dist/src/stack/rosStack/vars.js +3 -3
- package/dist/src/validator/functionSchema.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -31
- package/samples/aliyun-poc-fc-gpu.yml +23 -22
|
@@ -78,41 +78,41 @@ const resolveBuckets = (scope, buckets, context) => {
|
|
|
78
78
|
}, true);
|
|
79
79
|
}
|
|
80
80
|
buckets.forEach((bucket) => {
|
|
81
|
-
const ossBucket = new oss.Bucket(scope,
|
|
82
|
-
bucketName: (0, common_1.
|
|
83
|
-
accessControl: aclMap.get((0, common_1.
|
|
81
|
+
const ossBucket = new oss.Bucket(scope, bucket.key, {
|
|
82
|
+
bucketName: (0, common_1.calcRefs)(bucket.name, context),
|
|
83
|
+
accessControl: aclMap.get((0, common_1.calcRefs)(bucket.security?.acl, context) ?? ''),
|
|
84
84
|
websiteConfigurationV2: bucket.website
|
|
85
85
|
? {
|
|
86
86
|
indexDocument: {
|
|
87
87
|
type: '0',
|
|
88
|
-
suffix: (0, common_1.
|
|
88
|
+
suffix: (0, common_1.calcRefs)(bucket.website.index, context),
|
|
89
89
|
supportSubDir: 'true',
|
|
90
90
|
},
|
|
91
91
|
errorDocument: {
|
|
92
|
-
httpStatus: `${(0, common_1.
|
|
93
|
-
key: (0, common_1.
|
|
92
|
+
httpStatus: `${(0, common_1.calcRefs)(bucket.website.error_code, context)}`,
|
|
93
|
+
key: (0, common_1.calcRefs)(bucket.website.error_page, context),
|
|
94
94
|
},
|
|
95
95
|
}
|
|
96
96
|
: undefined,
|
|
97
97
|
});
|
|
98
98
|
if (bucket.website?.code) {
|
|
99
|
-
const filePath = node_path_1.default.resolve(process.cwd(), (0, common_1.
|
|
100
|
-
new ossDeployment.BucketDeployment(scope, `si_auto_${bucket.key}_bucket_code_deployment
|
|
99
|
+
const filePath = node_path_1.default.resolve(process.cwd(), (0, common_1.calcValue)(bucket.website.code, context));
|
|
100
|
+
new ossDeployment.BucketDeployment(scope, (0, common_1.formatRosId)(`si_auto_${bucket.key}_bucket_code_deployment`), {
|
|
101
101
|
sources: (0, common_1.getAssets)(filePath),
|
|
102
102
|
destinationBucket: ossBucket.attrName,
|
|
103
103
|
roleArn: siAutoOssDeploymentBucketRole.attrArn,
|
|
104
|
-
timeout:
|
|
104
|
+
timeout: common_1.OSS_DEPLOYMENT_TIMEOUT,
|
|
105
105
|
logMonitoring: false,
|
|
106
106
|
retainOnCreate: false,
|
|
107
107
|
}, true);
|
|
108
108
|
}
|
|
109
109
|
if (bucket.website?.domain) {
|
|
110
110
|
const { rr, domainName } = (0, common_1.splitDomain)(bucket.website.domain);
|
|
111
|
-
new oss.Domain(scope,
|
|
111
|
+
new oss.Domain(scope, (0, common_1.formatRosId)(`${bucket.key}_custom_domain`), {
|
|
112
112
|
bucketName: ossBucket.attrName,
|
|
113
|
-
domainName: (0, common_1.
|
|
113
|
+
domainName: (0, common_1.calcRefs)(bucket.website.domain, context),
|
|
114
114
|
});
|
|
115
|
-
new dns.DomainRecord(scope,
|
|
115
|
+
new dns.DomainRecord(scope, (0, common_1.formatRosId)(`${bucket.key}_custom_domain_record`), {
|
|
116
116
|
domainName: domainName,
|
|
117
117
|
rr,
|
|
118
118
|
type: 'CNAME',
|
|
@@ -212,13 +212,13 @@ const resolveDatabases = (scope, databases, context) => {
|
|
|
212
212
|
databases.forEach((db) => {
|
|
213
213
|
const { engine, version, category, dbInstanceClass, quota, storage } = rdsEngineMap.get(`${db.type}-${db.version}`) ?? {};
|
|
214
214
|
if (["ELASTICSEARCH_SERVERLESS" /* DatabaseEnum.ELASTICSEARCH_SERVERLESS */].includes(db.type)) {
|
|
215
|
-
new esServerless.App(scope,
|
|
216
|
-
appName: (0, common_1.
|
|
215
|
+
new esServerless.App(scope, db.key, {
|
|
216
|
+
appName: (0, common_1.calcRefs)(db.name, context),
|
|
217
217
|
appVersion: version,
|
|
218
218
|
authentication: {
|
|
219
219
|
basicAuth: [
|
|
220
220
|
{
|
|
221
|
-
password: (0, common_1.
|
|
221
|
+
password: (0, common_1.calcRefs)(db.security.basicAuth.password, context),
|
|
222
222
|
},
|
|
223
223
|
],
|
|
224
224
|
},
|
|
@@ -246,7 +246,7 @@ const resolveDatabases = (scope, databases, context) => {
|
|
|
246
246
|
"RDS_PGSQL_SERVERLESS" /* DatabaseEnum.RDS_PGSQL_SERVERLESS */,
|
|
247
247
|
"RDS_MSSQL_SERVERLESS" /* DatabaseEnum.RDS_MSSQL_SERVERLESS */,
|
|
248
248
|
].includes(db.type)) {
|
|
249
|
-
new rds.DBInstance(scope,
|
|
249
|
+
new rds.DBInstance(scope, db.key, {
|
|
250
250
|
engine: engine,
|
|
251
251
|
/**
|
|
252
252
|
* Serverless 实例
|
|
@@ -255,7 +255,7 @@ const resolveDatabases = (scope, databases, context) => {
|
|
|
255
255
|
* PostgreSQL:14.0、15.0、16.0 - PGSQL_HA_14, PGSQL_14 PGSQL_HA_15, PGSQL_15, PGSQL_HA_16,PGSQL_16
|
|
256
256
|
*/
|
|
257
257
|
engineVersion: version,
|
|
258
|
-
dbInstanceStorage: (0, common_1.
|
|
258
|
+
dbInstanceStorage: (0, common_1.calcRefs)(db.storage.min, context),
|
|
259
259
|
/** Serverless 实例
|
|
260
260
|
* serverless_basic:Serverless 基础系列。(仅适用 MySQL 和 PostgreSQL)
|
|
261
261
|
* serverless_standard:Serverless 高可用系列。(仅适用 MySQL 和 PostgreSQL)
|
|
@@ -293,18 +293,18 @@ const resolveDatabases = (scope, databases, context) => {
|
|
|
293
293
|
*/
|
|
294
294
|
serverlessConfig: {
|
|
295
295
|
// @TODO db.cu.min should get parameter value when it refer to a parameter
|
|
296
|
-
minCapacity: (0, common_1.
|
|
297
|
-
maxCapacity: (0, common_1.
|
|
296
|
+
minCapacity: (0, common_1.calcRefs)(db.cu.min === 0 ? quota.minCapacity : db.cu.min + quota.minCapacity, context),
|
|
297
|
+
maxCapacity: (0, common_1.calcRefs)(db.cu.max + quota.minCapacity <= quota.maxCapacity
|
|
298
298
|
? db.cu.max + quota.minCapacity
|
|
299
299
|
: quota.maxCapacity, context),
|
|
300
300
|
autoPause: db.cu.min === 0,
|
|
301
301
|
switchForce: false,
|
|
302
302
|
},
|
|
303
|
-
masterUsername: (0, common_1.
|
|
304
|
-
masterUserPassword: (0, common_1.
|
|
303
|
+
masterUsername: (0, common_1.calcRefs)(db.security.basicAuth.username, context),
|
|
304
|
+
masterUserPassword: (0, common_1.calcRefs)(db.security.basicAuth.password, context),
|
|
305
305
|
masterUserType: 'Super',
|
|
306
306
|
multiAz: quota.ha,
|
|
307
|
-
securityIpList: (0, common_1.
|
|
307
|
+
securityIpList: (0, common_1.calcRefs)(db.network.ingressRules.join(','), context),
|
|
308
308
|
connectionStringType: db.network.type === 'PRIVATE' ? 'Inner' : 'Public',
|
|
309
309
|
dbInstanceNetType: db.network.type === 'PRIVATE' ? 'Intranet' : 'Internet',
|
|
310
310
|
}, true);
|
|
@@ -48,9 +48,9 @@ const resolveEvents = (scope, events, tags, context, service) => {
|
|
|
48
48
|
if (!apiGateway?.length)
|
|
49
49
|
return;
|
|
50
50
|
apiGateway.forEach((event) => {
|
|
51
|
-
const gatewayAccessRole = new ram.RosRole(scope, (0, common_1.
|
|
52
|
-
roleName: (0, common_1.
|
|
53
|
-
description: (0, common_1.
|
|
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
54
|
assumeRolePolicyDocument: {
|
|
55
55
|
version: '1',
|
|
56
56
|
statement: [
|
|
@@ -65,7 +65,7 @@ const resolveEvents = (scope, events, tags, context, service) => {
|
|
|
65
65
|
},
|
|
66
66
|
policies: [
|
|
67
67
|
{
|
|
68
|
-
policyName: (0, common_1.
|
|
68
|
+
policyName: (0, common_1.calcRefs)(`${service}-${event.name}-policy`, context),
|
|
69
69
|
policyDocument: {
|
|
70
70
|
version: '1',
|
|
71
71
|
statement: [
|
|
@@ -80,62 +80,62 @@ const resolveEvents = (scope, events, tags, context, service) => {
|
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
}, true);
|
|
83
|
-
const apiGatewayGroup = new agw.RosGroup(scope, (0, common_1.
|
|
84
|
-
groupName: (0, common_1.
|
|
85
|
-
tags: (0, common_1.
|
|
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
86
|
passthroughHeaders: 'host',
|
|
87
87
|
}, true);
|
|
88
88
|
if (event.domain) {
|
|
89
|
-
const
|
|
89
|
+
const dnsRecordId = (0, common_1.formatRosId)(`${event.key}_agw_custom_domain_record`);
|
|
90
90
|
const { domainName, rr } = (0, common_1.splitDomain)(event.domain?.domain_name);
|
|
91
|
-
new dns.DomainRecord(scope,
|
|
91
|
+
new dns.DomainRecord(scope, dnsRecordId, {
|
|
92
92
|
domainName,
|
|
93
93
|
rr,
|
|
94
94
|
type: 'CNAME',
|
|
95
95
|
value: apiGatewayGroup.attrSubDomain,
|
|
96
96
|
});
|
|
97
|
-
const agwCustomDomain = new agw.RosCustomDomain(scope,
|
|
97
|
+
const agwCustomDomain = new agw.RosCustomDomain(scope, (0, common_1.formatRosId)(`${event.key}_agw_custom_domain`), {
|
|
98
98
|
groupId: apiGatewayGroup.attrGroupId,
|
|
99
99
|
domainName: event.domain.domain_name,
|
|
100
100
|
certificateName: event.domain.certificate_name,
|
|
101
101
|
certificateBody: event.domain.certificate_body,
|
|
102
102
|
certificatePrivateKey: event.domain.certificate_private_key,
|
|
103
103
|
}, true);
|
|
104
|
-
agwCustomDomain.addRosDependency(
|
|
104
|
+
agwCustomDomain.addRosDependency(dnsRecordId);
|
|
105
105
|
}
|
|
106
106
|
event.triggers.forEach((trigger) => {
|
|
107
|
-
const key = (0, common_1.
|
|
108
|
-
const api = new agw.RosApi(scope, `${event.key}
|
|
109
|
-
apiName: (0, common_1.
|
|
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
110
|
groupId: apiGatewayGroup.attrGroupId,
|
|
111
111
|
visibility: 'PRIVATE',
|
|
112
112
|
authType: 'ANONYMOUS',
|
|
113
113
|
requestConfig: {
|
|
114
114
|
requestProtocol: 'HTTP',
|
|
115
|
-
requestHttpMethod: (0, common_1.
|
|
116
|
-
requestPath: (0, common_1.
|
|
115
|
+
requestHttpMethod: (0, common_1.calcRefs)(trigger.method, context),
|
|
116
|
+
requestPath: (0, common_1.calcRefs)(trigger.path, context),
|
|
117
117
|
requestMode: 'PASSTHROUGH',
|
|
118
118
|
},
|
|
119
119
|
serviceConfig: {
|
|
120
120
|
serviceProtocol: 'FunctionCompute',
|
|
121
121
|
functionComputeConfig: {
|
|
122
122
|
fcRegionId: context.region,
|
|
123
|
-
functionName: (0, common_1.
|
|
123
|
+
functionName: (0, common_1.calcRefs)(trigger.backend, context),
|
|
124
124
|
roleArn: gatewayAccessRole.attrArn,
|
|
125
125
|
fcVersion: '3.0',
|
|
126
|
-
method: (0, common_1.
|
|
126
|
+
method: (0, common_1.calcRefs)(trigger.method, context),
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
129
|
resultSample: 'ServerlessInsight resultSample',
|
|
130
130
|
resultType: 'PASSTHROUGH',
|
|
131
|
-
tags: (0, common_1.
|
|
131
|
+
tags: (0, common_1.calcRefs)(tags, context),
|
|
132
132
|
}, true);
|
|
133
133
|
api.addDependsOn(apiGatewayGroup);
|
|
134
|
-
new agw.Deployment(scope, `${
|
|
134
|
+
new agw.Deployment(scope, (0, common_1.formatRosId)(`${event.key}_agw_api_deployment_${key}`), {
|
|
135
135
|
apiId: api.attrApiId,
|
|
136
136
|
groupId: apiGatewayGroup.attrGroupId,
|
|
137
137
|
stageName: 'RELEASE',
|
|
138
|
-
description: `${service} Api Gateway deployment`,
|
|
138
|
+
description: (0, common_1.calcRefs)(`${service} Api Gateway deployment for api: ${trigger.method} ${trigger.path}`, context),
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
});
|
|
@@ -43,6 +43,7 @@ const ros = __importStar(require("@alicloud/ros-cdk-core"));
|
|
|
43
43
|
const sls = __importStar(require("@alicloud/ros-cdk-sls"));
|
|
44
44
|
const nas = __importStar(require("@alicloud/ros-cdk-nas"));
|
|
45
45
|
const ecs = __importStar(require("@alicloud/ros-cdk-ecs"));
|
|
46
|
+
const vpc = __importStar(require("@alicloud/ros-cdk-vpc"));
|
|
46
47
|
const storageClassMap = {
|
|
47
48
|
[types_1.NasStorageClassEnum.STANDARD_CAPACITY]: { fileSystemType: 'standard', storageType: 'Capacity' },
|
|
48
49
|
[types_1.NasStorageClassEnum.STANDARD_PERFORMANCE]: {
|
|
@@ -95,14 +96,17 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
|
|
|
95
96
|
}
|
|
96
97
|
let logConfig = undefined;
|
|
97
98
|
const enableLog = functions?.some(({ log }) => log);
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const slsProjectId = 'sls_project';
|
|
100
|
+
const slsLogstoreId = 'sls_logstore';
|
|
101
|
+
const slsIndexId = 'sls_index';
|
|
102
|
+
const slsProject = new sls.Project(scope, slsProjectId, { name: (0, common_1.calcRefs)(`${service}-sls`, context), tags: (0, common_1.calcRefs)(tags, context) }, true);
|
|
103
|
+
const slsLogstore = new sls.Logstore(scope, slsLogstoreId, {
|
|
104
|
+
logstoreName: (0, common_1.calcRefs)(`${service}-sls-logstore`, context),
|
|
105
|
+
projectName: slsProject.attrName,
|
|
102
106
|
ttl: 7,
|
|
103
107
|
}, true);
|
|
104
|
-
new sls.Index(scope,
|
|
105
|
-
projectName:
|
|
108
|
+
new sls.Index(scope, slsIndexId, {
|
|
109
|
+
projectName: slsProject.attrName,
|
|
106
110
|
logstoreName: slsLogstore.attrLogstoreName,
|
|
107
111
|
fullTextIndex: { enable: true },
|
|
108
112
|
}, true);
|
|
@@ -116,99 +120,118 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
|
|
|
116
120
|
const fileSources = functions
|
|
117
121
|
?.filter(({ code }) => code?.path && (0, common_1.readCodeSize)(code.path) > common_1.CODE_ZIP_SIZE_LIMIT)
|
|
118
122
|
.map(({ code, name }) => {
|
|
119
|
-
const fcName = (0, common_1.
|
|
123
|
+
const fcName = (0, common_1.calcRefs)(name, context);
|
|
120
124
|
return { fcName, ...(0, common_1.getFileSource)(fcName, code.path) };
|
|
121
125
|
});
|
|
122
126
|
const destinationBucketName = ros.Fn.sub('si-bootstrap-artifacts-${ALIYUN::AccountId}-${ALIYUN::Region}');
|
|
123
|
-
const ossDeploymentId =
|
|
127
|
+
const ossDeploymentId = 'si_auto_artifacts_code_deployment';
|
|
124
128
|
if (!(0, lodash_1.isEmpty)(fileSources)) {
|
|
125
129
|
new ossDeployment.BucketDeployment(scope, ossDeploymentId, {
|
|
126
130
|
sources: fileSources.map(({ source }) => source),
|
|
127
131
|
destinationBucket: destinationBucketName,
|
|
128
|
-
timeout:
|
|
132
|
+
timeout: common_1.OSS_DEPLOYMENT_TIMEOUT,
|
|
129
133
|
logMonitoring: false,
|
|
130
134
|
retainOnCreate: false,
|
|
131
135
|
}, true);
|
|
132
136
|
}
|
|
133
137
|
functions?.forEach((fnc) => {
|
|
134
138
|
let runtimeConfig;
|
|
135
|
-
const storeInBucket = !!fnc.code?.path && (0, common_1.readCodeSize)(fnc.code.path) > common_1.CODE_ZIP_SIZE_LIMIT;
|
|
139
|
+
const storeInBucket = !!fnc.code?.path && (0, common_1.readCodeSize)((0, common_1.calcValue)(fnc.code.path, context)) > common_1.CODE_ZIP_SIZE_LIMIT;
|
|
136
140
|
if (fnc.container) {
|
|
137
141
|
runtimeConfig = {
|
|
138
142
|
runtime: 'custom-container',
|
|
139
143
|
handler: 'index.handler',
|
|
140
144
|
customContainerConfig: {
|
|
141
|
-
image: fnc.container.image,
|
|
142
|
-
command: fnc.container.cmd?.split(' '),
|
|
143
|
-
port: fnc.container.port,
|
|
145
|
+
image: (0, common_1.calcRefs)(fnc.container.image, context),
|
|
146
|
+
command: (0, common_1.calcRefs)(fnc.container.cmd, context)?.split(' '),
|
|
147
|
+
port: (0, common_1.calcRefs)(fnc.container.port, context),
|
|
144
148
|
},
|
|
145
149
|
};
|
|
146
150
|
}
|
|
147
151
|
else {
|
|
148
152
|
let code = {
|
|
149
|
-
zipFile: (0, common_1.resolveCode)(fnc.code.path),
|
|
153
|
+
zipFile: (0, common_1.resolveCode)((0, common_1.calcValue)(fnc.code.path, context)),
|
|
150
154
|
};
|
|
151
155
|
if (storeInBucket) {
|
|
152
156
|
code = {
|
|
153
157
|
ossBucketName: destinationBucketName,
|
|
154
|
-
ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.
|
|
158
|
+
ossObjectName: fileSources?.find(({ fcName }) => fcName === (0, common_1.calcRefs)(fnc.name, context))
|
|
159
|
+
?.objectKey,
|
|
155
160
|
};
|
|
156
161
|
}
|
|
157
162
|
runtimeConfig = {
|
|
158
163
|
code,
|
|
159
|
-
handler: (0, common_1.
|
|
160
|
-
runtime: (0, common_1.
|
|
164
|
+
handler: (0, common_1.calcRefs)(fnc.code.handler, context),
|
|
165
|
+
runtime: (0, common_1.calcRefs)(fnc.code.runtime, context),
|
|
161
166
|
};
|
|
162
167
|
}
|
|
163
168
|
let vpcConfig = undefined;
|
|
164
169
|
if (fnc.network) {
|
|
165
|
-
const securityGroup = new ecs.SecurityGroup(scope, `${fnc.key}_security_group
|
|
170
|
+
const securityGroup = new ecs.SecurityGroup(scope, (0, common_1.formatRosId)(`${fnc.key}_security_group`), {
|
|
166
171
|
securityGroupName: fnc.network.security_group.name,
|
|
167
|
-
vpcId: (0, common_1.
|
|
168
|
-
tags: (0, common_1.
|
|
172
|
+
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
173
|
+
tags: (0, common_1.calcRefs)(tags, context),
|
|
169
174
|
securityGroupIngress: transformSecurityRules(fnc.network.security_group.ingress, 'INGRESS'),
|
|
170
175
|
securityGroupEgress: transformSecurityRules(fnc.network.security_group.egress, 'EGRESS'),
|
|
171
176
|
}, true);
|
|
172
177
|
vpcConfig = {
|
|
173
|
-
vpcId: (0, common_1.
|
|
174
|
-
vSwitchIds: (0, common_1.
|
|
178
|
+
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
179
|
+
vSwitchIds: (0, common_1.calcRefs)(fnc.network.subnet_ids, context),
|
|
175
180
|
securityGroupId: securityGroup.attrSecurityGroupId,
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
let fcNas;
|
|
179
184
|
if (fnc.storage?.nas) {
|
|
180
185
|
fcNas = fnc.storage.nas.map((nasItem) => {
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
|
|
186
|
+
const storageClass = (0, common_1.calcValue)(nasItem.storage_class, context);
|
|
187
|
+
const { fileSystemType, storageType } = storageClassMap[storageClass];
|
|
188
|
+
const mountPathValue = (0, common_1.formatRosId)((0, common_1.calcValue)(nasItem.mount_path, context));
|
|
189
|
+
const nasMountTargetId = (0, common_1.formatRosId)(`${fnc.key}_nas_mount_${mountPathValue}`);
|
|
190
|
+
const accessGroup = new nas.AccessGroup(scope, (0, common_1.formatRosId)(`${fnc.key}_nas_access_${mountPathValue}`), {
|
|
191
|
+
accessGroupName: (0, common_1.calcRefs)(`${fnc.name}-nas-access-${mountPathValue.replace(/_/g, '-')}`, context),
|
|
184
192
|
accessGroupType: 'Vpc',
|
|
185
193
|
}, true);
|
|
186
|
-
const
|
|
194
|
+
const fcVpcSubnets = fnc.network?.subnet_ids.map((subnet) => new vpc.datasource.VSwitch(scope, (0, common_1.formatRosId)((0, common_1.calcValue)(`${fnc.key}_datasource_subnet_${subnet}`, context)), {
|
|
195
|
+
vSwitchId: subnet,
|
|
196
|
+
refreshOptions: 'Always',
|
|
197
|
+
}));
|
|
198
|
+
fcVpcSubnets?.forEach((subnetDatasource, index) => {
|
|
199
|
+
new nas.AccessRule(scope, (0, common_1.formatRosId)((0, common_1.calcValue)(`${fnc.key}_nas_rule_${fnc.network.subnet_ids[index]}`, context)), {
|
|
200
|
+
accessGroupName: accessGroup.attrAccessGroupName,
|
|
201
|
+
sourceCidrIp: subnetDatasource.attrCidrBlock,
|
|
202
|
+
}, true);
|
|
203
|
+
});
|
|
204
|
+
const nasResource = new nas.FileSystem(scope, (0, common_1.formatRosId)(`${fnc.key}_nas_${mountPathValue}`), {
|
|
187
205
|
fileSystemType,
|
|
188
206
|
storageType,
|
|
189
207
|
protocolType: 'NFS',
|
|
190
208
|
tags: [
|
|
191
|
-
...((0, common_1.
|
|
192
|
-
{ key: 'function-name', value: fnc.name },
|
|
209
|
+
...((0, common_1.calcRefs)(tags, context) ?? []),
|
|
210
|
+
{ key: 'function-name', value: (0, common_1.calcRefs)(fnc.name, context) },
|
|
193
211
|
],
|
|
194
212
|
}, true);
|
|
195
|
-
const nasMountTarget = new nas.MountTarget(scope,
|
|
213
|
+
const nasMountTarget = new nas.MountTarget(scope, nasMountTargetId, {
|
|
196
214
|
fileSystemId: nasResource.attrFileSystemId,
|
|
197
215
|
networkType: 'Vpc',
|
|
198
216
|
accessGroupName: accessGroup.attrAccessGroupName,
|
|
199
|
-
vpcId: fnc.network.vpc_id,
|
|
200
|
-
vSwitchId: fnc.network.subnet_ids[0],
|
|
217
|
+
vpcId: (0, common_1.calcRefs)(fnc.network.vpc_id, context),
|
|
218
|
+
vSwitchId: (0, common_1.calcRefs)(fnc.network.subnet_ids[0], context),
|
|
201
219
|
}, true);
|
|
202
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
nas: nasResource,
|
|
222
|
+
nasMount: nasMountTarget,
|
|
223
|
+
mountDir: (0, common_1.calcRefs)(nasItem.mount_path, context),
|
|
224
|
+
nasMountTargetId,
|
|
225
|
+
};
|
|
203
226
|
});
|
|
204
227
|
}
|
|
205
228
|
const fcn = new fc.RosFunction(scope, fnc.key, {
|
|
206
|
-
functionName: (0, common_1.
|
|
207
|
-
memorySize: (0, common_1.
|
|
208
|
-
diskSize: fnc.storage?.disk,
|
|
229
|
+
functionName: (0, common_1.calcRefs)(fnc.name, context),
|
|
230
|
+
memorySize: (0, common_1.calcRefs)(fnc.memory, context),
|
|
231
|
+
diskSize: (0, common_1.calcRefs)(fnc.storage?.disk, context),
|
|
209
232
|
gpuConfig: transformGpuConfig(fnc.gpu),
|
|
210
|
-
timeout: (0, common_1.
|
|
211
|
-
environmentVariables: (0, common_1.
|
|
233
|
+
timeout: (0, common_1.calcRefs)(fnc.timeout, context),
|
|
234
|
+
environmentVariables: (0, common_1.calcRefs)(fnc.environment, context),
|
|
212
235
|
logConfig,
|
|
213
236
|
vpcConfig,
|
|
214
237
|
...runtimeConfig,
|
|
@@ -222,17 +245,15 @@ const resolveFunctions = (scope, functions, tags, context, service) => {
|
|
|
222
245
|
: undefined,
|
|
223
246
|
}, true);
|
|
224
247
|
if (enableLog) {
|
|
225
|
-
fcn.addRosDependency(
|
|
226
|
-
fcn.addRosDependency(
|
|
227
|
-
fcn.addRosDependency(
|
|
248
|
+
fcn.addRosDependency(slsProjectId);
|
|
249
|
+
fcn.addRosDependency(slsLogstoreId);
|
|
250
|
+
fcn.addRosDependency(slsIndexId);
|
|
228
251
|
}
|
|
229
252
|
if (storeInBucket) {
|
|
230
|
-
fcn.addRosDependency(
|
|
253
|
+
fcn.addRosDependency(ossDeploymentId);
|
|
231
254
|
}
|
|
232
255
|
if (fcNas?.length) {
|
|
233
|
-
fcNas.forEach((
|
|
234
|
-
fcn.addRosDependency(`${fnc.key}_nas_mount_${(0, common_1.encodeBase64ForRosId)(nasItem.mountDir)}`);
|
|
235
|
-
});
|
|
256
|
+
fcNas.forEach(({ nasMountTargetId }) => fcn.addRosDependency(nasMountTargetId));
|
|
236
257
|
}
|
|
237
258
|
});
|
|
238
259
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ros from '@alicloud/ros-cdk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { Context, ServerlessIac } from '../../types';
|
|
3
3
|
export * from './bootstrap';
|
|
4
4
|
export declare class RosStack extends ros.Stack {
|
|
5
5
|
private readonly service;
|
|
6
|
-
constructor(scope: ros.Construct, iac: ServerlessIac, context:
|
|
6
|
+
constructor(scope: ros.Construct, iac: ServerlessIac, context: Context);
|
|
7
7
|
}
|
|
@@ -49,14 +49,14 @@ const bucket_1 = require("./bucket");
|
|
|
49
49
|
__exportStar(require("./bootstrap"), exports);
|
|
50
50
|
class RosStack extends ros.Stack {
|
|
51
51
|
constructor(scope, iac, context) {
|
|
52
|
-
super(scope, (0, common_1.
|
|
52
|
+
super(scope, (0, common_1.calcRefs)(iac.service, context), {
|
|
53
53
|
stackName: context.stackName,
|
|
54
54
|
tags: (0, tag_1.resolveTags)(iac.tags, context),
|
|
55
55
|
});
|
|
56
|
-
this.service = (0, common_1.
|
|
56
|
+
this.service = (0, common_1.calcRefs)(iac.service, context);
|
|
57
57
|
new ros.RosInfo(this, ros.RosInfo.description, `${this.service} stack`);
|
|
58
58
|
// Define Parameters
|
|
59
|
-
(0, vars_1.
|
|
59
|
+
(0, vars_1.resolveVars)(this, iac.vars);
|
|
60
60
|
// Define Mappings
|
|
61
61
|
(0, stage_1.resolveStages)(this, iac.stages, context);
|
|
62
62
|
// Define functions
|
|
@@ -41,6 +41,6 @@ const resolveStages = (scope, stages, context) => {
|
|
|
41
41
|
if ((0, lodash_1.isEmpty)(stages)) {
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
|
-
new ros.RosMapping(scope, 'stages', { mapping: (0, common_1.
|
|
44
|
+
new ros.RosMapping(scope, 'stages', { mapping: (0, common_1.calcRefs)(stages, context) });
|
|
45
45
|
};
|
|
46
46
|
exports.resolveStages = resolveStages;
|
|
@@ -4,7 +4,7 @@ exports.resolveTags = void 0;
|
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const resolveTags = (tags, context) => {
|
|
6
6
|
return tags?.reduce((acc, tag) => {
|
|
7
|
-
acc[tag.key] = (0, common_1.
|
|
7
|
+
acc[tag.key] = (0, common_1.calcRefs)(tag.value, context);
|
|
8
8
|
return acc;
|
|
9
9
|
}, {});
|
|
10
10
|
};
|
|
@@ -33,11 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.resolveVars = void 0;
|
|
37
37
|
const ros = __importStar(require("@alicloud/ros-cdk-core"));
|
|
38
38
|
const ros_cdk_core_1 = require("@alicloud/ros-cdk-core");
|
|
39
39
|
const lodash_1 = require("lodash");
|
|
40
|
-
const
|
|
40
|
+
const resolveVars = (scope, vars) => {
|
|
41
41
|
if ((0, lodash_1.isEmpty)(vars)) {
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
@@ -46,4 +46,4 @@ const resloveVars = (scope, vars) => {
|
|
|
46
46
|
defaultValue: value,
|
|
47
47
|
}));
|
|
48
48
|
};
|
|
49
|
-
exports.
|
|
49
|
+
exports.resolveVars = resolveVars;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/index.ts","../src/commands/template.ts","../src/commands/validate.ts","../src/common/
|
|
1
|
+
{"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/index.ts","../src/commands/template.ts","../src/commands/validate.ts","../src/common/base64.ts","../src/common/constants.ts","../src/common/context.ts","../src/common/domainHelper.ts","../src/common/getVersion.ts","../src/common/iacHelper.ts","../src/common/imsClient.ts","../src/common/index.ts","../src/common/logger.ts","../src/common/providerEnum.ts","../src/common/rosAssets.ts","../src/common/rosClient.ts","../src/lang/index.ts","../src/parser/bucketParser.ts","../src/parser/databaseParser.ts","../src/parser/eventParser.ts","../src/parser/functionParser.ts","../src/parser/index.ts","../src/parser/tagParser.ts","../src/stack/deploy.ts","../src/stack/index.ts","../src/stack/rfsStack/function.ts","../src/stack/rfsStack/index.ts","../src/stack/rosStack/bootstrap.ts","../src/stack/rosStack/bucket.ts","../src/stack/rosStack/database.ts","../src/stack/rosStack/event.ts","../src/stack/rosStack/function.ts","../src/stack/rosStack/index.ts","../src/stack/rosStack/stage.ts","../src/stack/rosStack/tag.ts","../src/stack/rosStack/vars.ts","../src/types/assets.ts","../src/types/index.ts","../src/types/domains/bucket.ts","../src/types/domains/context.ts","../src/types/domains/database.ts","../src/types/domains/event.ts","../src/types/domains/function.ts","../src/types/domains/provider.ts","../src/types/domains/tag.ts","../src/types/domains/vars.ts","../src/validator/bucketSchema.ts","../src/validator/databaseSchema.ts","../src/validator/eventSchema.ts","../src/validator/functionSchema.ts","../src/validator/iacSchema.ts","../src/validator/index.ts","../src/validator/rootSchema.ts"],"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -49,51 +49,52 @@
|
|
|
49
49
|
"function"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@alicloud/ims20190815": "^2.
|
|
53
|
-
"@alicloud/openapi-client": "^0.4.
|
|
54
|
-
"@alicloud/ros-cdk-apigateway": "^1.
|
|
55
|
-
"@alicloud/ros-cdk-core": "^1.
|
|
56
|
-
"@alicloud/ros-cdk-dns": "^1.
|
|
57
|
-
"@alicloud/ros-cdk-ecs": "^1.
|
|
58
|
-
"@alicloud/ros-cdk-elasticsearchserverless": "^1.
|
|
59
|
-
"@alicloud/ros-cdk-fc3": "^1.
|
|
60
|
-
"@alicloud/ros-cdk-nas": "^1.
|
|
61
|
-
"@alicloud/ros-cdk-oss": "^1.
|
|
62
|
-
"@alicloud/ros-cdk-ossdeployment": "^1.
|
|
63
|
-
"@alicloud/ros-cdk-ram": "^1.
|
|
64
|
-
"@alicloud/ros-cdk-rds": "^1.
|
|
65
|
-
"@alicloud/ros-cdk-sls": "^1.
|
|
66
|
-
"@alicloud/
|
|
52
|
+
"@alicloud/ims20190815": "^2.2.0",
|
|
53
|
+
"@alicloud/openapi-client": "^0.4.14",
|
|
54
|
+
"@alicloud/ros-cdk-apigateway": "^1.8.0",
|
|
55
|
+
"@alicloud/ros-cdk-core": "^1.8.0",
|
|
56
|
+
"@alicloud/ros-cdk-dns": "^1.8.0",
|
|
57
|
+
"@alicloud/ros-cdk-ecs": "^1.8.0",
|
|
58
|
+
"@alicloud/ros-cdk-elasticsearchserverless": "^1.8.0",
|
|
59
|
+
"@alicloud/ros-cdk-fc3": "^1.8.0",
|
|
60
|
+
"@alicloud/ros-cdk-nas": "^1.8.0",
|
|
61
|
+
"@alicloud/ros-cdk-oss": "^1.8.0",
|
|
62
|
+
"@alicloud/ros-cdk-ossdeployment": "^1.8.0",
|
|
63
|
+
"@alicloud/ros-cdk-ram": "^1.8.0",
|
|
64
|
+
"@alicloud/ros-cdk-rds": "^1.8.0",
|
|
65
|
+
"@alicloud/ros-cdk-sls": "^1.8.0",
|
|
66
|
+
"@alicloud/ros-cdk-vpc": "^1.8.0",
|
|
67
|
+
"@alicloud/ros20190910": "^3.5.6",
|
|
67
68
|
"ajv": "^8.17.1",
|
|
68
69
|
"ali-oss": "^6.22.0",
|
|
69
70
|
"chalk": "^5.4.1",
|
|
70
|
-
"commander": "^
|
|
71
|
+
"commander": "^13.1.0",
|
|
71
72
|
"i": "^0.3.7",
|
|
72
73
|
"i18n": "^0.15.1",
|
|
73
74
|
"jszip": "^3.10.1",
|
|
74
75
|
"lodash": "^4.17.21",
|
|
75
|
-
"npm": "^11.
|
|
76
|
-
"pino": "^9.
|
|
76
|
+
"npm": "^11.2.0",
|
|
77
|
+
"pino": "^9.6.0",
|
|
77
78
|
"pino-pretty": "^13.0.0",
|
|
78
|
-
"yaml": "^2.7.
|
|
79
|
+
"yaml": "^2.7.1"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
81
82
|
"@types/ali-oss": "^6.16.11",
|
|
82
83
|
"@types/i18n": "^0.13.12",
|
|
83
84
|
"@types/jest": "^29.5.14",
|
|
84
|
-
"@types/lodash": "^4.17.
|
|
85
|
-
"@types/node": "^22.
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
87
|
-
"@typescript-eslint/parser": "^8.
|
|
88
|
-
"eslint": "^9.
|
|
89
|
-
"eslint-config-prettier": "^
|
|
90
|
-
"eslint-plugin-prettier": "^5.2.
|
|
91
|
-
"globals": "^
|
|
85
|
+
"@types/lodash": "^4.17.16",
|
|
86
|
+
"@types/node": "^22.14.0",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
|
88
|
+
"@typescript-eslint/parser": "^8.29.0",
|
|
89
|
+
"eslint": "^9.24.0",
|
|
90
|
+
"eslint-config-prettier": "^10.1.1",
|
|
91
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
92
|
+
"globals": "^16.0.0",
|
|
92
93
|
"husky": "^9.1.7",
|
|
93
94
|
"jest": "^29.7.0",
|
|
94
|
-
"prettier": "^3.
|
|
95
|
-
"ts-jest": "^29.
|
|
95
|
+
"prettier": "^3.5.3",
|
|
96
|
+
"ts-jest": "^29.3.1",
|
|
96
97
|
"ts-node": "^10.9.2",
|
|
97
|
-
"typescript": "^5.
|
|
98
|
+
"typescript": "^5.8.3"
|
|
98
99
|
}
|
|
99
100
|
}
|