@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
|
@@ -13,6 +13,7 @@ const domainUtils_1 = require("../../common/domainUtils");
|
|
|
13
13
|
const hashUtils_1 = require("../../common/hashUtils");
|
|
14
14
|
const ownershipTag_1 = require("../ownershipTag");
|
|
15
15
|
const alreadyExists_1 = require("../alreadyExists");
|
|
16
|
+
const sharedLogProject_1 = require("./sharedLogProject");
|
|
16
17
|
const getCdnConfig = (event) => {
|
|
17
18
|
const domainCdn = event.domain?.cdn;
|
|
18
19
|
if (domainCdn == null) {
|
|
@@ -265,6 +266,78 @@ const buildApigwDeploymentInstance = (groupId, apiId, stageName, stage) => {
|
|
|
265
266
|
stageName,
|
|
266
267
|
};
|
|
267
268
|
};
|
|
269
|
+
const buildLogConfigInstance = (context, slsProject, slsLogStore) => ({
|
|
270
|
+
sid: (0, common_1.buildSid)('aliyun', 'apigw-log-config', context.stage, `${context.region}:PROVIDER`),
|
|
271
|
+
type: 'ALIYUN_APIGW_LOG_CONFIG',
|
|
272
|
+
id: `${context.region}:PROVIDER`,
|
|
273
|
+
attributes: { slsProject, slsLogStore },
|
|
274
|
+
});
|
|
275
|
+
const ensureGatewayLogConfig = async (context, client, state) => {
|
|
276
|
+
const slsLogStore = `${context.service}-${context.stage}-apigw-logs`;
|
|
277
|
+
const ours = { slsProject: (0, sharedLogProject_1.buildSharedProjectName)(context.app, context.stage), slsLogStore };
|
|
278
|
+
const existing = await client.apigw.describeGatewayLogConfig();
|
|
279
|
+
const matchesOurs = existing &&
|
|
280
|
+
existing.slsProject === ours.slsProject &&
|
|
281
|
+
existing.slsLogStore === ours.slsLogStore;
|
|
282
|
+
if (matchesOurs) {
|
|
283
|
+
// The PROVIDER singleton already targets our shared project. Enforce the
|
|
284
|
+
// app-ownership invariant on both the tracked and untracked paths: only an
|
|
285
|
+
// app-owned project is reused or adopted; a foreign/untagged one is refused
|
|
286
|
+
// and a missing project (stale config) falls through to (re)creation.
|
|
287
|
+
const project = await client.sls.getProject(ours.slsProject);
|
|
288
|
+
if (project) {
|
|
289
|
+
if (!(await (0, sharedLogProject_1.isSharedProjectOwnedByApp)(context, client, ours.slsProject))) {
|
|
290
|
+
throw new Error(lang_1.lang.__('SLS_PROJECT_FOREIGN_OWNED', { projectName: ours.slsProject }));
|
|
291
|
+
}
|
|
292
|
+
const known = (0, stateManager_1.getSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY);
|
|
293
|
+
return {
|
|
294
|
+
instance: buildLogConfigInstance(context, ours.slsProject, ours.slsLogStore),
|
|
295
|
+
sharedProject: known ?? (0, sharedLogProject_1.adoptSharedSlsProjectState)(context, ours.slsProject),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else if (existing) {
|
|
300
|
+
logger_1.logger.warn(lang_1.lang.__('SLS_LOG_CONFIG_FOREIGN', {
|
|
301
|
+
slsProject: existing.slsProject ?? '',
|
|
302
|
+
slsLogStore: existing.slsLogStore ?? '',
|
|
303
|
+
}));
|
|
304
|
+
return {};
|
|
305
|
+
}
|
|
306
|
+
const shared = await (0, sharedLogProject_1.ensureSharedSlsProject)(context, client, state);
|
|
307
|
+
const sharedProject = (0, sharedLogProject_1.buildSharedProjectResourceState)(context, shared);
|
|
308
|
+
await (0, sharedLogProject_1.ensureGatewayLogstore)(context, client, shared.projectName);
|
|
309
|
+
await client.apigw.createGatewayLogConfig({
|
|
310
|
+
slsProject: shared.projectName,
|
|
311
|
+
slsLogStore,
|
|
312
|
+
});
|
|
313
|
+
return {
|
|
314
|
+
instance: buildLogConfigInstance(context, shared.projectName, slsLogStore),
|
|
315
|
+
sharedProject,
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
const releaseGatewayLogstoreIfNeeded = async (client, attrs) => {
|
|
319
|
+
const { slsProject, slsLogStore } = (attrs ?? {});
|
|
320
|
+
if (!slsProject || !slsLogStore) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const currentConfig = await client.apigw.describeGatewayLogConfig();
|
|
324
|
+
if (currentConfig?.slsLogStore === slsLogStore && currentConfig?.slsProject === slsProject) {
|
|
325
|
+
logger_1.logger.warn(lang_1.lang.__('APIGW_LOG_CONFIG_STILL_REFERENCES_STORE', { slsLogStore }));
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
await client.sls.deleteIndex(slsProject, slsLogStore);
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
// logstore already gone — index deletion is best-effort
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
await client.sls.deleteLogstore(slsProject, slsLogStore);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// logstore already gone
|
|
339
|
+
}
|
|
340
|
+
};
|
|
268
341
|
const resolveDomainCertificate = async (domain, serviceName, eventKey, stage, client) => {
|
|
269
342
|
if (domain.certificate_id) {
|
|
270
343
|
const certId = domain.certificate_id;
|
|
@@ -312,6 +385,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
312
385
|
];
|
|
313
386
|
const groupDefinition = (0, apigwTypes_1.extractApigwGroupDefinition)(groupConfig);
|
|
314
387
|
let groupId;
|
|
388
|
+
const logSnapshot = (0, apigwTypes_1.buildEventLogSnapshot)(event, context);
|
|
315
389
|
const buildResourceDefinition = () => ({
|
|
316
390
|
...groupDefinition,
|
|
317
391
|
triggers: event.triggers.map((t) => ({
|
|
@@ -320,6 +394,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
320
394
|
backend: t.backend,
|
|
321
395
|
})),
|
|
322
396
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
397
|
+
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
323
398
|
});
|
|
324
399
|
// Persist a tainted state BEFORE any cloud side-effect so a group created
|
|
325
400
|
// in cloud but not yet tracked stays tracked if a later step fails.
|
|
@@ -382,6 +457,18 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
382
457
|
status: 'tainted',
|
|
383
458
|
});
|
|
384
459
|
let currentState = stateAfterDependents;
|
|
460
|
+
if (event.log) {
|
|
461
|
+
const logResult = await ensureGatewayLogConfig(context, client, stateAfterDependents);
|
|
462
|
+
if (logResult?.sharedProject) {
|
|
463
|
+
stateAfterDependents = (0, stateManager_1.setSharedResource)(stateAfterDependents, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY, logResult.sharedProject);
|
|
464
|
+
// Keep currentState in sync so the shared project survives into the
|
|
465
|
+
// final returned state (the create path returns from currentState).
|
|
466
|
+
currentState = stateAfterDependents;
|
|
467
|
+
}
|
|
468
|
+
if (logResult?.instance) {
|
|
469
|
+
instances.push(logResult.instance);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
385
472
|
// Create APIs and deployments for each trigger
|
|
386
473
|
for (const trigger of event.triggers) {
|
|
387
474
|
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage, roleArn);
|
|
@@ -411,6 +498,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
411
498
|
backend: t.backend,
|
|
412
499
|
})),
|
|
413
500
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
501
|
+
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
414
502
|
},
|
|
415
503
|
instances,
|
|
416
504
|
lastUpdated: new Date().toISOString(),
|
|
@@ -476,6 +564,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
476
564
|
backend: t.backend,
|
|
477
565
|
})),
|
|
478
566
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
567
|
+
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
479
568
|
},
|
|
480
569
|
instances,
|
|
481
570
|
lastUpdated: new Date().toISOString(),
|
|
@@ -648,6 +737,23 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
648
737
|
}
|
|
649
738
|
}
|
|
650
739
|
}
|
|
740
|
+
const logSnapshot = (0, apigwTypes_1.buildEventLogSnapshot)(event, context);
|
|
741
|
+
let sharedProjectState;
|
|
742
|
+
if (event.log) {
|
|
743
|
+
const logResult = await ensureGatewayLogConfig(context, client, state);
|
|
744
|
+
if (logResult?.sharedProject) {
|
|
745
|
+
sharedProjectState = logResult.sharedProject;
|
|
746
|
+
}
|
|
747
|
+
if (logResult?.instance) {
|
|
748
|
+
instances.push(logResult.instance);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
const previousLogInstance = (existingState?.instances ?? []).find((i) => i.type === 'ALIYUN_APIGW_LOG_CONFIG');
|
|
753
|
+
if (previousLogInstance) {
|
|
754
|
+
await releaseGatewayLogstoreIfNeeded(client, previousLogInstance.attributes);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
651
757
|
if (event.domain) {
|
|
652
758
|
const desiredDomainDef = (0, apigwTypes_1.extractEventDomainDefinition)(event.domain);
|
|
653
759
|
const previousDomainDef = existingState?.definition?.domain;
|
|
@@ -805,11 +911,15 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
805
911
|
backend: t.backend,
|
|
806
912
|
})),
|
|
807
913
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
914
|
+
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
808
915
|
},
|
|
809
916
|
instances,
|
|
810
917
|
lastUpdated: new Date().toISOString(),
|
|
811
918
|
};
|
|
812
|
-
|
|
919
|
+
const finalState = sharedProjectState
|
|
920
|
+
? (0, stateManager_1.setSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY, sharedProjectState)
|
|
921
|
+
: state;
|
|
922
|
+
return (0, stateManager_1.setResource)(finalState, logicalId, resourceState);
|
|
813
923
|
};
|
|
814
924
|
exports.updateApigwResource = updateApigwResource;
|
|
815
925
|
const deleteApigwResource = async (context, logicalId, state) => {
|
|
@@ -904,6 +1014,13 @@ const deleteApigwResource = async (context, logicalId, state) => {
|
|
|
904
1014
|
name: groupId,
|
|
905
1015
|
}));
|
|
906
1016
|
}
|
|
1017
|
+
// The PROVIDER log configuration is a regional singleton — never deleted.
|
|
1018
|
+
// Tear down the per-service gateway logstore only when the singleton no
|
|
1019
|
+
// longer references it; otherwise it must be retained.
|
|
1020
|
+
const logConfigInstance = existingInstances.find((i) => i.type === 'ALIYUN_APIGW_LOG_CONFIG');
|
|
1021
|
+
if (logConfigInstance) {
|
|
1022
|
+
await releaseGatewayLogstoreIfNeeded(client, logConfigInstance.attributes);
|
|
1023
|
+
}
|
|
907
1024
|
return (0, stateManager_1.removeResource)(state, logicalId);
|
|
908
1025
|
};
|
|
909
1026
|
exports.deleteApigwResource = deleteApigwResource;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractEventDomainDefinition = exports.inferProtocolConfig = exports.extractApigwDeploymentDefinition = exports.extractApigwApiDefinition = exports.extractApigwGroupDefinition = exports.triggerToApigwApiConfig = exports.generateApiKey = exports.eventToApigwGroupConfig = void 0;
|
|
3
|
+
exports.extractEventDomainDefinition = exports.buildEventLogSnapshot = exports.inferProtocolConfig = exports.extractApigwDeploymentDefinition = exports.extractApigwApiDefinition = exports.extractApigwGroupDefinition = exports.triggerToApigwApiConfig = exports.generateApiKey = exports.eventToApigwGroupConfig = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const lang_1 = require("../../lang");
|
|
6
6
|
const ownershipTag_1 = require("../ownershipTag");
|
|
@@ -202,6 +202,24 @@ const getDomainCdnConfig = (domain) => {
|
|
|
202
202
|
: {}),
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Snapshot of the event-level access-log wiring (issue #214): the app-scoped
|
|
207
|
+
* shared SLS project plus the service-scoped gateway logstore. Omitted when the
|
|
208
|
+
* event does not opt into logging so existing state definitions stay identical.
|
|
209
|
+
*/
|
|
210
|
+
const buildEventLogSnapshot = (event, context) => {
|
|
211
|
+
if (!event.log) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
logEnabled: event.log === true || event.log === 'true',
|
|
216
|
+
logConfig: {
|
|
217
|
+
project: `${context.app}-${context.stage}-sls`,
|
|
218
|
+
logstore: `${context.service}-${context.stage}-apigw-logs`,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
exports.buildEventLogSnapshot = buildEventLogSnapshot;
|
|
205
223
|
const extractEventDomainDefinition = (domain) => {
|
|
206
224
|
if (!domain) {
|
|
207
225
|
return null;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.destroyAliyunStack = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
|
+
const stateManager_1 = require("../../common/stateManager");
|
|
6
|
+
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
7
|
const lang_1 = require("../../lang");
|
|
6
8
|
const fc3Planner_1 = require("./fc3Planner");
|
|
7
9
|
const fc3Executor_1 = require("./fc3Executor");
|
|
@@ -13,6 +15,7 @@ const tablestorePlanner_1 = require("./tablestorePlanner");
|
|
|
13
15
|
const tablestoreExecutor_1 = require("./tablestoreExecutor");
|
|
14
16
|
const apigwPlanner_1 = require("./apigwPlanner");
|
|
15
17
|
const apigwExecutor_1 = require("./apigwExecutor");
|
|
18
|
+
const sharedLogProject_1 = require("./sharedLogProject");
|
|
16
19
|
const createSaveStateFn = (backend, app, service, stage) => async (state) => {
|
|
17
20
|
await backend.saveState(state, app, service, stage);
|
|
18
21
|
};
|
|
@@ -117,6 +120,28 @@ const destroyAliyunStack = async (backend) => {
|
|
|
117
120
|
],
|
|
118
121
|
});
|
|
119
122
|
}
|
|
123
|
+
// Release the shared SLS project once nothing references it anymore. The
|
|
124
|
+
// per-resource teardowns above deleted their own logstores; the shared
|
|
125
|
+
// project is retained while the regional PROVIDER gateway log config (or a
|
|
126
|
+
// retained ALIYUN_APIGW_LOG_CONFIG instance) still points at it.
|
|
127
|
+
const shared = (0, stateManager_1.getSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY);
|
|
128
|
+
if (shared) {
|
|
129
|
+
const sharedName = (0, sharedLogProject_1.resolveSharedProjectName)(shared);
|
|
130
|
+
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
131
|
+
const gatewayConfig = await client.apigw.describeGatewayLogConfig();
|
|
132
|
+
const retainedByGateway = Boolean(sharedName && gatewayConfig?.slsProject === sharedName);
|
|
133
|
+
const retainedByApigwState = Object.values(state.resources ?? {}).some((resourceState) => resourceState.instances?.some((instance) => instance.type === 'ALIYUN_APIGW_LOG_CONFIG' &&
|
|
134
|
+
instance.attributes?.slsProject === sharedName));
|
|
135
|
+
if (retainedByGateway || retainedByApigwState) {
|
|
136
|
+
common_1.logger.info(lang_1.lang.__('SHARED_SLS_PROJECT_IN_USE', { projectName: sharedName ?? '', count: '1' }));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const releaseResult = await (0, sharedLogProject_1.releaseSharedSlsProjectIfUnused)(context, client, shared);
|
|
140
|
+
if (releaseResult === 'deleted') {
|
|
141
|
+
state = (0, stateManager_1.removeSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
120
145
|
await backend.saveState(state, context.app, context.service, context.stage);
|
|
121
146
|
};
|
|
122
147
|
exports.destroyAliyunStack = destroyAliyunStack;
|
|
@@ -15,6 +15,7 @@ const logger_1 = require("../../common/logger");
|
|
|
15
15
|
const lang_1 = require("../../lang");
|
|
16
16
|
const ownershipTag_1 = require("../ownershipTag");
|
|
17
17
|
const alreadyExists_1 = require("../alreadyExists");
|
|
18
|
+
const sharedLogProject_1 = require("./sharedLogProject");
|
|
18
19
|
const RECOVERY_GET_FUNCTION_DELAY_MS = 1500;
|
|
19
20
|
const delay = async (ms) => {
|
|
20
21
|
await new Promise((resolve) => {
|
|
@@ -144,10 +145,11 @@ const buildHttpTriggerConfig = (trigger) => {
|
|
|
144
145
|
...(disableURLInternet !== undefined ? { disableURLInternet } : {}),
|
|
145
146
|
};
|
|
146
147
|
};
|
|
147
|
-
const createDependentResources = async (context, fn, serviceName, existingInstances = []) => {
|
|
148
|
+
const createDependentResources = async (context, fn, serviceName, existingInstances = [], state) => {
|
|
148
149
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
149
150
|
const instances = [];
|
|
150
151
|
let logConfig;
|
|
152
|
+
let sharedProject;
|
|
151
153
|
let securityGroup;
|
|
152
154
|
let nasConfig;
|
|
153
155
|
const hasSlsProject = existingInstances.some((i) => i.type === 'ALIYUN_SLS_PROJECT');
|
|
@@ -165,29 +167,20 @@ const createDependentResources = async (context, fn, serviceName, existingInstan
|
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
else {
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_PROJECT', { projectName }));
|
|
171
|
-
const project = await client.sls.createProject(projectName);
|
|
172
|
-
instances.push({ type: 'ALIYUN_SLS_PROJECT', id: projectName, attributes: { ...project } });
|
|
173
|
-
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_LOGSTORE', { logstoreName }));
|
|
174
|
-
const logstore = await client.sls.createLogstore(projectName, logstoreName);
|
|
170
|
+
const shared = await (0, sharedLogProject_1.ensureSharedSlsProject)(context, client, state);
|
|
171
|
+
const logstore = await (0, sharedLogProject_1.ensureFunctionLogstore)(context, client, shared.projectName);
|
|
175
172
|
instances.push({
|
|
176
173
|
type: 'ALIYUN_SLS_LOGSTORE',
|
|
177
|
-
id: `${projectName}/${logstoreName}`,
|
|
178
|
-
attributes: {
|
|
174
|
+
id: `${shared.projectName}/${logstore.logstoreName}`,
|
|
175
|
+
attributes: { logstoreName: logstore.logstoreName },
|
|
179
176
|
});
|
|
180
|
-
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_INDEX', { logstoreName }));
|
|
181
|
-
const index = await client.sls.createIndex(projectName, logstoreName);
|
|
182
177
|
instances.push({
|
|
183
178
|
type: 'ALIYUN_SLS_INDEX',
|
|
184
|
-
id: `${projectName}/${logstoreName}/index`,
|
|
185
|
-
attributes: {
|
|
179
|
+
id: `${shared.projectName}/${logstore.logstoreName}/index`,
|
|
180
|
+
attributes: { projectName: shared.projectName, logstoreName: logstore.logstoreName },
|
|
186
181
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
await client.sls.waitForLogstore(projectName, logstoreName);
|
|
190
|
-
logConfig = { project: projectName, logstore: logstoreName };
|
|
182
|
+
logConfig = { project: shared.projectName, logstore: logstore.logstoreName };
|
|
183
|
+
sharedProject = (0, sharedLogProject_1.buildSharedProjectResourceState)(context, shared);
|
|
191
184
|
}
|
|
192
185
|
}
|
|
193
186
|
const iamConfig = fn.iam?.role;
|
|
@@ -319,6 +312,7 @@ const createDependentResources = async (context, fn, serviceName, existingInstan
|
|
|
319
312
|
role,
|
|
320
313
|
securityGroup,
|
|
321
314
|
nasConfig,
|
|
315
|
+
sharedProject,
|
|
322
316
|
instances,
|
|
323
317
|
};
|
|
324
318
|
};
|
|
@@ -366,8 +360,9 @@ const deleteDependentResources = async (context, instances) => {
|
|
|
366
360
|
break;
|
|
367
361
|
}
|
|
368
362
|
case 'ALIYUN_SLS_PROJECT':
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
// Shared/legacy SLS projects are never deleted at resource level — the
|
|
364
|
+
// destroyer releases the shared project once unused (legacy orphans are
|
|
365
|
+
// manual cleanup, see issue #214).
|
|
371
366
|
break;
|
|
372
367
|
case 'ALIYUN_FC3_HTTP_TRIGGER':
|
|
373
368
|
// HTTP trigger deletion requires functionName which is not available here.
|
|
@@ -389,7 +384,10 @@ const createResource = async (context, fn, state) => {
|
|
|
389
384
|
const logicalId = `functions.${fn.key}`;
|
|
390
385
|
const existingResourceState = (0, common_1.getResource)(state, logicalId);
|
|
391
386
|
const existingDependentInstances = (existingResourceState?.instances ?? []).filter((i) => i.type !== 'ALIYUN_FC3_FUNCTION');
|
|
392
|
-
const dependentResources = await createDependentResources(context, fn, serviceName, existingDependentInstances);
|
|
387
|
+
const dependentResources = await createDependentResources(context, fn, serviceName, existingDependentInstances, state);
|
|
388
|
+
const stateWithSharedProject = dependentResources.sharedProject
|
|
389
|
+
? (0, common_1.setSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY, dependentResources.sharedProject)
|
|
390
|
+
: state;
|
|
393
391
|
let config = (0, fc3Types_1.functionToFc3Config)(fn);
|
|
394
392
|
config = {
|
|
395
393
|
...config,
|
|
@@ -456,7 +454,7 @@ const createResource = async (context, fn, state) => {
|
|
|
456
454
|
lastUpdated: new Date().toISOString(),
|
|
457
455
|
status: 'tainted',
|
|
458
456
|
};
|
|
459
|
-
const stateAfterDependents = (0, common_1.setResource)(
|
|
457
|
+
const stateAfterDependents = (0, common_1.setResource)(stateWithSharedProject, logicalId, taintedResourceState);
|
|
460
458
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
461
459
|
const isTainted = existingResourceState?.status === 'tainted';
|
|
462
460
|
const existingFunctionOnRetry = isTainted ? await client.fc3.getFunction(fn.name) : null;
|
|
@@ -591,27 +589,47 @@ const updateResource = async (context, fn, state) => {
|
|
|
591
589
|
const logicalId = `functions.${fn.key}`;
|
|
592
590
|
const existingState = (0, common_1.getResource)(state, logicalId);
|
|
593
591
|
const existingInstances = (existingState?.instances ?? []);
|
|
594
|
-
const hasSlsResources = existingInstances.some((i) => i.type === 'ALIYUN_SLS_PROJECT'
|
|
592
|
+
const hasSlsResources = existingInstances.some((i) => i.type === 'ALIYUN_SLS_PROJECT' ||
|
|
593
|
+
i.type === 'ALIYUN_SLS_LOGSTORE' ||
|
|
594
|
+
i.type === 'ALIYUN_SLS_INDEX');
|
|
595
595
|
const hasRamRole = existingInstances.some((i) => i.type === 'ALIYUN_RAM_ROLE');
|
|
596
596
|
const hasSecurityGroup = existingInstances.some((i) => i.type === 'ALIYUN_ECS_SECURITY_GROUP');
|
|
597
597
|
const hasNasResources = existingInstances.some((i) => i.type === 'ALIYUN_NAS_FILE_SYSTEM');
|
|
598
598
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
599
599
|
const newDependentInstances = [];
|
|
600
600
|
let logConfig;
|
|
601
|
+
let sharedProjectState;
|
|
601
602
|
let role;
|
|
602
603
|
let securityGroup;
|
|
603
604
|
let nasConfig;
|
|
605
|
+
// SLS dependent-instance types to drop from the resulting state when
|
|
606
|
+
// function logging is disabled (true -> false).
|
|
607
|
+
const droppedSlsDependentTypes = [];
|
|
608
|
+
// Set when the shared project is released (deleted or gone) so its stale
|
|
609
|
+
// shared-state entry is removed from the returned state.
|
|
610
|
+
let releasedSharedProject = false;
|
|
604
611
|
if (fn.log && !hasSlsResources) {
|
|
605
|
-
const deps = await createDependentResources(context, { ...fn, network: undefined, storage: { ...fn.storage, nas: undefined } }, serviceName);
|
|
612
|
+
const deps = await createDependentResources(context, { ...fn, network: undefined, storage: { ...fn.storage, nas: undefined } }, serviceName, undefined, state);
|
|
606
613
|
logConfig = deps.logConfig;
|
|
607
614
|
newDependentInstances.push(...deps.instances.filter((i) => i.type.startsWith('ALIYUN_SLS_')));
|
|
615
|
+
if (deps.sharedProject) {
|
|
616
|
+
sharedProjectState = deps.sharedProject;
|
|
617
|
+
}
|
|
608
618
|
}
|
|
609
619
|
else if (hasSlsResources) {
|
|
610
|
-
const slsProjectInstance = existingInstances.find((i) => i.type === 'ALIYUN_SLS_PROJECT');
|
|
611
620
|
const slsLogstoreInstance = existingInstances.find((i) => i.type === 'ALIYUN_SLS_LOGSTORE');
|
|
612
|
-
if (
|
|
613
|
-
|
|
614
|
-
|
|
621
|
+
if (fn.log) {
|
|
622
|
+
if (slsLogstoreInstance) {
|
|
623
|
+
const [projectName, logstoreName] = slsLogstoreInstance.id.split('/');
|
|
624
|
+
logConfig = { project: projectName, logstore: logstoreName };
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
// Logging disabled: the owned index + logstore are deleted from the
|
|
629
|
+
// provider after the function log config is cleared, and the SLS
|
|
630
|
+
// instances are dropped from state. The shared project is released by
|
|
631
|
+
// the destroyer once no logstores remain (issue #214).
|
|
632
|
+
droppedSlsDependentTypes.push('ALIYUN_SLS_INDEX', 'ALIYUN_SLS_LOGSTORE', 'ALIYUN_SLS_PROJECT');
|
|
615
633
|
}
|
|
616
634
|
}
|
|
617
635
|
const newIamRole = fn.iam?.role;
|
|
@@ -620,7 +638,7 @@ const updateResource = async (context, fn, state) => {
|
|
|
620
638
|
role = { roleName: '', arn: newIamRole };
|
|
621
639
|
}
|
|
622
640
|
else if (!hasRamRole) {
|
|
623
|
-
const deps = await createDependentResources(context, { ...fn, log: false, network: undefined, storage: { ...fn.storage, nas: undefined } }, serviceName);
|
|
641
|
+
const deps = await createDependentResources(context, { ...fn, log: false, network: undefined, storage: { ...fn.storage, nas: undefined } }, serviceName, undefined, state);
|
|
624
642
|
role = deps.role;
|
|
625
643
|
newDependentInstances.push(...deps.instances.filter((i) => i.type === 'ALIYUN_RAM_ROLE'));
|
|
626
644
|
}
|
|
@@ -660,7 +678,7 @@ const updateResource = async (context, fn, state) => {
|
|
|
660
678
|
}
|
|
661
679
|
}
|
|
662
680
|
if (fn.network && !hasSecurityGroup) {
|
|
663
|
-
const deps = await createDependentResources(context, { ...fn, log: false, storage: { ...fn.storage, nas: undefined } }, serviceName);
|
|
681
|
+
const deps = await createDependentResources(context, { ...fn, log: false, storage: { ...fn.storage, nas: undefined } }, serviceName, undefined, state);
|
|
664
682
|
securityGroup = deps.securityGroup;
|
|
665
683
|
newDependentInstances.push(...deps.instances.filter((i) => i.type === 'ALIYUN_ECS_SECURITY_GROUP'));
|
|
666
684
|
}
|
|
@@ -671,7 +689,7 @@ const updateResource = async (context, fn, state) => {
|
|
|
671
689
|
}
|
|
672
690
|
}
|
|
673
691
|
if (fn.storage?.nas && fn.storage.nas.length > 0 && fn.network && !hasNasResources) {
|
|
674
|
-
const deps = await createDependentResources(context, { ...fn, log: false }, serviceName);
|
|
692
|
+
const deps = await createDependentResources(context, { ...fn, log: false }, serviceName, undefined, state);
|
|
675
693
|
nasConfig = deps.nasConfig;
|
|
676
694
|
newDependentInstances.push(...deps.instances.filter((i) => i.type.startsWith('ALIYUN_NAS_')));
|
|
677
695
|
}
|
|
@@ -741,6 +759,36 @@ const updateResource = async (context, fn, state) => {
|
|
|
741
759
|
const ossCode = await ensureOssCodeUpload(client, codePath, context.region, fn.name);
|
|
742
760
|
await client.fc3.updateFunctionCode(fn.name, codePath, ossCode);
|
|
743
761
|
}
|
|
762
|
+
if (droppedSlsDependentTypes.length > 0) {
|
|
763
|
+
const slsLogstoreInstance = existingInstances.find((i) => i.type === 'ALIYUN_SLS_LOGSTORE');
|
|
764
|
+
if (slsLogstoreInstance) {
|
|
765
|
+
const [projectName, logstoreName] = slsLogstoreInstance.id.split('/');
|
|
766
|
+
logger_1.logger.info(lang_1.lang.__('DELETING_SLS_INDEX', { id: `${projectName}/${logstoreName}` }));
|
|
767
|
+
try {
|
|
768
|
+
await client.sls.deleteIndex(projectName, logstoreName);
|
|
769
|
+
}
|
|
770
|
+
catch {
|
|
771
|
+
// index already gone — best-effort
|
|
772
|
+
}
|
|
773
|
+
logger_1.logger.info(lang_1.lang.__('DELETING_SLS_LOGSTORE', { id: `${projectName}/${logstoreName}` }));
|
|
774
|
+
try {
|
|
775
|
+
await client.sls.deleteLogstore(projectName, logstoreName);
|
|
776
|
+
}
|
|
777
|
+
catch {
|
|
778
|
+
// logstore already gone — best-effort
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
// Release the shared project once no logstores remain in the provider; it
|
|
782
|
+
// is retained (with its state entry) while another service or the gateway
|
|
783
|
+
// still references it.
|
|
784
|
+
const shared = (0, common_1.getSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY);
|
|
785
|
+
if (shared) {
|
|
786
|
+
const releaseResult = await (0, sharedLogProject_1.releaseSharedSlsProjectIfUnused)(context, client, shared);
|
|
787
|
+
if (releaseResult !== 'retained') {
|
|
788
|
+
releasedSharedProject = true;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
744
792
|
if (!configChanged && !codeChanged) {
|
|
745
793
|
logger_1.logger.warn(lang_1.lang.__('UPDATING_RESOURCE_WITH_NO_CHANGES', { resourceType: 'function', name: fn.name }));
|
|
746
794
|
}
|
|
@@ -881,6 +929,7 @@ const updateResource = async (context, fn, state) => {
|
|
|
881
929
|
.filter((i) => i.type !== 'ALIYUN_FC3_HTTP_TRIGGER')
|
|
882
930
|
.filter((i) => i.type !== 'ALIYUN_FC3_CUSTOM_DOMAIN')
|
|
883
931
|
.filter((i) => !(typeof fn.iam?.role === 'string' && i.type === 'ALIYUN_RAM_ROLE'))
|
|
932
|
+
.filter((i) => !droppedSlsDependentTypes.includes(i.type))
|
|
884
933
|
.map((i) => {
|
|
885
934
|
const { sid: existingSid, id: existingId, ...rest } = i;
|
|
886
935
|
return {
|
|
@@ -911,7 +960,17 @@ const updateResource = async (context, fn, state) => {
|
|
|
911
960
|
],
|
|
912
961
|
lastUpdated: new Date().toISOString(),
|
|
913
962
|
};
|
|
914
|
-
|
|
963
|
+
let finalState;
|
|
964
|
+
if (sharedProjectState) {
|
|
965
|
+
finalState = (0, common_1.setSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY, sharedProjectState);
|
|
966
|
+
}
|
|
967
|
+
else if (releasedSharedProject) {
|
|
968
|
+
finalState = (0, common_1.removeSharedResource)(state, context.stage, sharedLogProject_1.SHARED_LOG_PROJECT_KEY);
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
finalState = state;
|
|
972
|
+
}
|
|
973
|
+
return (0, common_1.setResource)(finalState, logicalId, resourceState);
|
|
915
974
|
};
|
|
916
975
|
exports.updateResource = updateResource;
|
|
917
976
|
const deleteResource = async (context, functionName, logicalId, state) => {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureGatewayLogstore = exports.ensureFunctionLogstore = exports.releaseSharedSlsProjectIfUnused = exports.isSharedProjectOwnedByApp = exports.adoptSharedSlsProjectState = exports.buildSharedProjectResourceState = exports.ensureSharedSlsProject = exports.resolveSharedProjectName = exports.buildSharedProjectName = exports.SHARED_LOG_PROJECT_KEY = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const logger_1 = require("../../common/logger");
|
|
6
|
+
const lang_1 = require("../../lang");
|
|
7
|
+
const ownershipTag_1 = require("../ownershipTag");
|
|
8
|
+
/**
|
|
9
|
+
* Issue #214: one shared SLS project per app×stage, tracked in the stage-level
|
|
10
|
+
* `shared` slot under the provider-neutral key 'logs.project'. Function and
|
|
11
|
+
* gateway logstores stay nested under their owning resource inside the shared
|
|
12
|
+
* project; the shared project is released by the destroyer once the provider
|
|
13
|
+
* reports zero remaining logstores.
|
|
14
|
+
*/
|
|
15
|
+
exports.SHARED_LOG_PROJECT_KEY = 'logs.project';
|
|
16
|
+
const buildSharedProjectName = (app, stage) => `${app}-${stage}-sls`;
|
|
17
|
+
exports.buildSharedProjectName = buildSharedProjectName;
|
|
18
|
+
const resolveSharedProjectName = (shared) => {
|
|
19
|
+
const instanceId = shared.instances?.[0]?.id;
|
|
20
|
+
return instanceId ?? shared.definition?.projectName;
|
|
21
|
+
};
|
|
22
|
+
exports.resolveSharedProjectName = resolveSharedProjectName;
|
|
23
|
+
const ensureSharedSlsProject = async (context, client, state) => {
|
|
24
|
+
const shared = state
|
|
25
|
+
? (0, common_1.getSharedResource)(state, context.stage, exports.SHARED_LOG_PROJECT_KEY)
|
|
26
|
+
: undefined;
|
|
27
|
+
const existingName = shared ? (0, exports.resolveSharedProjectName)(shared) : undefined;
|
|
28
|
+
const projectName = existingName ?? (0, exports.buildSharedProjectName)(context.app, context.stage);
|
|
29
|
+
// A local shared-state entry is never trusted blindly: the provider must
|
|
30
|
+
// confirm the project exists and carries this app's shared ownership tag
|
|
31
|
+
// before it is reused. A foreign or untagged project is refused; a stale
|
|
32
|
+
// entry (project gone from provider) falls through to creation.
|
|
33
|
+
const existingProject = await client.sls.getProject(projectName);
|
|
34
|
+
if (existingProject) {
|
|
35
|
+
if (await (0, exports.isSharedProjectOwnedByApp)(context, client, projectName)) {
|
|
36
|
+
if (!existingName) {
|
|
37
|
+
logger_1.logger.info(lang_1.lang.__('SHARED_SLS_PROJECT_ADOPTED', { projectName }));
|
|
38
|
+
}
|
|
39
|
+
return { projectName };
|
|
40
|
+
}
|
|
41
|
+
throw new Error(lang_1.lang.__('SLS_PROJECT_FOREIGN_OWNED', { projectName }));
|
|
42
|
+
}
|
|
43
|
+
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_PROJECT', { projectName }));
|
|
44
|
+
await client.sls.createProject(projectName);
|
|
45
|
+
await client.sls.addTags({
|
|
46
|
+
resourceType: 'project',
|
|
47
|
+
resourceId: projectName,
|
|
48
|
+
tags: [
|
|
49
|
+
{
|
|
50
|
+
key: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
51
|
+
value: (0, ownershipTag_1.buildSharedOwnershipTagValue)(context.app, exports.SHARED_LOG_PROJECT_KEY),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
return { projectName };
|
|
56
|
+
};
|
|
57
|
+
exports.ensureSharedSlsProject = ensureSharedSlsProject;
|
|
58
|
+
const buildSharedProjectResourceState = (context, result) => ({
|
|
59
|
+
mode: 'managed',
|
|
60
|
+
region: context.region,
|
|
61
|
+
definition: {
|
|
62
|
+
projectName: result.projectName,
|
|
63
|
+
region: context.region,
|
|
64
|
+
stage: context.stage,
|
|
65
|
+
},
|
|
66
|
+
instances: [
|
|
67
|
+
{
|
|
68
|
+
sid: (0, common_1.buildSid)('aliyun', 'sls_project', context.stage, result.projectName),
|
|
69
|
+
type: 'ALIYUN_SLS_PROJECT',
|
|
70
|
+
id: result.projectName,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
lastUpdated: new Date().toISOString(),
|
|
74
|
+
});
|
|
75
|
+
exports.buildSharedProjectResourceState = buildSharedProjectResourceState;
|
|
76
|
+
const adoptSharedSlsProjectState = (context, projectName) => (0, exports.buildSharedProjectResourceState)(context, { projectName });
|
|
77
|
+
exports.adoptSharedSlsProjectState = adoptSharedSlsProjectState;
|
|
78
|
+
/**
|
|
79
|
+
* Exact app-scope ownership check for an SLS project. The caller must verify
|
|
80
|
+
* the project exists (getProject) before reading its tags; a foreign or
|
|
81
|
+
* untagged project is never adopted (issue #214).
|
|
82
|
+
*/
|
|
83
|
+
const isSharedProjectOwnedByApp = async (context, client, projectName) => {
|
|
84
|
+
const tags = await client.sls.getProjectTags(projectName);
|
|
85
|
+
return (0, ownershipTag_1.isOwnedByApp)(context.app, exports.SHARED_LOG_PROJECT_KEY, tags.map((t) => ({ Key: t.key, Value: t.value })));
|
|
86
|
+
};
|
|
87
|
+
exports.isSharedProjectOwnedByApp = isSharedProjectOwnedByApp;
|
|
88
|
+
const releaseSharedSlsProjectIfUnused = async (context, client, shared) => {
|
|
89
|
+
if (!shared) {
|
|
90
|
+
return 'absent';
|
|
91
|
+
}
|
|
92
|
+
const projectName = (0, exports.resolveSharedProjectName)(shared);
|
|
93
|
+
if (!projectName) {
|
|
94
|
+
return 'absent';
|
|
95
|
+
}
|
|
96
|
+
const project = await client.sls.getProject(projectName);
|
|
97
|
+
if (!project) {
|
|
98
|
+
return 'absent';
|
|
99
|
+
}
|
|
100
|
+
// Only ever delete a project we own. A foreign or untagged project is
|
|
101
|
+
// retained — the tracked entry may be stale and must not be torn down.
|
|
102
|
+
if (!(await (0, exports.isSharedProjectOwnedByApp)(context, client, projectName))) {
|
|
103
|
+
return 'retained';
|
|
104
|
+
}
|
|
105
|
+
const logstores = await client.sls.listLogStores(projectName);
|
|
106
|
+
if (logstores.length > 0) {
|
|
107
|
+
logger_1.logger.info(lang_1.lang.__('SHARED_SLS_PROJECT_IN_USE', {
|
|
108
|
+
projectName,
|
|
109
|
+
count: String(logstores.length),
|
|
110
|
+
}));
|
|
111
|
+
return 'retained';
|
|
112
|
+
}
|
|
113
|
+
await client.sls.deleteProject(projectName);
|
|
114
|
+
return 'deleted';
|
|
115
|
+
};
|
|
116
|
+
exports.releaseSharedSlsProjectIfUnused = releaseSharedSlsProjectIfUnused;
|
|
117
|
+
const ensureLogstoreInSharedProject = async (context, client, projectName, logstoreName) => {
|
|
118
|
+
const existing = await client.sls.getLogstore(projectName, logstoreName);
|
|
119
|
+
if (existing) {
|
|
120
|
+
return { logstoreName };
|
|
121
|
+
}
|
|
122
|
+
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_LOGSTORE', { logstoreName }));
|
|
123
|
+
await client.sls.createLogstore(projectName, logstoreName);
|
|
124
|
+
logger_1.logger.info(lang_1.lang.__('CREATING_SLS_INDEX', { logstoreName }));
|
|
125
|
+
await client.sls.createIndex(projectName, logstoreName);
|
|
126
|
+
logger_1.logger.info(lang_1.lang.__('SLS_LOGSTORE_WAITING', { project: projectName, logstore: logstoreName }));
|
|
127
|
+
await client.sls.waitForLogstore(projectName, logstoreName);
|
|
128
|
+
return { logstoreName };
|
|
129
|
+
};
|
|
130
|
+
const ensureFunctionLogstore = async (context, client, projectName) => {
|
|
131
|
+
return ensureLogstoreInSharedProject(context, client, projectName, `${context.service}-${context.stage}-fn-logs`);
|
|
132
|
+
};
|
|
133
|
+
exports.ensureFunctionLogstore = ensureFunctionLogstore;
|
|
134
|
+
const ensureGatewayLogstore = async (context, client, projectName) => {
|
|
135
|
+
return ensureLogstoreInSharedProject(context, client, projectName, `${context.service}-${context.stage}-apigw-logs`);
|
|
136
|
+
};
|
|
137
|
+
exports.ensureGatewayLogstore = ensureGatewayLogstore;
|