@geek-fun/serverlessinsight 0.8.6 → 0.8.8
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 +94 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +47 -27
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +35 -73
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +148 -0
- package/AGENTS.md +29 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/deploy.js +1 -0
- package/dist/src/commands/index.js +6 -2
- package/dist/src/commands/plan.js +1 -0
- package/dist/src/common/aliyunClient/ecsOperations.js +70 -1
- package/dist/src/common/aliyunClient/nasOperations.js +21 -0
- package/dist/src/common/aliyunClient/ramOperations.js +116 -15
- package/dist/src/common/aliyunClient/slsOperations.js +16 -3
- package/dist/src/common/concurrency.js +30 -0
- package/dist/src/common/context.js +3 -0
- package/dist/src/common/dependencyGraph/graph.js +5 -0
- package/dist/src/common/iacHelper.js +3 -1
- package/dist/src/common/iamStatements.js +21 -1
- package/dist/src/common/index.js +5 -0
- package/dist/src/common/nameBuilder.js +12 -1
- package/dist/src/common/planCompare.js +62 -0
- package/dist/src/common/planFormatter.js +15 -3
- package/dist/src/common/refreshCache.js +32 -0
- package/dist/src/common/refreshPlanner.js +105 -0
- package/dist/src/common/tencentClient/camOperations.js +24 -12
- package/dist/src/common/tencentClient/clsOperations.js +27 -3
- package/dist/src/common/tencentClient/tdsqlcOperations.js +22 -0
- package/dist/src/common/throttleRetry.js +56 -0
- package/dist/src/common/volcengineClient/iamOperations.js +15 -11
- package/dist/src/common/volcengineClient/tlsOperations.js +12 -4
- package/dist/src/lang/en.js +23 -0
- package/dist/src/lang/zh-CN.js +22 -0
- package/dist/src/stack/aliyunStack/apigwExecutor.js +5 -5
- package/dist/src/stack/aliyunStack/apigwPlanner.js +75 -7
- package/dist/src/stack/aliyunStack/apigwResource.js +10 -8
- package/dist/src/stack/aliyunStack/apigwTypes.js +86 -5
- package/dist/src/stack/aliyunStack/databasePlanner.js +26 -62
- package/dist/src/stack/aliyunStack/deployer.js +33 -3
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +50 -1
- package/dist/src/stack/aliyunStack/fc3Executor.js +5 -3
- package/dist/src/stack/aliyunStack/fc3Planner.js +299 -12
- package/dist/src/stack/aliyunStack/fc3Resource.js +358 -34
- package/dist/src/stack/aliyunStack/fc3Types.js +61 -1
- package/dist/src/stack/aliyunStack/ossPlanner.js +21 -63
- package/dist/src/stack/aliyunStack/ossTypes.js +25 -1
- package/dist/src/stack/aliyunStack/rdsTypes.js +38 -1
- package/dist/src/stack/aliyunStack/sharedLogProject.js +22 -5
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +20 -74
- package/dist/src/stack/aliyunStack/tablestoreTypes.js +33 -1
- package/dist/src/stack/scfStack/cosPlanner.js +30 -50
- package/dist/src/stack/scfStack/cosTypes.js +29 -1
- package/dist/src/stack/scfStack/esServerlessPlanner.js +21 -54
- package/dist/src/stack/scfStack/esServerlessTypes.js +13 -1
- package/dist/src/stack/scfStack/scfExecutor.js +5 -3
- package/dist/src/stack/scfStack/scfPlanner.js +72 -51
- package/dist/src/stack/scfStack/scfResource.js +109 -12
- package/dist/src/stack/scfStack/scfTypes.js +35 -1
- package/dist/src/stack/scfStack/sharedLogset.js +12 -3
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +37 -55
- package/dist/src/stack/scfStack/tdsqlcTypes.js +21 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +59 -8
- package/dist/src/stack/volcengineStack/apigwResource.js +52 -30
- package/dist/src/stack/volcengineStack/apigwTypes.js +44 -8
- package/dist/src/stack/volcengineStack/sharedLogProject.js +9 -3
- package/dist/src/stack/volcengineStack/tosPlanner.js +28 -55
- package/dist/src/stack/volcengineStack/tosTypes.js +18 -1
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +5 -3
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +119 -10
- package/dist/src/stack/volcengineStack/vefaasResource.js +112 -13
- package/dist/src/stack/volcengineStack/vefaasTypes.js +61 -7
- package/dist/src/validator/semanticValidation.js +41 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const common_1 = require("../../common");
|
|
|
7
7
|
const reportResourceEvent_1 = require("../../common/reportResourceEvent");
|
|
8
8
|
const stateManager_1 = require("../../common/stateManager");
|
|
9
9
|
const lang_1 = require("../../lang");
|
|
10
|
-
const executeSingleItem = async (context, item, eventsMap, serviceName,
|
|
10
|
+
const executeSingleItem = async (context, item, eventsMap, serviceName, resolveRoleArn, currentState) => {
|
|
11
11
|
switch (item.action) {
|
|
12
12
|
case 'noop':
|
|
13
13
|
common_1.logger.info(lang_1.lang.__('NO_CHANGESForResource', { logicalId: item.logicalId }));
|
|
@@ -18,7 +18,7 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, roleArn,
|
|
|
18
18
|
throw new Error(`Event not found for logical ID: ${item.logicalId}`);
|
|
19
19
|
}
|
|
20
20
|
common_1.logger.info(lang_1.lang.__('CREATING_RESOURCE', { resourceType: 'API Gateway resources', name: event.name }));
|
|
21
|
-
const newState = await (0, apigwResource_1.createApigwResource)(context, event, serviceName,
|
|
21
|
+
const newState = await (0, apigwResource_1.createApigwResource)(context, event, serviceName, resolveRoleArn, currentState);
|
|
22
22
|
common_1.logger.info(lang_1.lang.__('RESOURCE_CREATED', { resourceType: 'API Gateway resources', name: event.name }));
|
|
23
23
|
return newState;
|
|
24
24
|
}
|
|
@@ -28,7 +28,7 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, roleArn,
|
|
|
28
28
|
throw new Error(`Event not found for logical ID: ${item.logicalId}`);
|
|
29
29
|
}
|
|
30
30
|
common_1.logger.info(lang_1.lang.__('UPDATING_RESOURCE', { resourceType: 'API Gateway resources', name: event.name }));
|
|
31
|
-
const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName,
|
|
31
|
+
const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState);
|
|
32
32
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'API Gateway resources', name: event.name }));
|
|
33
33
|
return newState;
|
|
34
34
|
}
|
|
@@ -57,7 +57,7 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, roleArn,
|
|
|
57
57
|
/**
|
|
58
58
|
* Execute API Gateway plan with partial failure support
|
|
59
59
|
*/
|
|
60
|
-
const executeApigwPlan = async (context, plan, events, serviceName,
|
|
60
|
+
const executeApigwPlan = async (context, plan, events, serviceName, resolveRoleArn, initialState, onStateChange) => {
|
|
61
61
|
const eventsMap = new Map(events?.map((e) => [`events.${e.key}`, e]) ?? []);
|
|
62
62
|
const successfulItems = [];
|
|
63
63
|
let currentState = initialState;
|
|
@@ -71,7 +71,7 @@ const executeApigwPlan = async (context, plan, events, serviceName, roleArn, ini
|
|
|
71
71
|
});
|
|
72
72
|
const __siStartedAt = Date.now();
|
|
73
73
|
try {
|
|
74
|
-
const newState = await executeSingleItem(context, item, eventsMap, serviceName,
|
|
74
|
+
const newState = await executeSingleItem(context, item, eventsMap, serviceName, resolveRoleArn, currentState);
|
|
75
75
|
if (newState !== null) {
|
|
76
76
|
currentState = newState;
|
|
77
77
|
successfulItems.push(item);
|
|
@@ -5,6 +5,10 @@ const aliyunClient_1 = require("../../common/aliyunClient");
|
|
|
5
5
|
const apigwTypes_1 = require("./apigwTypes");
|
|
6
6
|
const stateManager_1 = require("../../common/stateManager");
|
|
7
7
|
const hashUtils_1 = require("../../common/hashUtils");
|
|
8
|
+
const iacHelper_1 = require("../../common/iacHelper");
|
|
9
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
10
|
+
const refreshCache_1 = require("../../common/refreshCache");
|
|
11
|
+
const concurrency_1 = require("../../common/concurrency");
|
|
8
12
|
const ownershipTag_1 = require("../ownershipTag");
|
|
9
13
|
const DNS_SUB_RESOURCE_SUFFIXES = ['.dns_verification', '.dns_txt_verification'];
|
|
10
14
|
const isDnsSubResource = (logicalId) => DNS_SUB_RESOURCE_SUFFIXES.some((suffix) => logicalId.endsWith(suffix));
|
|
@@ -14,6 +18,17 @@ const planEventDeletion = (logicalId, definition) => ({
|
|
|
14
18
|
resourceType: 'ALIYUN_APIGW',
|
|
15
19
|
changes: { before: definition },
|
|
16
20
|
});
|
|
21
|
+
const buildDesiredTriggerApiName = (event, trigger, stage) => (0, apigwTypes_1.buildAliyunApigwApiName)(event.name, stage, (0, apigwTypes_1.generateApiKey)(trigger.method, trigger.path));
|
|
22
|
+
const resolveTriggerBackend = (iac, backendRef) => {
|
|
23
|
+
if (!iac) {
|
|
24
|
+
return backendRef;
|
|
25
|
+
}
|
|
26
|
+
const functionDef = (0, iacHelper_1.getIacDefinition)(iac, backendRef);
|
|
27
|
+
if (!functionDef || !(0, iacHelper_1.isFunctionDomain)(functionDef)) {
|
|
28
|
+
return backendRef;
|
|
29
|
+
}
|
|
30
|
+
return functionDef.name;
|
|
31
|
+
};
|
|
17
32
|
/**
|
|
18
33
|
* Generate plan for API Gateway events
|
|
19
34
|
*/
|
|
@@ -27,7 +42,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
27
42
|
return { items };
|
|
28
43
|
}
|
|
29
44
|
const desiredLogicalIds = new Set(events.map((e) => `events.${e.key}`));
|
|
30
|
-
const eventItems = await
|
|
45
|
+
const eventItems = await (0, concurrency_1.mapWithConcurrency)(events, concurrency_1.PLAN_READ_CONCURRENCY, async (event) => {
|
|
31
46
|
const logicalId = `events.${event.key}`;
|
|
32
47
|
const currentState = (0, stateManager_1.getResource)(state, logicalId);
|
|
33
48
|
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage);
|
|
@@ -50,7 +65,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
50
65
|
// If a same-named group already exists WITHOUT our ownership tag it
|
|
51
66
|
// may belong to another project — fail fast in the plan instead of
|
|
52
67
|
// letting the executor discover it mid-deploy.
|
|
53
|
-
const remoteGroup = await client.apigw.findApiGroupByName(groupConfig.groupName);
|
|
68
|
+
const remoteGroup = await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.findApiGroupByName:${groupConfig.groupName}`, () => client.apigw.findApiGroupByName(groupConfig.groupName));
|
|
54
69
|
if (remoteGroup?.groupId) {
|
|
55
70
|
if (!(0, ownershipTag_1.isOwnedByStack)(context, logicalId, remoteGroup.tags)) {
|
|
56
71
|
throw new Error(`API group ${groupConfig.groupName} already exists in provider but is not owned by this stack (missing ${ownershipTag_1.OWNERSHIP_TAG_KEY} tag). Refusing to create — resolve manually.`);
|
|
@@ -77,8 +92,12 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
77
92
|
// State exists, check for changes
|
|
78
93
|
try {
|
|
79
94
|
const groupInstance = currentState.instances.find((i) => i.type === 'ALIYUN_APIGW_GROUP');
|
|
95
|
+
const currentDefinition = currentState.definition || {};
|
|
96
|
+
const definitionChanged = !(0, hashUtils_1.attributesEqual)(currentDefinition, desiredDefinition);
|
|
97
|
+
let groupRemoteDiffers = false;
|
|
98
|
+
let triggersDiffer = false;
|
|
80
99
|
if (groupInstance) {
|
|
81
|
-
const remoteGroup = await client.apigw.getApiGroup(groupInstance.id);
|
|
100
|
+
const remoteGroup = await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.getApiGroup:${groupInstance.id}`, () => client.apigw.getApiGroup(groupInstance.id));
|
|
82
101
|
if (!remoteGroup) {
|
|
83
102
|
// Resource in state but not remotely - needs recreate
|
|
84
103
|
return {
|
|
@@ -89,15 +108,64 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
89
108
|
drifted: true,
|
|
90
109
|
};
|
|
91
110
|
}
|
|
111
|
+
// Issue #234 Phase 1: a local config change already forces update, so
|
|
112
|
+
// the live cloud is only probed when state == config — a console edit
|
|
113
|
+
// to the group/trigger then surfaces as update + drifted, and a read
|
|
114
|
+
// failure cannot degrade a config-driven update into a create.
|
|
115
|
+
// Domain/log stay existence-only in Phase 0-2 — never compared live.
|
|
116
|
+
if (!definitionChanged) {
|
|
117
|
+
const remoteGroupAttrs = (0, apigwTypes_1.cloudApigwGroupToDefinition)(remoteGroup);
|
|
118
|
+
groupRemoteDiffers = (0, planCompare_1.remoteDiffersFromDesired)(remoteGroupAttrs, desiredDefinition);
|
|
119
|
+
if (event.triggers.length > 0) {
|
|
120
|
+
const desiredApis = new Map(event.triggers.map((trigger) => {
|
|
121
|
+
const apiName = buildDesiredTriggerApiName(event, trigger, context.stage);
|
|
122
|
+
return [
|
|
123
|
+
apiName,
|
|
124
|
+
{
|
|
125
|
+
method: trigger.method,
|
|
126
|
+
path: trigger.path,
|
|
127
|
+
backend: resolveTriggerBackend(context.iac, String(trigger.backend)),
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
}));
|
|
131
|
+
const cloudSummaries = ((await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.listApisByGroup:${groupInstance.id}`, () => client.apigw.listApisByGroup(groupInstance.id))) ?? []);
|
|
132
|
+
const cloudApis = new Map();
|
|
133
|
+
for (const summary of cloudSummaries) {
|
|
134
|
+
// Only reconcile expected APIs — the executor never touches
|
|
135
|
+
// same-group APIs outside our derived name set (buildCloudInstance
|
|
136
|
+
// in apigwResource), so foreign/console-added APIs are ignored.
|
|
137
|
+
if (!desiredApis.has(summary.apiName)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const apiInfo = await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.getApi:${groupInstance.id}:${summary.apiId}`, () => client.apigw.getApi(groupInstance.id, summary.apiId));
|
|
141
|
+
if (apiInfo) {
|
|
142
|
+
const attrs = (0, apigwTypes_1.cloudApigwApiToTriggerAttributes)(apiInfo);
|
|
143
|
+
if (attrs.apiName) {
|
|
144
|
+
cloudApis.set(attrs.apiName, attrs);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// A desired API absent from the cloud is recreated by the executor.
|
|
149
|
+
triggersDiffer = [...desiredApis.keys()].sort().some((apiName) => {
|
|
150
|
+
const desired = desiredApis.get(apiName);
|
|
151
|
+
const cloud = cloudApis.get(apiName);
|
|
152
|
+
if (!desired || !cloud) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
return (desired.method !== cloud.method ||
|
|
156
|
+
desired.path !== cloud.path ||
|
|
157
|
+
desired.backend !== cloud.backend);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
92
161
|
}
|
|
93
|
-
|
|
94
|
-
const definitionChanged = !(0, hashUtils_1.attributesEqual)(currentDefinition, desiredDefinition);
|
|
95
|
-
if (definitionChanged) {
|
|
162
|
+
if (definitionChanged || groupRemoteDiffers || triggersDiffer) {
|
|
96
163
|
return {
|
|
97
164
|
logicalId,
|
|
98
165
|
action: 'update',
|
|
99
166
|
resourceType: 'ALIYUN_APIGW',
|
|
100
167
|
changes: { before: currentDefinition, after: desiredDefinition },
|
|
168
|
+
drifted: true,
|
|
101
169
|
};
|
|
102
170
|
}
|
|
103
171
|
return { logicalId, action: 'noop', resourceType: 'ALIYUN_APIGW' };
|
|
@@ -110,7 +178,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
110
178
|
changes: { before: currentState.definition, after: desiredDefinition },
|
|
111
179
|
};
|
|
112
180
|
}
|
|
113
|
-
})
|
|
181
|
+
});
|
|
114
182
|
// Find resources in state that are no longer in config
|
|
115
183
|
const allStates = (0, stateManager_1.getAllResources)(state);
|
|
116
184
|
const deletionItems = Object.entries(allStates)
|
|
@@ -273,7 +273,7 @@ const buildLogConfigInstance = (context, slsProject, slsLogStore) => ({
|
|
|
273
273
|
attributes: { slsProject, slsLogStore },
|
|
274
274
|
});
|
|
275
275
|
const ensureGatewayLogConfig = async (context, client, state) => {
|
|
276
|
-
const slsLogStore =
|
|
276
|
+
const slsLogStore = (0, sharedLogProject_1.buildGatewayLogstoreName)(context.service, context.stage);
|
|
277
277
|
const ours = { slsProject: (0, sharedLogProject_1.buildSharedProjectName)(context.app, context.stage), slsLogStore };
|
|
278
278
|
const existing = await client.apigw.describeGatewayLogConfig();
|
|
279
279
|
const matchesOurs = existing &&
|
|
@@ -373,9 +373,10 @@ const buildDomainBindingConfig = async (domain, groupId, serviceName, eventKey,
|
|
|
373
373
|
...certConfig,
|
|
374
374
|
};
|
|
375
375
|
};
|
|
376
|
-
const createApigwResource = async (context, event, serviceName,
|
|
376
|
+
const createApigwResource = async (context, event, serviceName, resolveRoleArn, state) => {
|
|
377
377
|
const logicalId = `events.${event.key}`;
|
|
378
378
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
379
|
+
const roleArnFor = (0, apigwTypes_1.normalizeRoleArnResolver)(resolveRoleArn);
|
|
379
380
|
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage, context, logicalId);
|
|
380
381
|
// Stamp the ownership tag — the create-time contract that lets a later run
|
|
381
382
|
// (state reset, mid-run failure) idempotently adopt the group we create
|
|
@@ -471,7 +472,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
471
472
|
}
|
|
472
473
|
// Create APIs and deployments for each trigger
|
|
473
474
|
for (const trigger of event.triggers) {
|
|
474
|
-
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage,
|
|
475
|
+
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage, roleArnFor(String(trigger.backend)));
|
|
475
476
|
const apiId = await client.apigw.createApi(apiConfig);
|
|
476
477
|
// Get API info for state
|
|
477
478
|
const apiInfo = await client.apigw.getApi(groupId, apiId);
|
|
@@ -586,15 +587,16 @@ const readApigwResourceByName = async (context, groupName) => {
|
|
|
586
587
|
return await client.apigw.findApiGroupByName(groupName);
|
|
587
588
|
};
|
|
588
589
|
exports.readApigwResourceByName = readApigwResourceByName;
|
|
589
|
-
const updateApigwResource = async (context, event, serviceName,
|
|
590
|
+
const updateApigwResource = async (context, event, serviceName, resolveRoleArn, state) => {
|
|
590
591
|
const logicalId = `events.${event.key}`;
|
|
591
592
|
const existingState = (0, stateManager_1.getResource)(state, logicalId);
|
|
592
593
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
594
|
+
const roleArnFor = (0, apigwTypes_1.normalizeRoleArnResolver)(resolveRoleArn);
|
|
593
595
|
let existingInstances;
|
|
594
596
|
let groupId;
|
|
595
597
|
// Precompute expected API names from triggers to safely filter cloud APIs
|
|
596
598
|
const expectedApiNames = new Set(event.triggers.map((trigger) => {
|
|
597
|
-
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, 'placeholder', serviceName, context.region, context.stage,
|
|
599
|
+
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, 'placeholder', serviceName, context.region, context.stage, roleArnFor(String(trigger.backend)));
|
|
598
600
|
return apiConfig.apiName;
|
|
599
601
|
}));
|
|
600
602
|
const buildCloudInstance = (cloudGroup, cloudApis) => {
|
|
@@ -622,7 +624,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
622
624
|
// Shared helper: try to find the group from cloud. On any error (or not found),
|
|
623
625
|
// fall back to full creation since there's nothing to update.
|
|
624
626
|
const findCloudGroupOrCreate = async () => {
|
|
625
|
-
return (0, exports.createApigwResource)(context, event, serviceName,
|
|
627
|
+
return (0, exports.createApigwResource)(context, event, serviceName, resolveRoleArn, state);
|
|
626
628
|
};
|
|
627
629
|
if (existingState) {
|
|
628
630
|
existingInstances = existingState.instances;
|
|
@@ -692,7 +694,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
692
694
|
const existingApis = existingInstances.filter((i) => i.type === 'ALIYUN_APIGW_API');
|
|
693
695
|
const neededApiKeys = new Set();
|
|
694
696
|
for (const trigger of event.triggers) {
|
|
695
|
-
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage,
|
|
697
|
+
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage, roleArnFor(String(trigger.backend)));
|
|
696
698
|
const apiKey = (0, apigwTypes_1.generateApiKey)(trigger.method, trigger.path);
|
|
697
699
|
neededApiKeys.add(apiKey);
|
|
698
700
|
const existingApi = existingApis.find((a) => {
|
|
@@ -723,7 +725,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
723
725
|
const apiInfo = await client.apigw.getApi(groupId, existingApi.id);
|
|
724
726
|
if (apiInfo) {
|
|
725
727
|
const isNeeded = event.triggers.some((t) => {
|
|
726
|
-
const expectedName = (0, apigwTypes_1.triggerToApigwApiConfig)(event, t, groupId, serviceName, context.region, context.stage,
|
|
728
|
+
const expectedName = (0, apigwTypes_1.triggerToApigwApiConfig)(event, t, groupId, serviceName, context.region, context.stage, roleArnFor(String(t.backend))).apiName;
|
|
727
729
|
return apiInfo.apiName === expectedName;
|
|
728
730
|
});
|
|
729
731
|
if (!isNeeded) {
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractEventDomainDefinition = exports.buildEventLogSnapshot = exports.inferProtocolConfig = exports.extractApigwDeploymentDefinition = exports.extractApigwApiDefinition = exports.extractApigwGroupDefinition = exports.triggerToApigwApiConfig = exports.eventToApigwGroupConfig = exports.generateApiKey = exports.buildAliyunApigwApiName = void 0;
|
|
3
|
+
exports.cloudGatewayLogToLogConfig = exports.cloudApigwCustomDomainToDefinition = exports.cloudApigwApiToTriggerAttributes = exports.cloudApigwGroupToDefinition = exports.extractEventDomainDefinition = exports.buildEventLogSnapshot = exports.inferProtocolConfig = exports.extractApigwDeploymentDefinition = exports.extractApigwApiDefinition = exports.extractApigwGroupDefinition = exports.triggerToApigwApiConfig = exports.eventToApigwGroupConfig = exports.normalizeRoleArnResolver = exports.generateApiKey = exports.buildAliyunApigwApiName = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const lang_1 = require("../../lang");
|
|
6
6
|
const ownershipTag_1 = require("../ownershipTag");
|
|
7
|
+
const sharedLogProject_1 = require("./sharedLogProject");
|
|
7
8
|
var common_2 = require("../../common");
|
|
8
9
|
Object.defineProperty(exports, "buildAliyunApigwApiName", { enumerable: true, get: function () { return common_2.buildAliyunApigwApiName; } });
|
|
9
10
|
Object.defineProperty(exports, "generateApiKey", { enumerable: true, get: function () { return common_2.generateApiKey; } });
|
|
11
|
+
const normalizeRoleArnResolver = (param) => {
|
|
12
|
+
if (typeof param === 'function') {
|
|
13
|
+
return param;
|
|
14
|
+
}
|
|
15
|
+
return () => param;
|
|
16
|
+
};
|
|
17
|
+
exports.normalizeRoleArnResolver = normalizeRoleArnResolver;
|
|
10
18
|
/**
|
|
11
19
|
* Convert EventDomain to API Gateway group config
|
|
12
20
|
*
|
|
@@ -38,6 +46,7 @@ exports.eventToApigwGroupConfig = eventToApigwGroupConfig;
|
|
|
38
46
|
/**
|
|
39
47
|
* Resolves a function reference like ${functions.xxx} to the actual function name
|
|
40
48
|
*/
|
|
49
|
+
const FUNCTION_REF_PATTERN = /^\$\{functions\.[\w.]+\}$/;
|
|
41
50
|
const resolveFunctionReference = (backendRef) => {
|
|
42
51
|
// Get IAC from context
|
|
43
52
|
const context = (0, common_1.getContext)();
|
|
@@ -48,8 +57,14 @@ const resolveFunctionReference = (backendRef) => {
|
|
|
48
57
|
// Use getIacDefinition to resolve function references
|
|
49
58
|
const functionDef = (0, common_1.getIacDefinition)(context.iac, backendRef);
|
|
50
59
|
if (!functionDef || !(0, common_1.isFunctionDomain)(functionDef)) {
|
|
51
|
-
//
|
|
52
|
-
|
|
60
|
+
// Dangling template refs fail semantic validation; a bare value that matches
|
|
61
|
+
// no template function is an external deployed function name (issue #227).
|
|
62
|
+
if (FUNCTION_REF_PATTERN.test(backendRef)) {
|
|
63
|
+
common_1.logger.warn(lang_1.lang.__('FUNCTION_REF_NOT_RESOLVED', { backendRef }));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
common_1.logger.info(lang_1.lang.__('EXTERNAL_FUNCTION_BACKEND', { backendRef }));
|
|
67
|
+
}
|
|
53
68
|
return backendRef;
|
|
54
69
|
}
|
|
55
70
|
const functionName = functionDef.name;
|
|
@@ -208,8 +223,8 @@ const buildEventLogSnapshot = (event, context) => {
|
|
|
208
223
|
return {
|
|
209
224
|
logEnabled: event.log === true || event.log === 'true',
|
|
210
225
|
logConfig: {
|
|
211
|
-
project:
|
|
212
|
-
logstore:
|
|
226
|
+
project: (0, sharedLogProject_1.buildSharedProjectName)(context.app, context.stage),
|
|
227
|
+
logstore: (0, sharedLogProject_1.buildGatewayLogstoreName)(context.service, context.stage),
|
|
213
228
|
},
|
|
214
229
|
};
|
|
215
230
|
};
|
|
@@ -254,3 +269,69 @@ const extractEventDomainDefinition = (domain) => {
|
|
|
254
269
|
return definition;
|
|
255
270
|
};
|
|
256
271
|
exports.extractEventDomainDefinition = extractEventDomainDefinition;
|
|
272
|
+
// Cloud response normalizers (issue #234): pure field mappings from already
|
|
273
|
+
// fetched cloud objects back to the desired/config extract shapes. Never call a
|
|
274
|
+
// client API; Wave C diffs these against the desired definitions and only
|
|
275
|
+
// compares keys both sides declare, so omitting config-only or unreadable keys
|
|
276
|
+
// here prevents phantom drift.
|
|
277
|
+
/**
|
|
278
|
+
* Cloud-side counterpart of extractApigwGroupDefinition: maps an ApigwGroupInfo
|
|
279
|
+
* to the same {groupName, description, basePath} shape the planner diffs.
|
|
280
|
+
*/
|
|
281
|
+
const cloudApigwGroupToDefinition = (group) => {
|
|
282
|
+
return {
|
|
283
|
+
groupName: group.groupName ?? null,
|
|
284
|
+
description: group.description ?? null,
|
|
285
|
+
basePath: group.basePath ?? null,
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
exports.cloudApigwGroupToDefinition = cloudApigwGroupToDefinition;
|
|
289
|
+
/**
|
|
290
|
+
* Cloud-side counterpart of a desired trigger {method, path, backend}: the API's
|
|
291
|
+
* recorded apiName plus the request method/path and the FunctionCompute backend
|
|
292
|
+
* name. Fields with no clear cloud value stay undefined (never invented).
|
|
293
|
+
*/
|
|
294
|
+
const cloudApigwApiToTriggerAttributes = (api) => {
|
|
295
|
+
return {
|
|
296
|
+
apiName: api.apiName ?? '',
|
|
297
|
+
method: api.requestConfig?.requestHttpMethod,
|
|
298
|
+
path: api.requestConfig?.requestPath,
|
|
299
|
+
backend: api.serviceConfig?.functionComputeConfig?.functionName,
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
exports.cloudApigwApiToTriggerAttributes = cloudApigwApiToTriggerAttributes;
|
|
303
|
+
/**
|
|
304
|
+
* Cloud-side counterpart of extractEventDomainDefinition restricted to the keys
|
|
305
|
+
* the cloud reliably reports (domainName + certificateId). wwwBindApex,
|
|
306
|
+
* protocol, certificate bodies and cdn* have no cloud source and are omitted so
|
|
307
|
+
* they can never trigger phantom drift. Undefined when the item has no
|
|
308
|
+
* domainName to key on.
|
|
309
|
+
*/
|
|
310
|
+
const cloudApigwCustomDomainToDefinition = (domain) => {
|
|
311
|
+
if (!domain.domainName) {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
domainName: domain.domainName,
|
|
316
|
+
certificateId: domain.certificateId ?? null,
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
exports.cloudApigwCustomDomainToDefinition = cloudApigwCustomDomainToDefinition;
|
|
320
|
+
/**
|
|
321
|
+
* Cloud-side counterpart of buildEventLogSnapshot: maps the region-wide PROVIDER
|
|
322
|
+
* gateway log config into the snapshot shape. Undefined when no PROVIDER config
|
|
323
|
+
* exists (describeGatewayLogConfig returned null or an empty config).
|
|
324
|
+
*/
|
|
325
|
+
const cloudGatewayLogToLogConfig = (log) => {
|
|
326
|
+
if (!log || log.logType == null || log.logType === '') {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
logEnabled: log.logType === 'PROVIDER',
|
|
331
|
+
logConfig: {
|
|
332
|
+
project: log.slsProject ?? '',
|
|
333
|
+
logstore: log.slsLogStore ?? '',
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
exports.cloudGatewayLogToLogConfig = cloudGatewayLogToLogConfig;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDatabasePlan = void 0;
|
|
4
4
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
|
+
const refreshCache_1 = require("../../common/refreshCache");
|
|
6
|
+
const concurrency_1 = require("../../common/concurrency");
|
|
5
7
|
const rdsTypes_1 = require("./rdsTypes");
|
|
6
8
|
const esServerlessTypes_1 = require("./esServerlessTypes");
|
|
7
9
|
const stateManager_1 = require("../../common/stateManager");
|
|
8
|
-
const
|
|
10
|
+
const refreshPlanner_1 = require("../../common/refreshPlanner");
|
|
9
11
|
const ownershipTag_1 = require("../ownershipTag");
|
|
10
12
|
const toOwnershipTagShape = (tags) => tags?.map((t) => ({ Key: t.key, Value: t.value }));
|
|
11
13
|
const planDatabaseDeletion = (logicalId, definition, resourceType) => ({
|
|
@@ -61,71 +63,33 @@ const generateDatabasePlan = async (context, state, databases) => {
|
|
|
61
63
|
}
|
|
62
64
|
const desiredLogicalIds = new Set(aliyunDatabases.map((db) => `databases.${db.key}`));
|
|
63
65
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
64
|
-
const databaseItems = await
|
|
66
|
+
const databaseItems = await (0, concurrency_1.mapWithConcurrency)(aliyunDatabases, concurrency_1.PLAN_READ_CONCURRENCY, async (database) => {
|
|
65
67
|
const logicalId = `databases.${database.key}`;
|
|
66
68
|
const currentState = (0, stateManager_1.getResource)(state, logicalId);
|
|
67
69
|
const resourceType = getResourceType(database);
|
|
68
70
|
const desiredDefinition = getDesiredDefinition(database);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
let remoteInstance = null;
|
|
92
|
-
if (resourceType === 'ALIYUN_ES_SERVERLESS') {
|
|
93
|
-
remoteInstance = instanceId ? await client.es.getApp(instanceId) : null;
|
|
94
|
-
}
|
|
95
|
-
else if (resourceType === 'ALIYUN_RDS_SERVERLESS') {
|
|
96
|
-
remoteInstance = instanceId ? await client.rds.getInstance(instanceId) : null;
|
|
97
|
-
}
|
|
98
|
-
if (!remoteInstance) {
|
|
99
|
-
return {
|
|
100
|
-
logicalId,
|
|
101
|
-
action: 'create',
|
|
102
|
-
resourceType,
|
|
103
|
-
changes: { before: currentState.definition, after: desiredDefinition },
|
|
104
|
-
drifted: true,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const currentDefinition = currentState.definition || {};
|
|
108
|
-
const definitionChanged = !(0, hashUtils_1.attributesEqual)(currentDefinition, desiredDefinition);
|
|
109
|
-
if (definitionChanged) {
|
|
110
|
-
return {
|
|
111
|
-
logicalId,
|
|
112
|
-
action: 'update',
|
|
113
|
-
resourceType,
|
|
114
|
-
changes: { before: currentDefinition, after: desiredDefinition },
|
|
115
|
-
drifted: true,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return { logicalId, action: 'noop', resourceType };
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
return {
|
|
122
|
-
logicalId,
|
|
123
|
-
action: 'create',
|
|
124
|
-
resourceType,
|
|
125
|
-
changes: { before: currentState.definition, after: desiredDefinition },
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}));
|
|
71
|
+
const instanceId = currentState?.metadata?.instanceId ||
|
|
72
|
+
currentState?.instances?.[0]?.id;
|
|
73
|
+
const isEs = resourceType === 'ALIYUN_ES_SERVERLESS';
|
|
74
|
+
return (0, refreshPlanner_1.planRefreshedResource)({
|
|
75
|
+
logicalId,
|
|
76
|
+
resourceType,
|
|
77
|
+
currentState,
|
|
78
|
+
desiredDefinition,
|
|
79
|
+
probeRead: () => isEs
|
|
80
|
+
? (0, refreshCache_1.cachedRefreshRead)(context, `es.getApp:${database.name}`, () => client.es.getApp(database.name))
|
|
81
|
+
: (0, refreshCache_1.cachedRefreshRead)(context, `rds.getInstanceByName:${database.name}`, () => client.rds.getInstanceByName(database.name)),
|
|
82
|
+
read: () => !instanceId
|
|
83
|
+
? Promise.resolve(null)
|
|
84
|
+
: isEs
|
|
85
|
+
? (0, refreshCache_1.cachedRefreshRead)(context, `es.getApp:${instanceId}`, () => client.es.getApp(instanceId))
|
|
86
|
+
: (0, refreshCache_1.cachedRefreshRead)(context, `rds.getInstance:${instanceId}`, () => client.rds.getInstance(instanceId)),
|
|
87
|
+
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, toOwnershipTagShape(remote.tags)),
|
|
88
|
+
foreignError: () => new Error(`${resourceType} ${database.name} already exists in provider but is not owned by this stack (missing ${ownershipTag_1.OWNERSHIP_TAG_KEY} tag). Refusing to create — resolve manually.`),
|
|
89
|
+
cloudToDefinition: (remote) => isEs ? (0, esServerlessTypes_1.cloudEsToDefinition)(remote) : (0, rdsTypes_1.cloudRdsToDefinition)(remote),
|
|
90
|
+
refresh: context.refresh,
|
|
91
|
+
});
|
|
92
|
+
});
|
|
129
93
|
const allStates = (0, stateManager_1.getAllResources)(state);
|
|
130
94
|
const deletionItems = Object.entries(allStates)
|
|
131
95
|
.filter(([logicalId, resourceState]) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployAliyunStack = void 0;
|
|
3
|
+
exports.deployAliyunStack = exports.buildRoleArnResolver = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
const lang_1 = require("../../lang");
|
|
6
6
|
const fc3Planner_1 = require("./fc3Planner");
|
|
@@ -43,6 +43,36 @@ const logDependencyGraph = (orderedItems, dotGraph) => {
|
|
|
43
43
|
});
|
|
44
44
|
common_1.logger.debug(`${lang_1.lang.__('DOT_GRAPH_OUTPUT')}:\n${dotGraph}`);
|
|
45
45
|
};
|
|
46
|
+
const TEMPLATE_FUNCTION_REF_PATTERN = /^\$\{functions\.([\w.]+)\}$/;
|
|
47
|
+
const findFirstManagedRoleArn = (state) => {
|
|
48
|
+
for (const [logicalId, resourceState] of Object.entries(state.resources ?? {})) {
|
|
49
|
+
if (logicalId.startsWith('functions.')) {
|
|
50
|
+
const ramRoleInstance = resourceState.instances?.find((i) => i.type === 'ALIYUN_RAM_ROLE');
|
|
51
|
+
if (ramRoleInstance?.roleArn) {
|
|
52
|
+
return ramRoleInstance.roleArn;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
/** @public Resolves a trigger backend to its role ARN; template refs and bare names map to that function's role, else first managed role. */
|
|
59
|
+
const buildRoleArnResolver = (state, functions) => {
|
|
60
|
+
const fallbackArn = findFirstManagedRoleArn(state);
|
|
61
|
+
const keyByName = new Map((functions ?? []).map((f) => [f.name, f.key]));
|
|
62
|
+
return (backend) => {
|
|
63
|
+
const refMatch = backend.match(TEMPLATE_FUNCTION_REF_PATTERN);
|
|
64
|
+
const fnKey = refMatch ? refMatch[1] : keyByName.get(backend);
|
|
65
|
+
if (fnKey) {
|
|
66
|
+
const resourceState = state.resources?.[`functions.${fnKey}`];
|
|
67
|
+
const ramRoleInstance = resourceState?.instances?.find((i) => i.type === 'ALIYUN_RAM_ROLE');
|
|
68
|
+
if (ramRoleInstance?.roleArn) {
|
|
69
|
+
return ramRoleInstance.roleArn;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return fallbackArn;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.buildRoleArnResolver = buildRoleArnResolver;
|
|
46
76
|
const deployAliyunStack = async (iac, backend) => {
|
|
47
77
|
const context = (0, common_1.getContext)();
|
|
48
78
|
// Cache IAC for access throughout the deployment
|
|
@@ -123,8 +153,8 @@ const deployAliyunStack = async (iac, backend) => {
|
|
|
123
153
|
});
|
|
124
154
|
}
|
|
125
155
|
// Execute event plan after functions are created (events depend on functions)
|
|
126
|
-
const
|
|
127
|
-
const eventResult = await (0, apigwExecutor_1.executeApigwPlan)(context, eventPlan, iac.events, iac.service,
|
|
156
|
+
const resolveRoleArn = (0, exports.buildRoleArnResolver)(state, iac.functions);
|
|
157
|
+
const eventResult = await (0, apigwExecutor_1.executeApigwPlan)(context, eventPlan, iac.events, iac.service, resolveRoleArn, state, onStateChange);
|
|
128
158
|
state = eventResult.state;
|
|
129
159
|
if (eventResult.partialFailure) {
|
|
130
160
|
handlePartialFailure({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractEsDefinition = exports.databaseToEsConfig = void 0;
|
|
3
|
+
exports.cloudEsToDefinition = exports.extractEsDefinition = exports.databaseToEsConfig = void 0;
|
|
4
4
|
// Map database versions to ES versions
|
|
5
5
|
const esVersionMap = new Map([
|
|
6
6
|
[
|
|
@@ -139,3 +139,52 @@ const extractEsDefinition = (config) => {
|
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
141
|
exports.extractEsDefinition = extractEsDefinition;
|
|
142
|
+
const cloudEsToDefinition = (info) => ({
|
|
143
|
+
...(info.appName === undefined ? {} : { appName: info.appName }),
|
|
144
|
+
...(info.version === undefined ? {} : { appVersion: info.version }),
|
|
145
|
+
...(info.description === undefined ? {} : { description: info.description }),
|
|
146
|
+
...(info.chargeType === undefined ? {} : { chargeType: info.chargeType }),
|
|
147
|
+
...(info.network === undefined
|
|
148
|
+
? {}
|
|
149
|
+
: {
|
|
150
|
+
network: info.network.map((network) => ({
|
|
151
|
+
type: network.type ?? null,
|
|
152
|
+
enabled: network.enabled ?? null,
|
|
153
|
+
domain: network.domain ?? null,
|
|
154
|
+
port: network.port ?? null,
|
|
155
|
+
whiteIpGroup: network.whiteIpGroup
|
|
156
|
+
? network.whiteIpGroup.map((group) => ({
|
|
157
|
+
groupName: group.groupName ?? null,
|
|
158
|
+
ips: group.ips ?? [],
|
|
159
|
+
}))
|
|
160
|
+
: null,
|
|
161
|
+
})),
|
|
162
|
+
}),
|
|
163
|
+
...(info.privateNetwork === undefined
|
|
164
|
+
? {}
|
|
165
|
+
: {
|
|
166
|
+
privateNetwork: info.privateNetwork.map((network) => ({
|
|
167
|
+
type: network.type ?? null,
|
|
168
|
+
enabled: network.enabled ?? null,
|
|
169
|
+
domain: network.domain ?? null,
|
|
170
|
+
port: network.port ?? null,
|
|
171
|
+
vpcId: network.vpcId ?? null,
|
|
172
|
+
pvlEndpointId: network.pvlEndpointId ?? null,
|
|
173
|
+
whiteIpGroup: network.whiteIpGroup
|
|
174
|
+
? network.whiteIpGroup.map((group) => ({
|
|
175
|
+
groupName: group.groupName ?? null,
|
|
176
|
+
ips: group.ips ?? [],
|
|
177
|
+
}))
|
|
178
|
+
: null,
|
|
179
|
+
})),
|
|
180
|
+
}),
|
|
181
|
+
...(info.tags === undefined
|
|
182
|
+
? {}
|
|
183
|
+
: {
|
|
184
|
+
tags: info.tags.map((tag) => ({
|
|
185
|
+
key: tag.key ?? null,
|
|
186
|
+
value: tag.value ?? null,
|
|
187
|
+
})),
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
exports.cloudEsToDefinition = cloudEsToDefinition;
|
|
@@ -13,9 +13,11 @@ const executeCreateAction = async (context, fn, currentState) => {
|
|
|
13
13
|
common_1.logger.info(lang_1.lang.__('RESOURCE_CREATED', { resourceType: 'function', name: fn.name }));
|
|
14
14
|
return newState;
|
|
15
15
|
};
|
|
16
|
-
const executeUpdateAction = async (context, fn, currentState) => {
|
|
16
|
+
const executeUpdateAction = async (context, fn, currentState, drifted) => {
|
|
17
17
|
common_1.logger.info(lang_1.lang.__('UPDATING_RESOURCE', { resourceType: 'function', name: fn.name }));
|
|
18
|
-
|
|
18
|
+
// A drifted plan item means the cloud left the config: force the config
|
|
19
|
+
// re-push even when state-vs-desired sees no change.
|
|
20
|
+
const newState = await (0, fc3Resource_1.updateResource)(context, fn, currentState, { force: drifted === true });
|
|
19
21
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'function', name: fn.name }));
|
|
20
22
|
return newState;
|
|
21
23
|
};
|
|
@@ -42,7 +44,7 @@ const executeSingleItem = async (context, item, functionsMap, currentState) => {
|
|
|
42
44
|
if (!fn) {
|
|
43
45
|
throw new Error(`Function not found for logical ID: ${item.logicalId}`);
|
|
44
46
|
}
|
|
45
|
-
return executeUpdateAction(context, fn, currentState);
|
|
47
|
+
return executeUpdateAction(context, fn, currentState, item.drifted);
|
|
46
48
|
}
|
|
47
49
|
case 'delete': {
|
|
48
50
|
const state = (0, stateManager_1.getResource)(currentState, item.logicalId);
|