@geek-fun/serverlessinsight 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +123 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +93 -0
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +148 -0
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/CHANGELOG.md +29 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/deploy.js +3 -1
- package/dist/src/commands/index.js +25 -0
- package/dist/src/common/aliyunClient/fc3Operations.js +5 -0
- package/dist/src/common/nameBuilder.js +13 -1
- package/dist/src/common/planCompare.js +31 -1
- package/dist/src/common/planFormatter.js +69 -54
- package/dist/src/common/refreshPlanner.js +31 -8
- package/dist/src/lang/en.js +20 -6
- package/dist/src/lang/zh-CN.js +20 -6
- package/dist/src/stack/aliyunStack/apigwPlanner.js +26 -5
- package/dist/src/stack/aliyunStack/databasePlanner.js +6 -1
- package/dist/src/stack/aliyunStack/databaseResource.js +10 -2
- package/dist/src/stack/aliyunStack/deployer.js +30 -13
- package/dist/src/stack/aliyunStack/fc3Planner.js +46 -25
- package/dist/src/stack/aliyunStack/fc3Resource.js +49 -20
- package/dist/src/stack/aliyunStack/ossPlanner.js +6 -1
- package/dist/src/stack/aliyunStack/ossResource.js +9 -2
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +2 -1
- package/dist/src/stack/aliyunStack/tablestoreResource.js +2 -1
- package/dist/src/stack/deploy.js +10 -4
- package/dist/src/stack/scfStack/cosPlanner.js +6 -1
- package/dist/src/stack/scfStack/cosResource.js +6 -2
- package/dist/src/stack/scfStack/deployer.js +21 -6
- package/dist/src/stack/scfStack/esServerlessPlanner.js +6 -1
- package/dist/src/stack/scfStack/esServerlessResource.js +5 -1
- package/dist/src/stack/scfStack/scfPlanner.js +26 -27
- package/dist/src/stack/scfStack/scfResource.js +6 -2
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +6 -1
- package/dist/src/stack/scfStack/tdsqlcResource.js +5 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +15 -4
- package/dist/src/stack/volcengineStack/tosPlanner.js +6 -1
- package/dist/src/stack/volcengineStack/tosResource.js +10 -3
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +39 -11
- package/dist/src/stack/volcengineStack/vefaasResource.js +5 -1
- package/dist/src/validator/semanticValidation.js +24 -0
- package/package.json +1 -1
|
@@ -43,46 +43,45 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
43
43
|
const desiredCodeHash = await (0, hashUtils_1.computeZipContentHash)(codePath);
|
|
44
44
|
const desiredDefinition = (0, scfTypes_1.extractScfDefinition)(config, desiredCodeHash, fn.iam);
|
|
45
45
|
const client = (0, tencentClient_1.createTencentClient)(context);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
currentState
|
|
50
|
-
|
|
51
|
-
context.
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
return (0, refreshPlanner_1.planRefreshedResource)({
|
|
47
|
+
logicalId,
|
|
48
|
+
resourceType: 'SCF',
|
|
49
|
+
currentState,
|
|
50
|
+
desiredDefinition,
|
|
51
|
+
read: () => (0, refreshCache_1.cachedRefreshRead)(context, `scf.getFunction:${fn.name}`, () => client.scf.getFunction(fn.name)),
|
|
52
|
+
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, remote.Tags),
|
|
53
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
54
|
+
resourceType: 'Function',
|
|
55
|
+
resourceName: fn.name,
|
|
56
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
57
|
+
})),
|
|
58
|
+
extraUpdate: async () => {
|
|
59
|
+
// Issue #234 M3: nested topic drift — probed only when logging is
|
|
60
|
+
// declared; unresolvable/unreadable topics are not drift. Runs via
|
|
61
|
+
// the skeleton's extraUpdate hook (issue #246) so a topic-only
|
|
62
|
+
// drift gets the live→desired diff baseline too.
|
|
63
|
+
const topicInstance = currentState?.instances?.find((i) => i.type === 'TENCENT_CLS_TOPIC');
|
|
64
|
+
if (!fn.log || !topicInstance?.id) {
|
|
65
|
+
return { update: false, drifted: false };
|
|
66
|
+
}
|
|
54
67
|
const topicId = topicInstance.id;
|
|
55
68
|
try {
|
|
56
69
|
const liveTopic = await (0, refreshCache_1.cachedRefreshRead)(context, `cls.getTopicById:${topicId}`, () => client.cls.getTopicById(topicId));
|
|
57
70
|
const topicDrifted = !liveTopic ||
|
|
58
71
|
liveTopic.StorageType !== clsOperations_1.CLS_TOPIC_STORAGE_TYPE ||
|
|
59
72
|
liveTopic.Period !== clsOperations_1.CLS_TOPIC_PERIOD;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
action: 'update',
|
|
64
|
-
resourceType: 'SCF',
|
|
65
|
-
changes: { before: currentState.definition || {}, after: desiredDefinition },
|
|
66
|
-
drifted: true,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
73
|
+
return topicDrifted
|
|
74
|
+
? { update: true, drifted: true, reason: 'PLAN_DRIFT_CLS_TOPIC' }
|
|
75
|
+
: { update: false, drifted: false };
|
|
69
76
|
}
|
|
70
77
|
catch (error) {
|
|
71
78
|
logger_1.logger.warn(lang_1.lang.__('PLAN_FUNCTION_NESTED_PROBE_FAILED', {
|
|
72
79
|
functionName: fn.name,
|
|
73
80
|
error: String(error),
|
|
74
81
|
}));
|
|
82
|
+
return { update: false, drifted: false };
|
|
75
83
|
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return (0, refreshPlanner_1.planRefreshedResource)({
|
|
79
|
-
logicalId,
|
|
80
|
-
resourceType: 'SCF',
|
|
81
|
-
currentState,
|
|
82
|
-
desiredDefinition,
|
|
83
|
-
read: () => (0, refreshCache_1.cachedRefreshRead)(context, `scf.getFunction:${fn.name}`, () => client.scf.getFunction(fn.name)),
|
|
84
|
-
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, remote.Tags),
|
|
85
|
-
foreignError: () => new Error(`Function ${fn.name} already exists in provider but is not owned by this stack (missing ${ownershipTag_1.OWNERSHIP_TAG_KEY} tag). Refusing to create — resolve manually.`),
|
|
84
|
+
},
|
|
86
85
|
cloudToDefinition: scfTypes_1.cloudScfToDefinition,
|
|
87
86
|
enrichRemoteAttributes: async (remote, attributes) => {
|
|
88
87
|
// Resolve cloud CLS ids back to the stable names the desired
|
|
@@ -508,7 +508,7 @@ const createResource = async (context, fn, state) => {
|
|
|
508
508
|
// triggers below.
|
|
509
509
|
let adoptedInfo = existingFunctionOnRetry;
|
|
510
510
|
if (existingFunctionOnRetry) {
|
|
511
|
-
logger_1.logger.info(
|
|
511
|
+
logger_1.logger.info(lang_1.lang.__('TAINTED_RECOVERY_SKIP_CREATE', { resourceType: 'Function', resourceName: fn.name }));
|
|
512
512
|
}
|
|
513
513
|
try {
|
|
514
514
|
if (!existingFunctionOnRetry) {
|
|
@@ -543,7 +543,11 @@ const createResource = async (context, fn, state) => {
|
|
|
543
543
|
logger_1.logger.info(`Function ${fn.name} exists and carries ownership tag (${ownershipTag_1.OWNERSHIP_TAG_KEY}), adopting idempotently`);
|
|
544
544
|
}
|
|
545
545
|
else {
|
|
546
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
546
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
547
|
+
resourceType: 'Function',
|
|
548
|
+
resourceName: fn.name,
|
|
549
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
550
|
+
})));
|
|
547
551
|
}
|
|
548
552
|
}
|
|
549
553
|
else {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDatabasePlan = void 0;
|
|
4
|
+
const lang_1 = require("../../lang");
|
|
4
5
|
const tencentClient_1 = require("../../common/tencentClient");
|
|
5
6
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
6
7
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -49,7 +50,11 @@ const generateDatabasePlan = async (context, state, databases) => {
|
|
|
49
50
|
? (0, refreshCache_1.cachedRefreshRead)(context, `tdsqlc.getCluster:${clusterId}`, () => client.tdsqlc.getCluster(clusterId))
|
|
50
51
|
: Promise.resolve(null),
|
|
51
52
|
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, (0, tdsqlcTypes_1.tdsqlcTagsToOwnershipTags)(remote.ResourceTags)),
|
|
52
|
-
foreignError: () => new Error(
|
|
53
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
54
|
+
resourceType: 'Cluster',
|
|
55
|
+
resourceName: database.name,
|
|
56
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
57
|
+
})),
|
|
53
58
|
cloudToDefinition: tdsqlcTypes_1.cloudTdsqlcToDefinition,
|
|
54
59
|
extraUpdate: async () => {
|
|
55
60
|
// AutoPause needs a dedicated read: DescribeClusters reports the
|
|
@@ -151,7 +151,11 @@ const createDatabaseResource = async (context, database, state) => {
|
|
|
151
151
|
clusterInfo = probe;
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
154
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
154
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
155
|
+
resourceType: 'Cluster',
|
|
156
|
+
resourceName: database.name,
|
|
157
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
158
|
+
})));
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
else {
|
|
@@ -42,7 +42,11 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
42
42
|
// is account-scoped, so only refuse when the NAMED one is foreign.
|
|
43
43
|
const remoteGateway = await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.findGatewayByName:${serviceName}:${context.stage}`, () => client.apigw.findGatewayByName((0, apigwTypes_1.buildGatewayName)(serviceName, context.stage)));
|
|
44
44
|
if (remoteGateway?.gatewayId && !(0, ownershipTag_1.isOwnedByStack)(context, logicalId, remoteGateway.tags)) {
|
|
45
|
-
throw new Error(
|
|
45
|
+
throw new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
46
|
+
resourceType: 'API Gateway',
|
|
47
|
+
resourceName: (0, apigwTypes_1.buildGatewayName)(serviceName, context.stage),
|
|
48
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
49
|
+
}));
|
|
46
50
|
}
|
|
47
51
|
return {
|
|
48
52
|
logicalId,
|
|
@@ -32,7 +32,12 @@ const formatApiError = (error) => {
|
|
|
32
32
|
}
|
|
33
33
|
return parts.join(' | ');
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
// Issue #246: when the approved plan is passed through, the executor runs
|
|
36
|
+
// exactly the displayed items — partitioned by resourceType, no re-probe.
|
|
37
|
+
const partitionPlan = (plan, types) => ({
|
|
38
|
+
items: plan.items.filter((item) => types.includes(item.resourceType)),
|
|
39
|
+
});
|
|
40
|
+
const deployVolcengineStack = async (iac, backend, approvedPlan) => {
|
|
36
41
|
const context = (0, common_1.getContext)();
|
|
37
42
|
common_1.logger.info(lang_1.lang.__('DEPLOYING_STACK'));
|
|
38
43
|
let state = await backend.loadState('volcengine', iac.app, iac.service, context.stage);
|
|
@@ -41,9 +46,15 @@ const deployVolcengineStack = async (iac, backend) => {
|
|
|
41
46
|
await backend.saveState(state, iac.app, iac.service, context.stage);
|
|
42
47
|
};
|
|
43
48
|
common_1.logger.info(lang_1.lang.__('GENERATING_PLAN'));
|
|
44
|
-
const functionPlan =
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
const functionPlan = approvedPlan
|
|
50
|
+
? partitionPlan(approvedPlan, ['VOLCENGINE_VEFAAS'])
|
|
51
|
+
: await (0, vefaasPlanner_1.generateFunctionPlan)(context, state, iac.functions);
|
|
52
|
+
const bucketPlan = approvedPlan
|
|
53
|
+
? partitionPlan(approvedPlan, ['VOLCENGINE_TOS_BUCKET'])
|
|
54
|
+
: await (0, tosPlanner_1.generateBucketPlan)(context, state, iac.buckets);
|
|
55
|
+
const apigwPlan = approvedPlan
|
|
56
|
+
? partitionPlan(approvedPlan, ['VOLCENGINE_APIGW'])
|
|
57
|
+
: await (0, apigwPlanner_1.generateApigwPlan)(context, state, iac.events, iac.service);
|
|
47
58
|
const bucketResult = await (0, tosExecutor_1.executeBucketPlan)(context, bucketPlan, iac.buckets, state, onStateChange);
|
|
48
59
|
if (bucketResult.partialFailure) {
|
|
49
60
|
const error = bucketResult.partialFailure.error;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateBucketPlan = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const lang_1 = require("../../lang");
|
|
8
9
|
const volcengineClient_1 = require("../../common/volcengineClient");
|
|
9
10
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
10
11
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -52,7 +53,11 @@ const generateBucketPlan = async (context, state, buckets) => {
|
|
|
52
53
|
desiredDefinition,
|
|
53
54
|
read: () => (0, refreshCache_1.cachedRefreshRead)(context, `tos.getBucket:${bucket.name}`, () => client.tos.getBucket(bucket.name)),
|
|
54
55
|
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, remote.Tags),
|
|
55
|
-
foreignError: () => new Error(
|
|
56
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
57
|
+
resourceType: 'Bucket',
|
|
58
|
+
resourceName: bucket.name,
|
|
59
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
60
|
+
})),
|
|
56
61
|
cloudToDefinition: tosTypes_1.cloudTosToDefinition,
|
|
57
62
|
extraUpdate: async () => {
|
|
58
63
|
// Policy needs a canonical compare: the cloud returns a parsed
|
|
@@ -64,7 +64,10 @@ const createResource = async (context, bucket, state) => {
|
|
|
64
64
|
const isTainted = existingResourceState?.status === 'tainted';
|
|
65
65
|
const existingBucketOnRetry = isTainted ? await client.tos.getBucket(bucket.name) : null;
|
|
66
66
|
if (existingBucketOnRetry) {
|
|
67
|
-
logger_1.logger.info(
|
|
67
|
+
logger_1.logger.info(lang_1.lang.__('TAINTED_RECOVERY_SKIP_CREATE', {
|
|
68
|
+
resourceType: 'Bucket',
|
|
69
|
+
resourceName: bucket.name,
|
|
70
|
+
}));
|
|
68
71
|
}
|
|
69
72
|
const taintedResourceState = {
|
|
70
73
|
mode: 'managed',
|
|
@@ -102,7 +105,7 @@ const createResource = async (context, bucket, state) => {
|
|
|
102
105
|
if (!(0, alreadyExists_1.isResourceAlreadyExistsError)(error, ['BucketAlreadyExists'])) {
|
|
103
106
|
throw error;
|
|
104
107
|
}
|
|
105
|
-
logger_1.logger.info(
|
|
108
|
+
logger_1.logger.info(lang_1.lang.__('OWNERSHIP_VERIFYING', { resourceType: 'Bucket', resourceName: bucket.name }));
|
|
106
109
|
}
|
|
107
110
|
// CreateBucket succeeding does NOT prove the bucket is ours: a pre-existing
|
|
108
111
|
// bucket is returned idempotently. Only a bucket carrying our ownership tag
|
|
@@ -113,7 +116,11 @@ const createResource = async (context, bucket, state) => {
|
|
|
113
116
|
throw new Error(`Failed to refresh state for bucket: ${bucket.name}`);
|
|
114
117
|
}
|
|
115
118
|
if (!(0, ownershipTag_1.isOwnedByStack)(context, logicalId, probe.Tags)) {
|
|
116
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
119
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
120
|
+
resourceType: 'Bucket',
|
|
121
|
+
resourceName: bucket.name,
|
|
122
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
123
|
+
})));
|
|
117
124
|
}
|
|
118
125
|
bucketInfo = probe;
|
|
119
126
|
}
|
|
@@ -5,6 +5,7 @@ const common_1 = require("../../common");
|
|
|
5
5
|
const stateManager_1 = require("../../common/stateManager");
|
|
6
6
|
const volcengineClient_1 = require("../../common/volcengineClient");
|
|
7
7
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
8
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
8
9
|
const concurrency_1 = require("../../common/concurrency");
|
|
9
10
|
const vefaasTypes_1 = require("./vefaasTypes");
|
|
10
11
|
const vefaasResource_1 = require("./vefaasResource");
|
|
@@ -89,7 +90,11 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
89
90
|
const client = (0, volcengineClient_1.createVolcengineClient)(context);
|
|
90
91
|
const remoteFunction = await (0, refreshCache_1.cachedRefreshRead)(context, `vefaas.getFunction:${fn.name}`, () => client.vefaas.getFunction(fn.name));
|
|
91
92
|
if (remoteFunction && !(0, ownershipTag_1.isOwnedByStack)(context, logicalId, remoteFunction.Tags)) {
|
|
92
|
-
throw new Error(
|
|
93
|
+
throw new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
94
|
+
resourceType: 'Function',
|
|
95
|
+
resourceName: fn.name,
|
|
96
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
97
|
+
}));
|
|
93
98
|
}
|
|
94
99
|
return {
|
|
95
100
|
logicalId,
|
|
@@ -131,6 +136,11 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
131
136
|
// function's actual attributes (runtime/handler/memory/timeout/env)
|
|
132
137
|
// against the desired definition. Console edits would otherwise go
|
|
133
138
|
// undetected — definitionChanged only sees local-vs-desired.
|
|
139
|
+
// One-directional desired-declared contract (issue #246 fix: this
|
|
140
|
+
// planner previously used a full two-directional equality, so
|
|
141
|
+
// cloud-only values within mapped keys phantom-drifted every plan).
|
|
142
|
+
// Mapper-emitted shapes are subset-normalized to the definition the
|
|
143
|
+
// config writes, so nested comparisons stay apples-to-apples.
|
|
134
144
|
// Not refreshable (issue #234 phase 2): the IAM custom policy document
|
|
135
145
|
// (volcengine IAM has no GetPolicy read) and dependent TLS topics
|
|
136
146
|
// (existence-only by design decision 5) stay covered by the executor's
|
|
@@ -140,25 +150,34 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
140
150
|
handler: remoteFunction.handler,
|
|
141
151
|
memorySize: remoteFunction.memoryMb,
|
|
142
152
|
timeout: remoteFunction.requestTimeout,
|
|
143
|
-
environment: remoteFunction.environmentVariables,
|
|
153
|
+
environment: remoteFunction.environmentVariables ?? {},
|
|
144
154
|
// Provider responses carry `null` for unset fields while the desired
|
|
145
155
|
// definition carries `undefined` — normalize null → undefined so the
|
|
146
156
|
// comparison ignores the representation difference.
|
|
147
157
|
description: remoteFunction.description ?? undefined,
|
|
148
158
|
role: remoteFunction.role ?? undefined,
|
|
149
|
-
vpcConfig: remoteFunction.vpcConfig
|
|
159
|
+
vpcConfig: remoteFunction.vpcConfig
|
|
160
|
+
? {
|
|
161
|
+
vpcId: remoteFunction.vpcConfig.vpcId ?? undefined,
|
|
162
|
+
subnetIds: remoteFunction.vpcConfig.subnetIds ?? [],
|
|
163
|
+
securityGroupIds: remoteFunction.vpcConfig.securityGroupIds ?? [],
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
150
166
|
logConfig: remoteFunction.logConfig
|
|
151
167
|
? { project: remoteFunction.logConfig.project, topic: remoteFunction.logConfig.topic }
|
|
152
168
|
: undefined,
|
|
153
169
|
};
|
|
154
|
-
const
|
|
155
|
-
|
|
170
|
+
const remoteDiffers = (0, planCompare_1.remoteDiffersFromDesired)(remoteAttributes, desiredDefinition);
|
|
171
|
+
const liveBefore = (0, planCompare_1.mergeLiveBefore)(currentDefinition, remoteAttributes);
|
|
172
|
+
const revertKeys = (0, planCompare_1.computeRevertKeys)(currentDefinition, remoteAttributes, desiredDefinition);
|
|
173
|
+
if (definitionChanged || remoteDiffers) {
|
|
156
174
|
return {
|
|
157
175
|
logicalId,
|
|
158
176
|
action: 'update',
|
|
159
177
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
160
|
-
changes: { before:
|
|
178
|
+
changes: { before: liveBefore, after: desiredDefinition },
|
|
161
179
|
drifted: true,
|
|
180
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
162
181
|
};
|
|
163
182
|
}
|
|
164
183
|
// Issue #234 phase 3: live role drift — trust policy and attached
|
|
@@ -175,8 +194,9 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
175
194
|
logicalId,
|
|
176
195
|
action: 'update',
|
|
177
196
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
178
|
-
changes: { before:
|
|
197
|
+
changes: { before: liveBefore, after: desiredDefinition },
|
|
179
198
|
drifted: true,
|
|
199
|
+
driftReasons: ['PLAN_DRIFT_ROLE_MISSING'],
|
|
180
200
|
};
|
|
181
201
|
}
|
|
182
202
|
let cloudTrust;
|
|
@@ -192,8 +212,9 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
192
212
|
logicalId,
|
|
193
213
|
action: 'update',
|
|
194
214
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
195
|
-
changes: { before:
|
|
215
|
+
changes: { before: liveBefore, after: desiredDefinition },
|
|
196
216
|
drifted: true,
|
|
217
|
+
driftReasons: ['PLAN_DRIFT_ROLE_POLICY'],
|
|
197
218
|
};
|
|
198
219
|
}
|
|
199
220
|
const desiredManaged = (fn.iam?.role?.managed_policies ?? []).map((arn) => arn.split('/').pop() ?? '');
|
|
@@ -205,8 +226,9 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
205
226
|
logicalId,
|
|
206
227
|
action: 'update',
|
|
207
228
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
208
|
-
changes: { before:
|
|
229
|
+
changes: { before: liveBefore, after: desiredDefinition },
|
|
209
230
|
drifted: true,
|
|
231
|
+
driftReasons: ['PLAN_DRIFT_ROLE_POLICY'],
|
|
210
232
|
};
|
|
211
233
|
}
|
|
212
234
|
}
|
|
@@ -233,8 +255,9 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
233
255
|
logicalId,
|
|
234
256
|
action: 'update',
|
|
235
257
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
236
|
-
changes: { before:
|
|
258
|
+
changes: { before: liveBefore, after: desiredDefinition },
|
|
237
259
|
drifted: true,
|
|
260
|
+
driftReasons: ['PLAN_DRIFT_TLS_TOPIC'],
|
|
238
261
|
};
|
|
239
262
|
}
|
|
240
263
|
}
|
|
@@ -249,7 +272,11 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
249
272
|
}
|
|
250
273
|
return { logicalId, action: 'noop', resourceType: 'VOLCENGINE_VEFAAS' };
|
|
251
274
|
}
|
|
252
|
-
catch {
|
|
275
|
+
catch (error) {
|
|
276
|
+
common_1.logger.warn(lang_1.lang.__('PLAN_LIVE_READ_FAILED', {
|
|
277
|
+
logicalId,
|
|
278
|
+
error: error instanceof Error ? error.message : String(error),
|
|
279
|
+
}));
|
|
253
280
|
return {
|
|
254
281
|
logicalId,
|
|
255
282
|
action: 'create',
|
|
@@ -258,6 +285,7 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
258
285
|
before: currentState.definition,
|
|
259
286
|
after: desiredDefinition,
|
|
260
287
|
},
|
|
288
|
+
drifted: true,
|
|
261
289
|
};
|
|
262
290
|
}
|
|
263
291
|
});
|
|
@@ -377,7 +377,11 @@ const createResource = async (context, fn, state) => {
|
|
|
377
377
|
logger_1.logger.info(`Function ${fn.name} exists and carries ownership tag (${ownershipTag_1.OWNERSHIP_TAG_KEY}), adopting idempotently`);
|
|
378
378
|
}
|
|
379
379
|
else {
|
|
380
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
380
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
381
|
+
resourceType: 'Function',
|
|
382
|
+
resourceName: fn.name,
|
|
383
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
384
|
+
})));
|
|
381
385
|
}
|
|
382
386
|
}
|
|
383
387
|
else {
|
|
@@ -29,6 +29,30 @@ const validateSemantics = (iacJson) => {
|
|
|
29
29
|
? fn.name
|
|
30
30
|
: undefined)
|
|
31
31
|
.filter((name) => name !== undefined));
|
|
32
|
+
Object.entries(functionDefinitions).forEach(([fnKey, rawFn]) => {
|
|
33
|
+
if (!rawFn || typeof rawFn !== 'object')
|
|
34
|
+
return;
|
|
35
|
+
const fn = rawFn;
|
|
36
|
+
const instancePath = `/functions/${fnKey}`;
|
|
37
|
+
if (fn.container && fn.code) {
|
|
38
|
+
errors.push({
|
|
39
|
+
instancePath,
|
|
40
|
+
schemaPath: '#/semantic/containerCodeConflict',
|
|
41
|
+
keyword: 'containerCodeConflict',
|
|
42
|
+
params: {},
|
|
43
|
+
message: lang_1.lang.__('SEMANTIC_CONTAINER_CODE_CONFLICT', { fnKey }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else if (!fn.container && !fn.code) {
|
|
47
|
+
errors.push({
|
|
48
|
+
instancePath,
|
|
49
|
+
schemaPath: '#/semantic/functionSourceRequired',
|
|
50
|
+
keyword: 'functionSourceRequired',
|
|
51
|
+
params: {},
|
|
52
|
+
message: lang_1.lang.__('SEMANTIC_FUNCTION_SOURCE_REQUIRED', { fnKey }),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
32
56
|
Object.entries(events).forEach(([eventKey, rawEvent]) => {
|
|
33
57
|
const triggers = Array.isArray(rawEvent.triggers)
|
|
34
58
|
? rawEvent.triggers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Full life cycle cross providers serverless application management for your fast-growing business.",
|
|
5
5
|
"homepage": "https://serverlessinsight.com",
|
|
6
6
|
"main": "dist/src/index.js",
|