@geek-fun/serverlessinsight 0.8.3 → 0.8.4
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/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +3 -2
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +21 -2
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +44 -33
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +3 -2
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +63 -23
- package/dist/package.json +3 -2
- package/dist/src/common/aliyunClient/apigwOperations.js +36 -0
- package/dist/src/common/aliyunClient/slsOperations.js +34 -2
- package/dist/src/common/constants.js +5 -1
- package/dist/src/common/stateBackend/remoteStateBackend.js +4 -1
- package/dist/src/common/stateManager.js +52 -2
- package/dist/src/common/tencentClient/clsOperations.js +137 -0
- package/dist/src/common/tencentClient/index.js +21 -1
- package/dist/src/common/tencentClient/scfOperations.js +11 -0
- package/dist/src/common/volcengineClient/iamOperations.js +33 -0
- package/dist/src/common/volcengineClient/tlsOperations.js +84 -1
- package/dist/src/lang/en.js +23 -1
- package/dist/src/lang/zh-CN.js +23 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +2 -0
- package/dist/src/stack/aliyunStack/apigwResource.js +118 -1
- package/dist/src/stack/aliyunStack/apigwTypes.js +19 -1
- package/dist/src/stack/aliyunStack/destroyer.js +25 -0
- package/dist/src/stack/aliyunStack/fc3Resource.js +91 -32
- package/dist/src/stack/aliyunStack/sharedLogProject.js +137 -0
- package/dist/src/stack/ownershipTag.js +19 -1
- package/dist/src/stack/scfStack/destroyer.js +13 -0
- package/dist/src/stack/scfStack/scfPlanner.js +9 -1
- package/dist/src/stack/scfStack/scfResource.js +205 -13
- package/dist/src/stack/scfStack/scfTypes.js +6 -0
- package/dist/src/stack/scfStack/sharedLogset.js +126 -0
- package/dist/src/stack/volcengineStack/apigwResource.js +64 -48
- package/dist/src/stack/volcengineStack/apigwTypes.js +9 -0
- package/dist/src/stack/volcengineStack/destroyer.js +12 -0
- package/dist/src/stack/volcengineStack/sharedLogProject.js +190 -0
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +20 -13
- package/dist/src/stack/volcengineStack/vefaasResource.js +76 -76
- package/dist/src/types/domains/state.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClsOperations = void 0;
|
|
4
|
+
const polling_1 = require("../polling");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
// CLS reports missing resources with `ResourceNotFound.<Kind>NotExist` codes —
|
|
7
|
+
// match by suffix so get/delete operations stay idempotent.
|
|
8
|
+
const isResourceNotFound = (error) => {
|
|
9
|
+
if (!error || typeof error !== 'object' || !('code' in error)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const code = error.code;
|
|
13
|
+
return typeof code === 'string' && code.includes('NotExist');
|
|
14
|
+
};
|
|
15
|
+
const isAlreadyExists = (error) => {
|
|
16
|
+
if (!error || typeof error !== 'object') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const rec = error;
|
|
20
|
+
const code = typeof rec.code === 'string' ? rec.code : '';
|
|
21
|
+
const message = typeof rec.message === 'string' ? rec.message.toLowerCase() : '';
|
|
22
|
+
return (code.includes('AlreadyExists') ||
|
|
23
|
+
code.includes('ResourceExists') ||
|
|
24
|
+
message.includes('already exist'));
|
|
25
|
+
};
|
|
26
|
+
const createClsOperations = (clsClient) => {
|
|
27
|
+
const operations = {
|
|
28
|
+
createLogset: async (logsetName, tags) => {
|
|
29
|
+
const response = await clsClient.CreateLogset({
|
|
30
|
+
LogsetName: logsetName,
|
|
31
|
+
Tags: tags.map((t) => ({ Key: t.key, Value: t.value })),
|
|
32
|
+
});
|
|
33
|
+
return { logsetId: response?.LogsetId ?? '' };
|
|
34
|
+
},
|
|
35
|
+
getLogsetByName: async (logsetName) => {
|
|
36
|
+
const response = await clsClient.DescribeLogsets({
|
|
37
|
+
Filters: [{ Key: 'logsetName', Values: [logsetName] }],
|
|
38
|
+
});
|
|
39
|
+
// Preserve Tags so adopters can verify app-scope ownership of the logset.
|
|
40
|
+
const found = response?.Logsets?.find((l) => l.LogsetName === logsetName) ?? null;
|
|
41
|
+
if (!found) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
LogsetId: found.LogsetId,
|
|
46
|
+
LogsetName: found.LogsetName,
|
|
47
|
+
Tags: found.Tags,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
listTopicsByLogset: async (logsetId) => {
|
|
51
|
+
const response = await clsClient.DescribeTopics({
|
|
52
|
+
Filters: [{ Key: 'logsetId', Values: [logsetId] }],
|
|
53
|
+
Limit: 500,
|
|
54
|
+
});
|
|
55
|
+
return response?.Topics ?? [];
|
|
56
|
+
},
|
|
57
|
+
getTopicByName: async (logsetId, topicName) => {
|
|
58
|
+
const response = await clsClient.DescribeTopics({
|
|
59
|
+
Filters: [
|
|
60
|
+
{ Key: 'topicName', Values: [topicName] },
|
|
61
|
+
{ Key: 'logsetId', Values: [logsetId] },
|
|
62
|
+
],
|
|
63
|
+
PreciseSearch: 3,
|
|
64
|
+
});
|
|
65
|
+
return response?.Topics?.find((t) => t.TopicName === topicName) ?? null;
|
|
66
|
+
},
|
|
67
|
+
waitForTopic: async (logsetId, topicName) => (0, polling_1.pollUntil)({
|
|
68
|
+
description: `CLS topic ${topicName} to become visible`,
|
|
69
|
+
fetch: () => operations.getTopicByName(logsetId, topicName),
|
|
70
|
+
isDone: (topic) => topic !== null,
|
|
71
|
+
intervalMs: constants_1.CLS_TOPIC_POLL_INTERVAL_MS,
|
|
72
|
+
maxAttempts: constants_1.CLS_TOPIC_POLL_MAX_ATTEMPTS,
|
|
73
|
+
}),
|
|
74
|
+
// Topic creation is async on Tencent CLS — CreateTopic returns before the
|
|
75
|
+
// topic is queryable, so poll until DescribeTopics sees it.
|
|
76
|
+
createTopic: async (logsetId, topicName, opts) => {
|
|
77
|
+
await clsClient.CreateTopic({
|
|
78
|
+
LogsetId: logsetId,
|
|
79
|
+
TopicName: topicName,
|
|
80
|
+
StorageType: opts.storageType ?? 'hot',
|
|
81
|
+
Period: opts.period ?? 30,
|
|
82
|
+
Tags: opts.tags.map((t) => ({ Key: t.key, Value: t.value })),
|
|
83
|
+
});
|
|
84
|
+
const topic = await operations.waitForTopic(logsetId, topicName);
|
|
85
|
+
return { topicId: topic?.TopicId ?? '' };
|
|
86
|
+
},
|
|
87
|
+
deleteTopic: async (topicId) => {
|
|
88
|
+
try {
|
|
89
|
+
await clsClient.DeleteTopic({ TopicId: topicId });
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (isResourceNotFound(error)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
deleteLogset: async (logsetId) => {
|
|
99
|
+
try {
|
|
100
|
+
await clsClient.DeleteLogset({ LogsetId: logsetId });
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (isResourceNotFound(error)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
createFulltextIndex: async (topicId) => {
|
|
110
|
+
try {
|
|
111
|
+
await clsClient.CreateIndex({
|
|
112
|
+
TopicId: topicId,
|
|
113
|
+
Rule: { FullText: { CaseSensitive: false, Tokenizer: ' ,.?;!\n\t' } },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (isResourceNotFound(error) || isAlreadyExists(error)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
deleteIndex: async (topicId) => {
|
|
124
|
+
try {
|
|
125
|
+
await clsClient.DeleteIndex({ TopicId: topicId });
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (isResourceNotFound(error)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
return operations;
|
|
136
|
+
};
|
|
137
|
+
exports.createClsOperations = createClsOperations;
|
|
@@ -39,13 +39,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.createTencentClient = void 0;
|
|
42
|
+
exports.createTencentClient = exports.createClsOperations = void 0;
|
|
43
43
|
const tencentcloud = __importStar(require("tencentcloud-sdk-nodejs-scf"));
|
|
44
44
|
const cynosdb = __importStar(require("tencentcloud-sdk-nodejs-cynosdb"));
|
|
45
45
|
const tencentCam = __importStar(require("tencentcloud-sdk-nodejs-cam"));
|
|
46
46
|
const tencentEs = __importStar(require("tencentcloud-sdk-nodejs-es"));
|
|
47
47
|
const tencentSsl = __importStar(require("tencentcloud-sdk-nodejs-ssl"));
|
|
48
48
|
const tencentTag = __importStar(require("tencentcloud-sdk-nodejs-tag"));
|
|
49
|
+
const tencentCls = __importStar(require("tencentcloud-sdk-nodejs-cls"));
|
|
49
50
|
const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
|
|
50
51
|
const scfOperations_1 = require("./scfOperations");
|
|
51
52
|
const cosOperations_1 = require("./cosOperations");
|
|
@@ -54,13 +55,17 @@ const tdsqlcOperations_1 = require("./tdsqlcOperations");
|
|
|
54
55
|
const esOperations_1 = require("./esOperations");
|
|
55
56
|
const dnspodOperations_1 = require("./dnspodOperations");
|
|
56
57
|
const sslOperations_1 = require("./sslOperations");
|
|
58
|
+
const clsOperations_1 = require("./clsOperations");
|
|
57
59
|
__exportStar(require("./types"), exports);
|
|
60
|
+
var clsOperations_2 = require("./clsOperations");
|
|
61
|
+
Object.defineProperty(exports, "createClsOperations", { enumerable: true, get: function () { return clsOperations_2.createClsOperations; } });
|
|
58
62
|
const ScfClient = tencentcloud.scf.v20180416.Client;
|
|
59
63
|
const CynosdbClient = cynosdb.cynosdb.v20190107.Client;
|
|
60
64
|
const CamClient = tencentCam.cam.v20190116.Client;
|
|
61
65
|
const EsClient = tencentEs.es.v20180416.Client;
|
|
62
66
|
const SslClient = tencentSsl.ssl.v20191205.Client;
|
|
63
67
|
const TagClient = tencentTag.tag.v20180813.Client;
|
|
68
|
+
const ClsClient = tencentCls.cls.v20201016.Client;
|
|
64
69
|
// Initialize SDK clients (internal)
|
|
65
70
|
const initializeSdkClients = (context) => {
|
|
66
71
|
const scfClientConfig = {
|
|
@@ -145,6 +150,19 @@ const initializeSdkClients = (context) => {
|
|
|
145
150
|
},
|
|
146
151
|
};
|
|
147
152
|
const tagClient = new TagClient(tagClientConfig);
|
|
153
|
+
const clsClientConfig = {
|
|
154
|
+
credential: {
|
|
155
|
+
secretId: context.accessKeyId,
|
|
156
|
+
secretKey: context.accessKeySecret,
|
|
157
|
+
},
|
|
158
|
+
region: context.region,
|
|
159
|
+
profile: {
|
|
160
|
+
httpProfile: {
|
|
161
|
+
endpoint: 'cls.tencentcloudapi.com',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
const clsClient = new ClsClient(clsClientConfig);
|
|
148
166
|
return {
|
|
149
167
|
scf: scfClient,
|
|
150
168
|
cos: cosClient,
|
|
@@ -154,6 +172,7 @@ const initializeSdkClients = (context) => {
|
|
|
154
172
|
dns: (0, dnspodOperations_1.createDnsClient)(context),
|
|
155
173
|
cam: camClient,
|
|
156
174
|
tag: tagClient,
|
|
175
|
+
cls: clsClient,
|
|
157
176
|
};
|
|
158
177
|
};
|
|
159
178
|
const createTencentClient = (context) => {
|
|
@@ -171,6 +190,7 @@ const createTencentClient = (context) => {
|
|
|
171
190
|
tdsqlc: (0, tdsqlcOperations_1.createTdsqlcOperations)(sdkClients.cynosdb, context),
|
|
172
191
|
es: (0, esOperations_1.createTencentEsOperations)(sdkClients.es, context),
|
|
173
192
|
ssl: (0, sslOperations_1.createSslOperations)(sdkClients.ssl),
|
|
193
|
+
cls: (0, clsOperations_1.createClsOperations)(sdkClients.cls),
|
|
174
194
|
dns: dnsOps,
|
|
175
195
|
};
|
|
176
196
|
};
|
|
@@ -55,6 +55,8 @@ const createScfOperations = (scfClient, deps) => {
|
|
|
55
55
|
MemorySize: config.MemorySize,
|
|
56
56
|
Timeout: config.Timeout,
|
|
57
57
|
...(config.Role && { Role: config.Role }),
|
|
58
|
+
...(config.ClsLogsetId && { ClsLogsetId: config.ClsLogsetId }),
|
|
59
|
+
...(config.ClsTopicId && { ClsTopicId: config.ClsTopicId }),
|
|
58
60
|
...(config.Environment && { Environment: config.Environment }),
|
|
59
61
|
};
|
|
60
62
|
await scfClient.CreateFunction(params);
|
|
@@ -174,11 +176,20 @@ const createScfOperations = (scfClient, deps) => {
|
|
|
174
176
|
// Handler and Runtime are set at creation time and CANNOT be changed via
|
|
175
177
|
// UpdateFunctionConfiguration (Tencent rejects them with
|
|
176
178
|
// InvalidParameterValue.Handler / .Runtime) — omit them here.
|
|
179
|
+
//
|
|
180
|
+
// Tencent requires Role whenever the Cls* destination changes, else
|
|
181
|
+
// UpdateFunctionConfiguration fails with InvalidParameterValue.ClsRole —
|
|
182
|
+
// so Role is forwarded here whenever an si-managed role is present.
|
|
183
|
+
//
|
|
184
|
+
// Cls ids are forwarded whenever present — including '' — because
|
|
185
|
+
// passing ClsLogsetId/ClsTopicId as '' is Tencent's unbind contract.
|
|
177
186
|
const params = {
|
|
178
187
|
FunctionName: config.FunctionName,
|
|
179
188
|
MemorySize: config.MemorySize,
|
|
180
189
|
Timeout: config.Timeout,
|
|
181
190
|
...(config.Role && { Role: config.Role }),
|
|
191
|
+
...(config.ClsLogsetId !== undefined ? { ClsLogsetId: config.ClsLogsetId } : {}),
|
|
192
|
+
...(config.ClsTopicId !== undefined ? { ClsTopicId: config.ClsTopicId } : {}),
|
|
182
193
|
...(config.Environment && { Environment: config.Environment }),
|
|
183
194
|
};
|
|
184
195
|
await operations.waitForFunctionActive(config.FunctionName);
|
|
@@ -58,6 +58,16 @@ const buildExecutionPolicy = (customStatements) => {
|
|
|
58
58
|
const merged = (0, iamStatements_1.mergePolicyStatements)(VEFAAS_EXECUTION_STATEMENTS, customStatements, mapToVolcengineStatement);
|
|
59
59
|
return (0, iamStatements_1.buildPolicyDocument)(merged);
|
|
60
60
|
};
|
|
61
|
+
// TagResources expects flat numbered query params (ResourceIds.1, Tags.1.Key, ...).
|
|
62
|
+
// ResourceIds.1 carries the ROLE NAME (consistent with DeleteRole using RoleName).
|
|
63
|
+
const buildTagResourceQuery = (roleName, tags) => {
|
|
64
|
+
return tags.reduce((query, tag, index) => {
|
|
65
|
+
const n = index + 1;
|
|
66
|
+
query[`Tags.${n}.Key`] = tag.key;
|
|
67
|
+
query[`Tags.${n}.Value`] = tag.value;
|
|
68
|
+
return query;
|
|
69
|
+
}, { ResourceType: 'role', 'ResourceIds.1': roleName });
|
|
70
|
+
};
|
|
61
71
|
const createIamOperations = (iamClient) => {
|
|
62
72
|
const createAndAttachPolicy = async (roleName, customStatements) => {
|
|
63
73
|
const policyName = `${roleName}-policy`;
|
|
@@ -440,6 +450,29 @@ const createIamOperations = (iamClient) => {
|
|
|
440
450
|
logger_1.logger.info(lang_1.lang.__('MANAGED_POLICY_ATTACHED', { policyArn: policyName, roleName }));
|
|
441
451
|
}
|
|
442
452
|
},
|
|
453
|
+
tagRole: async (roleName, tags) => {
|
|
454
|
+
try {
|
|
455
|
+
await iamClient.fetchOpenAPI({
|
|
456
|
+
Action: 'TagResources',
|
|
457
|
+
Version: '2018-01-01',
|
|
458
|
+
method: 'GET',
|
|
459
|
+
headers: { 'content-type': 'application/json' },
|
|
460
|
+
query: buildTagResourceQuery(roleName, tags),
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
465
|
+
const code = String(error.code);
|
|
466
|
+
if (code.startsWith('ResourceNotFound.Role') ||
|
|
467
|
+
code === 'RoleNotFound' ||
|
|
468
|
+
code === 'NoSuchEntity') {
|
|
469
|
+
logger_1.logger.warn(lang_1.lang.__('VOLCENGINE_ROLE_NOT_FOUND_FOR_TAG', { roleName }));
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
throw error;
|
|
474
|
+
}
|
|
475
|
+
},
|
|
443
476
|
};
|
|
444
477
|
};
|
|
445
478
|
exports.createIamOperations = createIamOperations;
|
|
@@ -84,6 +84,22 @@ const isNotFoundError = (error) => {
|
|
|
84
84
|
code === 'ResourceNotFound' ||
|
|
85
85
|
code === 'NotFound');
|
|
86
86
|
};
|
|
87
|
+
const listTagsForResource = async (tlsClient, resourceType, resourceId) => {
|
|
88
|
+
try {
|
|
89
|
+
const response = await tlsClient.ListTagsForResources({
|
|
90
|
+
ResourceType: resourceType,
|
|
91
|
+
ResourcesIds: [resourceId],
|
|
92
|
+
MaxResults: 50,
|
|
93
|
+
});
|
|
94
|
+
return (response.ResourceTags ?? []).map((rt) => ({ Key: rt.TagKey, Value: rt.TagValue }));
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (isNotFoundError(error)) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
87
103
|
const createTlsOperations = (tlsClient) => {
|
|
88
104
|
const operations = {
|
|
89
105
|
createProject: async (config) => {
|
|
@@ -100,6 +116,7 @@ const createTlsOperations = (tlsClient) => {
|
|
|
100
116
|
description: config.description,
|
|
101
117
|
region: config.region,
|
|
102
118
|
status: 'Active',
|
|
119
|
+
created: true,
|
|
103
120
|
};
|
|
104
121
|
}
|
|
105
122
|
catch (error) {
|
|
@@ -107,13 +124,14 @@ const createTlsOperations = (tlsClient) => {
|
|
|
107
124
|
logger_1.logger.warn(lang_1.lang.__('TLS_PROJECT_ALREADY_EXISTS', { projectName: config.projectName }));
|
|
108
125
|
const existing = await operations.getProject(config.projectName);
|
|
109
126
|
if (existing) {
|
|
110
|
-
return existing;
|
|
127
|
+
return { ...existing, created: false };
|
|
111
128
|
}
|
|
112
129
|
return {
|
|
113
130
|
projectName: config.projectName,
|
|
114
131
|
description: config.description,
|
|
115
132
|
region: config.region,
|
|
116
133
|
status: 'Active',
|
|
134
|
+
created: false,
|
|
117
135
|
};
|
|
118
136
|
}
|
|
119
137
|
throw error;
|
|
@@ -142,6 +160,13 @@ const createTlsOperations = (tlsClient) => {
|
|
|
142
160
|
throw error;
|
|
143
161
|
}
|
|
144
162
|
},
|
|
163
|
+
getProjectTags: async (projectName) => {
|
|
164
|
+
const project = await operations.getProject(projectName);
|
|
165
|
+
if (!project?.projectId) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
return listTagsForResource(tlsClient, 'project', project.projectId);
|
|
169
|
+
},
|
|
145
170
|
deleteProject: async (projectName) => {
|
|
146
171
|
try {
|
|
147
172
|
const existing = await operations.getProject(projectName);
|
|
@@ -215,6 +240,7 @@ const createTlsOperations = (tlsClient) => {
|
|
|
215
240
|
if (!topic) {
|
|
216
241
|
return null;
|
|
217
242
|
}
|
|
243
|
+
const tags = await listTagsForResource(tlsClient, 'topic', topic.TopicId);
|
|
218
244
|
return {
|
|
219
245
|
topicId: topic.TopicId,
|
|
220
246
|
topicName: topic.TopicName,
|
|
@@ -223,6 +249,7 @@ const createTlsOperations = (tlsClient) => {
|
|
|
223
249
|
ttl: topic.Ttl,
|
|
224
250
|
createTime: topic.CreateTime,
|
|
225
251
|
status: 'Active',
|
|
252
|
+
tags,
|
|
226
253
|
};
|
|
227
254
|
}
|
|
228
255
|
catch (error) {
|
|
@@ -232,6 +259,30 @@ const createTlsOperations = (tlsClient) => {
|
|
|
232
259
|
throw error;
|
|
233
260
|
}
|
|
234
261
|
},
|
|
262
|
+
listTopics: async (projectName) => {
|
|
263
|
+
try {
|
|
264
|
+
const project = await operations.getProject(projectName);
|
|
265
|
+
if (!project?.projectId) {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
const response = await tlsClient.DescribeTopics({ ProjectId: project.projectId });
|
|
269
|
+
return (response.Topics ?? []).map((topic) => ({
|
|
270
|
+
topicId: topic.TopicId,
|
|
271
|
+
topicName: topic.TopicName,
|
|
272
|
+
projectName,
|
|
273
|
+
description: topic.Description,
|
|
274
|
+
ttl: topic.Ttl,
|
|
275
|
+
createTime: topic.CreateTime,
|
|
276
|
+
status: 'Active',
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
if (isNotFoundError(error)) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
},
|
|
235
286
|
deleteTopic: async (projectName, topicName) => {
|
|
236
287
|
try {
|
|
237
288
|
const existing = await operations.getTopic(projectName, topicName);
|
|
@@ -301,6 +352,38 @@ const createTlsOperations = (tlsClient) => {
|
|
|
301
352
|
waitForTopic: async (projectName, topicName) => {
|
|
302
353
|
await waitForTopicReady(operations.getTopic, projectName, topicName);
|
|
303
354
|
},
|
|
355
|
+
addTags: async (config) => {
|
|
356
|
+
try {
|
|
357
|
+
await tlsClient.AddTagsToResource({
|
|
358
|
+
ResourceType: config.resourceType,
|
|
359
|
+
ResourcesList: config.resourcesList,
|
|
360
|
+
Tags: config.tags.map((tag) => ({ Key: tag.key, Value: tag.value })),
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
if (isNotFoundError(error)) {
|
|
365
|
+
logger_1.logger.warn(lang_1.lang.__('TLS_TAG_TARGET_NOT_FOUND', { resourceType: config.resourceType }));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
throw error;
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
removeTags: async (config) => {
|
|
372
|
+
try {
|
|
373
|
+
await tlsClient.RemoveTagsFromResource({
|
|
374
|
+
ResourceType: config.resourceType,
|
|
375
|
+
ResourcesList: config.resourcesList,
|
|
376
|
+
TagKeyList: config.tagKeys,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
if (isNotFoundError(error)) {
|
|
381
|
+
logger_1.logger.warn(lang_1.lang.__('TLS_TAG_TARGET_NOT_FOUND', { resourceType: config.resourceType }));
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
},
|
|
304
387
|
};
|
|
305
388
|
return operations;
|
|
306
389
|
};
|
package/dist/src/lang/en.js
CHANGED
|
@@ -226,6 +226,12 @@ exports.en = {
|
|
|
226
226
|
APIGW_LOG_ENABLED: 'Access log enabled for API Gateway {{gatewayId}}',
|
|
227
227
|
APIGW_LOG_DISABLED: 'Access log disabled for API Gateway {{gatewayId}}',
|
|
228
228
|
APIGW_LOG_DISABLE_FAILED: 'Failed to disable access log for API Gateway {{gatewayId}}: {{error}}',
|
|
229
|
+
SLS_LOG_CONFIG_FOREIGN: 'Existing PROVIDER gateway log configuration points to {{slsProject}}/{{slsLogStore}}; leaving it untouched',
|
|
230
|
+
SLS_LOGSTORE_WAITING: 'Waiting for SLS logstore {{project}}/{{logstore}} to be ready...',
|
|
231
|
+
SHARED_SLS_PROJECT_IN_USE: '{{count}} logstore(s) still reference shared SLS project {{projectName}}; retaining it',
|
|
232
|
+
SHARED_SLS_PROJECT_ADOPTED: 'Adopting existing shared SLS project {{projectName}} owned by this app',
|
|
233
|
+
SLS_PROJECT_FOREIGN_OWNED: 'SLS project {{projectName}} exists but is not owned by this app; refusing to adopt',
|
|
234
|
+
APIGW_LOG_CONFIG_STILL_REFERENCES_STORE: 'Regional PROVIDER gateway log config still references {{slsLogStore}}; retaining logstore',
|
|
229
235
|
APIGW_DOMAIN_BINDING_FAILED: 'Failed to bind custom domain: {{error}}',
|
|
230
236
|
APIGW_DOMAIN_UNBIND_FAILED: 'Failed to unbind domain {{domain}}: {{error}}',
|
|
231
237
|
APIGW_WWW_DOMAIN_UNBIND_FAILED: 'Failed to unbind www domain {{domain}}: {{error}}',
|
|
@@ -388,7 +394,6 @@ exports.en = {
|
|
|
388
394
|
DELETING_RAM_ROLE: 'Deleting RAM role: {{id}}',
|
|
389
395
|
DELETING_SLS_INDEX: 'Deleting SLS index: {{id}}',
|
|
390
396
|
DELETING_SLS_LOGSTORE: 'Deleting SLS logstore: {{id}}',
|
|
391
|
-
DELETING_SLS_PROJECT: 'Deleting SLS project: {{id}}',
|
|
392
397
|
UNKNOWN_RESOURCE_TYPE: 'Unknown resource type: {{type}}',
|
|
393
398
|
FAILED_TO_DELETE_RESOURCE: 'Failed to delete resource {{type}}:{{id}}: {{error}}',
|
|
394
399
|
// OSS Resource messages
|
|
@@ -649,6 +654,12 @@ exports.en = {
|
|
|
649
654
|
TLS_TOPIC_CREATED: 'TLS topic {{topicName}} created successfully',
|
|
650
655
|
TLS_TOPIC_DELETED: 'TLS topic {{topicName}} deleted successfully',
|
|
651
656
|
TLS_TOPIC_NOT_FOUND: 'TLS topic {{topicName}} not found',
|
|
657
|
+
TLS_TAG_TARGET_NOT_FOUND: 'TLS {{resourceType}} not found while applying tags; skipping',
|
|
658
|
+
VOLCENGINE_ROLE_NOT_FOUND_FOR_TAG: 'IAM role {{roleName}} not found while applying tags; skipping',
|
|
659
|
+
SHARED_TLS_PROJECT_IN_USE: '{{count}} topic(s) still reference shared TLS project {{projectName}}; retaining it',
|
|
660
|
+
SHARED_TLS_PROJECT_DELETED: 'Deleted unused shared TLS project {{projectName}}',
|
|
661
|
+
TLS_SHARED_PROJECT_NOT_OWNED: 'Shared TLS project {{projectName}} exists but is not owned by this app (missing or foreign ownership tag); refusing to adopt or delete it',
|
|
662
|
+
TLS_TOPIC_FOREIGN_OWNED: 'TLS topic {{topicName}} exists but is owned by another stack; refusing to adopt',
|
|
652
663
|
TLS_TOPIC_ALREADY_EXISTS: 'TLS topic {{topicName}} already exists, adopting existing topic',
|
|
653
664
|
TLS_TOPIC_TIMEOUT: 'Timeout waiting for TLS topic {{topicName}} to be ready',
|
|
654
665
|
TLS_INDEX_CREATED: 'TLS index for topic {{topicName}} created successfully',
|
|
@@ -663,6 +674,17 @@ exports.en = {
|
|
|
663
674
|
DELETING_TLS_TOPIC: 'Deleting TLS topic: {{id}}',
|
|
664
675
|
DELETING_TLS_INDEX: 'Deleting TLS index: {{id}}',
|
|
665
676
|
WAITING_FOR_TLS_RESOURCES: 'Waiting for TLS resources to be ready: {{projectName}}/{{topicName}}',
|
|
677
|
+
// Tencent CLS (Cloud Log Service) messages
|
|
678
|
+
SHARED_CLS_LOGSET_IN_USE: '{{count}} topic(s) still reference shared CLS logset {{logsetName}}; retaining it',
|
|
679
|
+
SHARED_CLS_LOGSET_DELETED: 'Deleted unused shared CLS logset {{logsetName}}',
|
|
680
|
+
CLS_TOPIC_FOREIGN_OWNED: 'CLS topic {{topicName}} exists but is owned by another stack; refusing to adopt',
|
|
681
|
+
CLS_LOGSET_FOREIGN_OWNED: 'CLS logset {{logsetName}} exists but is not owned by this app; refusing to adopt',
|
|
682
|
+
CREATING_CLS_LOGSET: 'Creating CLS logset: {{logsetName}}',
|
|
683
|
+
CREATING_CLS_TOPIC: 'Creating CLS topic: {{topicName}}',
|
|
684
|
+
CREATING_CLS_INDEX: 'Creating CLS index for topic: {{topicName}}',
|
|
685
|
+
DELETING_CLS_TOPIC: 'Deleting CLS topic: {{id}}',
|
|
686
|
+
DELETING_CLS_INDEX: 'Deleting CLS index for topic: {{topicName}}',
|
|
687
|
+
CLS_LOG_DISABLED: 'Disabled CLS log delivery for function {{functionName}}',
|
|
666
688
|
// Volcengine veFaaS dependent resources
|
|
667
689
|
VEFAAS_DEPENDENT_RESOURCES_TRACKED: 'Dependent resources (TLS, IAM) are tracked in state',
|
|
668
690
|
VEFAAS_CAN_RETRY_DEPLOYMENT: 'You can retry deployment - the system will reuse existing dependent resources',
|
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -226,6 +226,12 @@ exports.zhCN = {
|
|
|
226
226
|
APIGW_LOG_ENABLED: '已为 API 网关 {{gatewayId}} 开启访问日志',
|
|
227
227
|
APIGW_LOG_DISABLED: '已为 API 网关 {{gatewayId}} 关闭访问日志',
|
|
228
228
|
APIGW_LOG_DISABLE_FAILED: '关闭 API 网关 {{gatewayId}} 访问日志失败:{{error}}',
|
|
229
|
+
SLS_LOG_CONFIG_FOREIGN: '已存在的 PROVIDER 网关日志配置指向 {{slsProject}}/{{slsLogStore}},保持不变',
|
|
230
|
+
SLS_LOGSTORE_WAITING: '等待 SLS 日志库 {{project}}/{{logstore}} 就绪...',
|
|
231
|
+
SHARED_SLS_PROJECT_IN_USE: '仍有 {{count}} 个日志库引用共享 SLS 项目 {{projectName}},予以保留',
|
|
232
|
+
SHARED_SLS_PROJECT_ADOPTED: '采用当前应用已有的共享 SLS 项目 {{projectName}}',
|
|
233
|
+
SLS_PROJECT_FOREIGN_OWNED: 'SLS 项目 {{projectName}} 已存在但不属于当前应用,拒绝采用',
|
|
234
|
+
APIGW_LOG_CONFIG_STILL_REFERENCES_STORE: '区域级 PROVIDER 网关日志配置仍引用 {{slsLogStore}},保留该日志库',
|
|
229
235
|
APIGW_DOMAIN_BINDING_FAILED: '绑定自定义域名失败:{{error}}',
|
|
230
236
|
APIGW_DOMAIN_UNBIND_FAILED: '解绑域名 {{domain}} 失败:{{error}}',
|
|
231
237
|
APIGW_WWW_DOMAIN_UNBIND_FAILED: '解绑 www 域名 {{domain}} 失败:{{error}}',
|
|
@@ -385,7 +391,6 @@ exports.zhCN = {
|
|
|
385
391
|
DELETING_RAM_ROLE: '正在删除 RAM 角色: {{id}}',
|
|
386
392
|
DELETING_SLS_INDEX: '正在删除 SLS 索引: {{id}}',
|
|
387
393
|
DELETING_SLS_LOGSTORE: '正在删除 SLS 日志库: {{id}}',
|
|
388
|
-
DELETING_SLS_PROJECT: '正在删除 SLS 项目: {{id}}',
|
|
389
394
|
UNKNOWN_RESOURCE_TYPE: '未知资源类型: {{type}}',
|
|
390
395
|
FAILED_TO_DELETE_RESOURCE: '删除资源 {{type}}:{{id}} 失败: {{error}}',
|
|
391
396
|
// OSS Resource messages
|
|
@@ -643,6 +648,12 @@ exports.zhCN = {
|
|
|
643
648
|
TLS_TOPIC_CREATED: 'TLS 主题 {{topicName}} 创建成功',
|
|
644
649
|
TLS_TOPIC_DELETED: 'TLS 主题 {{topicName}} 删除成功',
|
|
645
650
|
TLS_TOPIC_NOT_FOUND: 'TLS 主题 {{topicName}} 未找到',
|
|
651
|
+
TLS_TAG_TARGET_NOT_FOUND: '应用标签时未找到 TLS {{resourceType}},已跳过',
|
|
652
|
+
VOLCENGINE_ROLE_NOT_FOUND_FOR_TAG: '应用标签时未找到 IAM 角色 {{roleName}},已跳过',
|
|
653
|
+
SHARED_TLS_PROJECT_IN_USE: '仍有 {{count}} 个主题引用共享 TLS 项目 {{projectName}},予以保留',
|
|
654
|
+
SHARED_TLS_PROJECT_DELETED: '已删除未使用的共享 TLS 项目 {{projectName}}',
|
|
655
|
+
TLS_SHARED_PROJECT_NOT_OWNED: '共享 TLS 项目 {{projectName}} 已存在但不属于当前应用(缺少或持有非本应用的所有权标签),拒绝采用或删除',
|
|
656
|
+
TLS_TOPIC_FOREIGN_OWNED: 'TLS 主题 {{topicName}} 已存在但属于其他栈,拒绝采用',
|
|
646
657
|
TLS_TOPIC_ALREADY_EXISTS: 'TLS 主题 {{topicName}} 已存在,复用现有主题',
|
|
647
658
|
TLS_TOPIC_TIMEOUT: '等待 TLS 主题 {{topicName}} 就绪超时',
|
|
648
659
|
TLS_INDEX_CREATED: 'TLS 主题 {{topicName}} 索引创建成功',
|
|
@@ -657,6 +668,17 @@ exports.zhCN = {
|
|
|
657
668
|
DELETING_TLS_TOPIC: '正在删除 TLS 主题:{{id}}',
|
|
658
669
|
DELETING_TLS_INDEX: '正在删除 TLS 索引:{{id}}',
|
|
659
670
|
WAITING_FOR_TLS_RESOURCES: '等待 TLS 资源就绪:{{projectName}}/{{topicName}}',
|
|
671
|
+
// Tencent CLS(云日志服务)消息
|
|
672
|
+
SHARED_CLS_LOGSET_IN_USE: '仍有 {{count}} 个主题引用共享 CLS 日志集 {{logsetName}},予以保留',
|
|
673
|
+
SHARED_CLS_LOGSET_DELETED: '已删除未使用的共享 CLS 日志集 {{logsetName}}',
|
|
674
|
+
CLS_TOPIC_FOREIGN_OWNED: 'CLS 主题 {{topicName}} 已存在但属于其他栈,拒绝采用',
|
|
675
|
+
CLS_LOGSET_FOREIGN_OWNED: 'CLS 日志集 {{logsetName}} 已存在但不属于本应用,拒绝采用',
|
|
676
|
+
CREATING_CLS_LOGSET: '正在创建 CLS 日志集:{{logsetName}}',
|
|
677
|
+
CREATING_CLS_TOPIC: '正在创建 CLS 主题:{{topicName}}',
|
|
678
|
+
CREATING_CLS_INDEX: '正在为 CLS 主题创建索引:{{topicName}}',
|
|
679
|
+
DELETING_CLS_TOPIC: '正在删除 CLS 主题:{{id}}',
|
|
680
|
+
DELETING_CLS_INDEX: '正在删除 CLS 主题索引:{{topicName}}',
|
|
681
|
+
CLS_LOG_DISABLED: '已为函数 {{functionName}} 关闭 CLS 日志投递',
|
|
660
682
|
// Volcengine veFaaS dependent resources
|
|
661
683
|
VEFAAS_DEPENDENT_RESOURCES_TRACKED: '依赖资源(TLS、IAM)已在状态中跟踪',
|
|
662
684
|
VEFAAS_CAN_RETRY_DEPLOYMENT: '您可以重试部署 - 系统将复用现有的依赖资源',
|
|
@@ -34,6 +34,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
34
34
|
const groupDefinition = (0, apigwTypes_1.extractApigwGroupDefinition)(groupConfig);
|
|
35
35
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
36
36
|
// Build desired definition including triggers
|
|
37
|
+
const logSnapshot = (0, apigwTypes_1.buildEventLogSnapshot)(event, context);
|
|
37
38
|
const desiredDefinition = {
|
|
38
39
|
...groupDefinition,
|
|
39
40
|
triggers: event.triggers.map((t) => ({
|
|
@@ -42,6 +43,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
42
43
|
backend: t.backend,
|
|
43
44
|
})),
|
|
44
45
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
46
|
+
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
45
47
|
};
|
|
46
48
|
if (!currentState || currentState.status === 'tainted') {
|
|
47
49
|
// No usable local state: probe the provider before planning create.
|