@geek-fun/serverlessinsight 0.9.2 → 0.9.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 +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 +4 -8
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -8
- 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-poc-timer-app-insight-poc-timer.json.backup +28 -5
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +20 -5
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/AGENTS.md +10 -0
- package/CHANGELOG.md +62 -0
- package/README.md +256 -175
- package/README.zh-CN.md +249 -159
- package/dist/package.json +22 -19
- package/dist/src/commands/index.js +21 -52
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +35 -4
- package/dist/src/common/aliyunClient/apigwOperations.js +48 -9
- package/dist/src/common/aliyunClient/fc3Operations.js +7 -1
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- package/dist/src/common/domainUtils.js +4 -1
- package/dist/src/common/functionDefinition.js +25 -0
- package/dist/src/common/index.js +4 -0
- package/dist/src/common/jsonOutput.js +6 -1
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +22 -14
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +9 -2
- package/dist/src/common/tencentClient/tdsqlcOperations.js +6 -11
- package/dist/src/common/triggerMapper.js +16 -1
- package/dist/src/common/volcengineClient/apigwOperations.js +82 -0
- package/dist/src/common/volcengineClient/iamOperations.js +27 -3
- package/dist/src/common/volcengineClient/tosOperations.js +62 -56
- package/dist/src/lang/en.js +33 -8
- package/dist/src/lang/index.js +28 -14
- package/dist/src/lang/zh-CN.js +33 -8
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +1 -1
- package/dist/src/stack/aliyunStack/apigwDomainPlan.js +82 -0
- package/dist/src/stack/aliyunStack/apigwExecutor.js +4 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +165 -25
- package/dist/src/stack/aliyunStack/apigwResource.js +172 -126
- package/dist/src/stack/aliyunStack/apigwTypes.js +3 -7
- package/dist/src/stack/aliyunStack/deployer.js +2 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +8 -4
- package/dist/src/stack/aliyunStack/fc3Executor.js +7 -3
- package/dist/src/stack/aliyunStack/fc3Planner.js +124 -155
- package/dist/src/stack/aliyunStack/fc3Resource.js +48 -52
- package/dist/src/stack/aliyunStack/fc3Types.js +30 -16
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +113 -102
- package/dist/src/stack/aliyunStack/ossTypes.js +20 -20
- package/dist/src/stack/localStack/aliyunFc.js +1 -6
- package/dist/src/stack/localStack/event.js +31 -60
- package/dist/src/stack/localStack/function.js +24 -65
- package/dist/src/stack/localStack/functionRunner.js +10 -2
- package/dist/src/stack/localStack/httpAdapter.js +54 -0
- package/dist/src/stack/localStack/httpError.js +5 -0
- package/dist/src/stack/localStack/legacyLambda.js +26 -0
- package/dist/src/stack/localStack/localContext.js +29 -0
- package/dist/src/stack/localStack/localRoute.js +12 -0
- package/dist/src/stack/localStack/localRuntimes.js +22 -0
- package/dist/src/stack/localStack/localServer.js +8 -3
- package/dist/src/stack/localStack/requestBody.js +24 -0
- package/dist/src/stack/localStack/requestId.js +18 -0
- package/dist/src/stack/localStack/tencent.js +147 -0
- package/dist/src/stack/localStack/timer.js +23 -2
- package/dist/src/stack/localStack/volcengine.js +68 -0
- package/dist/src/stack/scfStack/cosPlanner.js +9 -14
- package/dist/src/stack/scfStack/cosResource.js +42 -50
- package/dist/src/stack/scfStack/cosTypes.js +19 -14
- package/dist/src/stack/scfStack/deployer.js +2 -0
- package/dist/src/stack/scfStack/scfExecutor.js +7 -3
- package/dist/src/stack/scfStack/scfHttpTrigger.js +106 -0
- package/dist/src/stack/scfStack/scfPlanner.js +67 -16
- package/dist/src/stack/scfStack/scfResource.js +170 -321
- package/dist/src/stack/scfStack/scfTypes.js +4 -3
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +10 -13
- package/dist/src/stack/volcengineStack/apigwDomains.js +64 -0
- package/dist/src/stack/volcengineStack/apigwPlanner.js +71 -15
- package/dist/src/stack/volcengineStack/apigwResource.js +60 -24
- package/dist/src/stack/volcengineStack/apigwTypes.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +6 -0
- package/dist/src/stack/volcengineStack/tosPlanner.js +8 -13
- package/dist/src/stack/volcengineStack/tosResource.js +22 -35
- package/dist/src/stack/volcengineStack/tosTypes.js +5 -8
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +142 -49
- package/dist/src/stack/volcengineStack/vefaasResource.js +17 -12
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/release-notes.md +53 -0
- package/samples/README_TENCENT_COS.md +3 -3
- package/samples/README_TENCENT_SCF.md +3 -3
- package/samples/tencent-local/index.js +13 -0
- package/samples/tencent-local/serverlessinsight.yml +23 -0
- package/samples/volcengine-local/index.js +13 -0
- package/samples/volcengine-local/serverlessinsight.yml +28 -0
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zhCN = void 0;
|
|
4
4
|
exports.zhCN = {
|
|
5
|
+
PLAN_SENSITIVE_VALUE: '(敏感值)',
|
|
6
|
+
PLAN_NAS_NETWORK_REQUIRED: '{{logicalId}} 的 NAS 存储需要声明 VPC 网络或已有挂载目标记录。计划已停止,尚未创建任何资源。',
|
|
7
|
+
APIGW_DOMAIN_READ_INVALID: '域名 {{domainId}} 的查询响应无效',
|
|
8
|
+
APIGW_DOMAIN_CERTIFICATE_UPDATED: '已更新网关域名证书: {{domain}}',
|
|
9
|
+
PLAN_DRIFT_EVENT_DOMAIN: '网关域名或证书与配置不一致或不存在',
|
|
10
|
+
PLAN_DRIFT_HTTP_TRIGGER: 'HTTP 触发器与请求配置不同或已丢失',
|
|
11
|
+
PLAN_DRIFT_FUNCTION_DOMAIN: '函数域名与请求配置不同或已丢失',
|
|
12
|
+
PLAN_REPLACEMENT_REQUIRED: '{{logicalId}} 的 {{fields}} 变更需要替换资源。暂不支持自动替换,请显式迁移或重建资源。',
|
|
13
|
+
PLAN_UPDATE_NOT_SUPPORTED: '无法更新 {{logicalId}} 的 {{fields}}:当前云厂商更新实现不支持这些属性。尚未执行任何变更。',
|
|
14
|
+
PLAN_STATE_ONLY: '{{logicalId}} 已与云端一致,仅更新保存的配置意图。',
|
|
5
15
|
// Validation messages
|
|
6
16
|
VALIDATING_YAML: '正在验证 yaml...',
|
|
7
17
|
YAML_VALID: 'Yaml 有效! 🎉',
|
|
@@ -121,7 +131,7 @@ exports.zhCN = {
|
|
|
121
131
|
PLAN_COMPUTED_VALUE: '(部署后可知)',
|
|
122
132
|
PLAN_REVERT_ANNOTATION: '(云端已改,将按配置恢复)',
|
|
123
133
|
PLAN_DRIFTED_MARKER: '(云端已漂移——与本配置不一致,将按配置纠正)',
|
|
124
|
-
PLAN_LIVE_READ_FAILED: '读取 {{logicalId}}
|
|
134
|
+
PLAN_LIVE_READ_FAILED: '读取 {{logicalId}} 云端状态失败,计划已停止: {{error}}',
|
|
125
135
|
PLAN_DRIFT_ROLE_MISSING: '云端 IAM 角色缺失',
|
|
126
136
|
PLAN_DRIFT_ROLE_POLICY: '云端 IAM 角色策略被修改',
|
|
127
137
|
PLAN_DRIFT_LOGSTORE: '云端函数日志资源被修改',
|
|
@@ -225,7 +235,7 @@ exports.zhCN = {
|
|
|
225
235
|
FORCE_UNLOCK_CONFIRM: '您确定吗?(yes/no): ',
|
|
226
236
|
FORCE_UNLOCK_CANCELLED: '强制解锁已取消',
|
|
227
237
|
SAAS_FORCE_UNLOCK_NOT_SUPPORTED: 'SaaS 模式下不支持通过 CLI 强制解锁。请在浏览器中打开 {{consoleUrl}},从部署页面解锁该部署。',
|
|
228
|
-
PLAN_COMMAND_NOT_SUPPORTED: '
|
|
238
|
+
PLAN_COMMAND_NOT_SUPPORTED: '此提供商不支持生成部署计划',
|
|
229
239
|
// Lock info formatting
|
|
230
240
|
LOCK_INFO_HEADER: '锁信息:',
|
|
231
241
|
LOCK_INFO_ID: ' ID: {{id}}',
|
|
@@ -250,8 +260,8 @@ exports.zhCN = {
|
|
|
250
260
|
SHARED_SLS_PROJECT_ADOPTED: '采用当前应用已有的共享 SLS 项目 {{projectName}}',
|
|
251
261
|
REFRESH_CACHE_HIT: '刷新读缓存命中:{{key}}',
|
|
252
262
|
PLAN_FUNCTION_ROLE_MISSING: '函数 {{functionName}} 的角色 {{roleName}} 在云端不存在;部署时将重建并重新绑定',
|
|
253
|
-
PLAN_FUNCTION_ROLE_PROBE_FAILED: '函数 {{functionName}}(角色 {{roleName}})的实时角色策略检查失败:{{error}}
|
|
254
|
-
PLAN_FUNCTION_NESTED_PROBE_FAILED: '函数 {{functionName}} 的嵌套资源探测失败:{{error}}
|
|
263
|
+
PLAN_FUNCTION_ROLE_PROBE_FAILED: '函数 {{functionName}}(角色 {{roleName}})的实时角色策略检查失败:{{error}};计划已停止',
|
|
264
|
+
PLAN_FUNCTION_NESTED_PROBE_FAILED: '函数 {{functionName}} 的嵌套资源探测失败:{{error}};计划已停止',
|
|
255
265
|
NESTED_LOGSTORE_RECREATED: '日志库 {{logstoreName}} 被带外删除,正在重建',
|
|
256
266
|
NESTED_LOGSTORE_UPDATED: '日志库 {{logstoreName}} 属性已漂移,正在按 si 默认值更新',
|
|
257
267
|
NESTED_TLS_TOPIC_UPDATED: 'TLS 日志主题 {{topicId}} 的 ttl 已漂移,正在按 si 默认值更新',
|
|
@@ -852,7 +862,7 @@ exports.zhCN = {
|
|
|
852
862
|
MIGRATE_ROLLBACK_NO_MARKER: '旧状态没有迁移标记——无需回滚。',
|
|
853
863
|
MIGRATE_ROLLBACK_DONE: '已清除迁移标记,旧后端恢复可写。',
|
|
854
864
|
MIGRATE_ROLLBACK_DONE_HINT: '如果已从 YAML 中删除 backend.state_manager 段,经旧后端部署前请先恢复该段。',
|
|
855
|
-
MIGRATE_CUTOVER_STEPS: 'cutover 清单:\n 1. 从 serverlessinsight.yml 删除 backend.state_manager 段,并在顶层添加 org 声明(org: <slug>,slug 见 Console 组织设置)后合并\n 2. 运行 `si
|
|
865
|
+
MIGRATE_CUTOVER_STEPS: 'cutover 清单:\n 1. 从 serverlessinsight.yml 删除 backend.state_manager 段,并在顶层添加 org 声明(org: <slug>,slug 见 Console 组织设置)后合并\n 2. 运行 `si diff`——必须显示无变更并退出 0(这是迁移无损的证明)\n 3. 恢复部署;此后部署时间线由 Console 接管',
|
|
856
866
|
MIGRATION_MARKER_REFUSED: '该状态已迁移至 ServerlessInsight Console(managedBy=saas),旧后端已关闭变更。\n • 继续使用 Console:从 YAML 中删除 backend.state_manager 段并在顶层声明 org: <slug> 后重新部署。\n • 确需经旧后端操作:运行 `si migrate --rollback` 清除标记。',
|
|
857
867
|
MIGRATION_MARKER_WARN: '该状态已迁移至 Console(managedBy=saas)——此处展示的是只读副本,可能已过期。请勿从该后端部署。',
|
|
858
868
|
// HTTP trigger messages
|
|
@@ -887,7 +897,7 @@ exports.zhCN = {
|
|
|
887
897
|
TIMER_TRIGGER_DELETED: "定时触发器 '{{triggerName}}' 已删除",
|
|
888
898
|
TIMER_TRIGGER_NOT_FOUND: "定时触发器 '{{triggerName}}' 在云平台中不存在,跳过删除",
|
|
889
899
|
TIMER_TRIGGER_ALREADY_ATTACHED: "定时触发器 '{{triggerName}}' 已挂在函数 '{{functionName}}' 上,跳过创建",
|
|
890
|
-
PLAN_DRIFT_TIMER_TRIGGER: '
|
|
900
|
+
PLAN_DRIFT_TIMER_TRIGGER: '定时触发器与请求配置不同',
|
|
891
901
|
PLAN_TIMER_TRIGGER_PROBE_FAILED: "探测函数 '{{functionName}}' 的定时触发器失败:{{error}}",
|
|
892
902
|
// si-cron messages (issue #258)
|
|
893
903
|
SI_CRON_EMPTY: 'si-cron 表达式为空',
|
|
@@ -1008,11 +1018,26 @@ exports.zhCN = {
|
|
|
1008
1018
|
OTS_ATTRIBUTE_NOT_FOUND: '找不到 key 对应的属性:{{key}}',
|
|
1009
1019
|
LOCAL_HANDLER_NOT_FOUND: '在 {{handlerPath}} 中找不到 Handler "{{handlerMethod}}",或它不是函数',
|
|
1010
1020
|
LOCAL_EXECUTION_TIMEOUT: '函数执行超时({{timeoutMs}}ms)',
|
|
1021
|
+
LOCAL_FUNCTION_NOT_FOUND: '找不到函数',
|
|
1022
|
+
LOCAL_FUNCTION_CODE_MISSING: '找不到函数代码配置',
|
|
1023
|
+
LOCAL_FUNCTION_EXECUTION_FAILED: '函数执行失败',
|
|
1024
|
+
LOCAL_HTTP_PROVIDER_UNSUPPORTED: '不支持 provider {{provider}} 的本地 HTTP 调用',
|
|
1025
|
+
LOCAL_VOLCENGINE_MODE_UNSUPPORTED: '本地 veFaaS HTTP 调用仅支持 node14/v1 和 node20/v1 代码包(函数:{{functionName}})。暂不模拟容器、原生运行时及其他语言。',
|
|
1026
|
+
LOCAL_VOLCENGINE_BINARY_UNSUPPORTED: '本地 veFaaS HTTP 调用仅支持 UTF-8 请求体。暂不模拟包含无效 UTF-8 的二进制请求体,也不假定 base64 事件协议。',
|
|
1027
|
+
LOCAL_VOLCENGINE_INVALID_RESPONSE: '本地 veFaaS 响应无效:请返回对象,可包含整数 statusCode(200-599)、字符串值的 headers 和字符串 body。暂不模拟二进制响应。',
|
|
1028
|
+
LOCAL_EVENT_TYPE_UNSUPPORTED: '本地事件端点仅支持 API_GATEWAY 触发器。',
|
|
1029
|
+
LOCAL_SCF_EVENT_UNSUPPORTED: '本地 SCF 模拟覆盖函数所属的函数 URL,而非 API Gateway 事件(未部署腾讯云 API 网关)。请在 /si_functions/<function-key>/<path> 调用函数 URL。',
|
|
1030
|
+
LOCAL_SCF_MODE_UNSUPPORTED: '本地 SCF HTTP 调用仅支持 {{runtimes}} 代码包(函数:{{functionName}})。暂不模拟容器、Web 函数及其他语言。',
|
|
1031
|
+
LOCAL_SCF_BINARY_REQUEST_UNSUPPORTED: '本地 SCF HTTP 调用仅支持 UTF-8 请求体。函数 URL 事件不含 isBase64Encoded 字段,因此不模拟二进制请求体。',
|
|
1032
|
+
LOCAL_SCF_BINARY_RESPONSE_UNSUPPORTED: '本地 SCF 响应不支持二进制响应体:函数 URL 响应不含 isBase64Encoded 字段,因此不模拟 isBase64Encoded 响应。',
|
|
1033
|
+
LOCAL_SCF_INVALID_RESPONSE: '本地 SCF 响应无效:请返回字符串或 JSON 对象,或返回包含可选整数 statusCode(200-599)、字符串值 headers 与字符串 body 的对象。',
|
|
1011
1034
|
LOCAL_PORT_CLOSED: '端口在收到响应前已关闭',
|
|
1012
1035
|
LOCAL_WORKER_EXITED: 'Worker 退出,退出码 {{code}}',
|
|
1013
1036
|
REFRESH_STATE_BUCKET: '刷新存储桶状态失败:{{name}}',
|
|
1014
1037
|
RESOURCE_SPACE_ID_NOT_FOUND: '状态中不存在 Space ID:{{logicalId}}',
|
|
1015
1038
|
REFRESH_STATE_ES_SPACE: '刷新 ES 空间状态失败:{{spaceId}}',
|
|
1039
|
+
IAM_POLICY_READ_INVALID: '策略 {{policyName}} 返回了无效的策略文档',
|
|
1040
|
+
SCF_HTTP_TRIGGER_ID_UNAVAILABLE: '无法记录函数 {{functionName}} 的云端 HTTP 触发器标识',
|
|
1016
1041
|
SCF_HTTP_TRIGGER_ALREADY_ATTACHED: 'HTTP 触发器 {{triggerName}} 已绑定到 {{functionName}},跳过创建',
|
|
1017
1042
|
SCF_HTTP_TRIGGER_ALREADY_EXISTS: 'HTTP 触发器 {{triggerName}} 在 {{functionName}} 上已存在,继续:{{error}}',
|
|
1018
1043
|
SCF_HANDLER_IMMUTABLE: '腾讯云 SCF 的 Handler 不可变,无法在更新时修改({{oldHandler}} -> {{newHandler}})。请删除后重建函数。',
|
|
@@ -1047,8 +1072,8 @@ exports.zhCN = {
|
|
|
1047
1072
|
CMD_WHOAMI_DESC: '显示当前登录状态',
|
|
1048
1073
|
CMD_SHOW_DESC: '从状态中显示已部署资源',
|
|
1049
1074
|
CMD_VALIDATE_DESC: '校验 serverless IaC yaml',
|
|
1050
|
-
|
|
1051
|
-
|
|
1075
|
+
CMD_DIFF_DESC: '展示配置与线上云环境的差异',
|
|
1076
|
+
CMD_PLAN_REMOVED: 'plan 命令已被移除;请改用 diff 命令——两者接受完全相同的选项和参数。迁移方式:将 si plan 替换为 si diff,所有参数保持不变。',
|
|
1052
1077
|
CMD_DEPLOY_DESC: '部署 serverless IaC yaml',
|
|
1053
1078
|
CMD_DESTROY_DESC: '销毁 serverless 资源栈',
|
|
1054
1079
|
CMD_LOCAL_DESC: '本地运行 Serverless 应用进行调试',
|
|
@@ -129,7 +129,7 @@ const parseFunction = (functions) => {
|
|
|
129
129
|
}
|
|
130
130
|
: undefined,
|
|
131
131
|
environment: func.environment,
|
|
132
|
-
log: (0, parseUtils_1.
|
|
132
|
+
log: (0, parseUtils_1.parseBooleanWithDefault)(func.log, false),
|
|
133
133
|
network: func.network,
|
|
134
134
|
storage: {
|
|
135
135
|
disk: (0, parseUtils_1.parseNumber)(func.storage?.disk),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.planApigwDomains = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const certUtils_1 = require("../../common/certUtils");
|
|
6
|
+
const domainUtils_1 = require("../../common/domainUtils");
|
|
7
|
+
const refreshCache_1 = require("../../common/refreshCache");
|
|
8
|
+
const lang_1 = require("../../lang");
|
|
9
|
+
const apigwTypes_1 = require("./apigwTypes");
|
|
10
|
+
const fingerprint = (value) => value ? (0, node_crypto_1.createHash)('sha256').update(value.replace(/\s/g, '')).digest('hex') : null;
|
|
11
|
+
/** Compare readable binding fields without exposing certificate contents or private keys. */
|
|
12
|
+
const planApigwDomains = async (context, client, groupId, domain, summaries, removeCertificate = false) => {
|
|
13
|
+
const primary = String(domain.domain_name);
|
|
14
|
+
const www = domain.www_bind_apex === true ? (0, domainUtils_1.deriveWwwDomain)(primary) : null;
|
|
15
|
+
const names = [primary, ...(www ? [www] : [])];
|
|
16
|
+
const redirect = (0, apigwTypes_1.inferProtocolConfig)(domain.protocol).isHttpRedirectToHttps ??
|
|
17
|
+
false;
|
|
18
|
+
const certificate = domain.certificate_id
|
|
19
|
+
? (await (0, refreshCache_1.cachedRefreshRead)(context, `cas.getCertificate:${domain.certificate_id}`, () => client.cas.getCertificate(String(domain.certificate_id))))?.cert
|
|
20
|
+
: domain.certificate_body
|
|
21
|
+
? (0, certUtils_1.readPemContent)(String(domain.certificate_body))
|
|
22
|
+
: undefined;
|
|
23
|
+
if (domain.certificate_id && !certificate)
|
|
24
|
+
throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: String(domain.certificate_id) }));
|
|
25
|
+
const desiredFingerprint = certificate
|
|
26
|
+
? fingerprint(certificate)
|
|
27
|
+
: removeCertificate
|
|
28
|
+
? null
|
|
29
|
+
: undefined;
|
|
30
|
+
const entries = await Promise.all(names.map(async (name) => {
|
|
31
|
+
const summary = summaries?.find((entry) => entry.domainName === name);
|
|
32
|
+
// An omitted summary entry is not proof of absence. Confirm against the detail API.
|
|
33
|
+
const detail = !summary || certificate || removeCertificate
|
|
34
|
+
? await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.getDomain:${groupId}:${name}`, () => client.apigw.getDomain(groupId, name))
|
|
35
|
+
: undefined;
|
|
36
|
+
const exists = detail === null ? false : detail || summary ? true : undefined;
|
|
37
|
+
const actualFingerprint = detail?.certificateBody !== undefined ? fingerprint(detail.certificateBody) : undefined;
|
|
38
|
+
const before = {
|
|
39
|
+
...(exists !== undefined ? { exists } : {}),
|
|
40
|
+
...(summary?.isHttpRedirectToHttps !== undefined && exists !== false
|
|
41
|
+
? { redirectToHttps: summary.isHttpRedirectToHttps }
|
|
42
|
+
: {}),
|
|
43
|
+
...(desiredFingerprint !== undefined && actualFingerprint !== undefined
|
|
44
|
+
? { certificateFingerprint: actualFingerprint }
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
47
|
+
const after = {
|
|
48
|
+
...(exists !== undefined ? { exists: true } : {}),
|
|
49
|
+
...(summary?.isHttpRedirectToHttps !== undefined || exists === false
|
|
50
|
+
? { redirectToHttps: redirect }
|
|
51
|
+
: {}),
|
|
52
|
+
...(desiredFingerprint !== undefined &&
|
|
53
|
+
(actualFingerprint !== undefined || exists === false)
|
|
54
|
+
? { certificateFingerprint: desiredFingerprint }
|
|
55
|
+
: {}),
|
|
56
|
+
};
|
|
57
|
+
const binding = exists === false ||
|
|
58
|
+
(summary?.isHttpRedirectToHttps !== undefined &&
|
|
59
|
+
summary.isHttpRedirectToHttps !== redirect);
|
|
60
|
+
const certificateChanged = desiredFingerprint !== undefined &&
|
|
61
|
+
(exists === false ||
|
|
62
|
+
(actualFingerprint !== undefined && actualFingerprint !== desiredFingerprint));
|
|
63
|
+
return {
|
|
64
|
+
name,
|
|
65
|
+
before,
|
|
66
|
+
after,
|
|
67
|
+
verified: exists === true &&
|
|
68
|
+
desiredFingerprint !== undefined &&
|
|
69
|
+
actualFingerprint === desiredFingerprint,
|
|
70
|
+
update: binding || certificateChanged
|
|
71
|
+
? { exists: exists === true, binding, certificate: certificateChanged }
|
|
72
|
+
: undefined,
|
|
73
|
+
};
|
|
74
|
+
}));
|
|
75
|
+
return {
|
|
76
|
+
before: Object.fromEntries(entries.map((entry) => [entry.name, entry.before])),
|
|
77
|
+
after: Object.fromEntries(entries.map((entry) => [entry.name, entry.after])),
|
|
78
|
+
updates: Object.fromEntries(entries.flatMap((entry) => (entry.update ? [[entry.name, entry.update]] : []))),
|
|
79
|
+
certificateVerified: entries.every((entry) => entry.verified),
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.planApigwDomains = planApigwDomains;
|
|
@@ -28,7 +28,10 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, resolveR
|
|
|
28
28
|
throw new Error(lang_1.lang.__('RESOURCE_EVENT_NOT_FOUND', { logicalId: 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, resolveRoleArn, currentState
|
|
31
|
+
const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState, {
|
|
32
|
+
repairDomain: item.driftReasons?.includes('PLAN_DRIFT_EVENT_DOMAIN'),
|
|
33
|
+
scope: item.gatewayUpdate,
|
|
34
|
+
});
|
|
32
35
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'API Gateway resources', name: event.name }));
|
|
33
36
|
return newState;
|
|
34
37
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateApigwPlan = void 0;
|
|
4
|
+
const hashUtils_1 = require("../../common/hashUtils");
|
|
5
|
+
const apigwDomainPlan_1 = require("./apigwDomainPlan");
|
|
6
|
+
const planCapabilities_1 = require("../../common/planCapabilities");
|
|
7
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
4
8
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
9
|
const logger_1 = require("../../common/logger");
|
|
6
10
|
const apigwTypes_1 = require("./apigwTypes");
|
|
7
11
|
const stateManager_1 = require("../../common/stateManager");
|
|
8
|
-
const hashUtils_1 = require("../../common/hashUtils");
|
|
9
12
|
const iacHelper_1 = require("../../common/iacHelper");
|
|
10
|
-
const
|
|
13
|
+
const planCompare_2 = require("../../common/planCompare");
|
|
11
14
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
12
15
|
const concurrency_1 = require("../../common/concurrency");
|
|
13
16
|
const ownershipTag_1 = require("../ownershipTag");
|
|
14
17
|
const lang_1 = require("../../lang");
|
|
15
18
|
const DNS_SUB_RESOURCE_SUFFIXES = ['.dns_verification', '.dns_txt_verification'];
|
|
16
|
-
const isDnsSubResource = (logicalId) => DNS_SUB_RESOURCE_SUFFIXES.some((suffix) => logicalId.endsWith(suffix));
|
|
19
|
+
const isDnsSubResource = (logicalId) => DNS_SUB_RESOURCE_SUFFIXES.some((suffix) => logicalId.endsWith(suffix) || logicalId.includes(`${suffix}.`));
|
|
17
20
|
const planEventDeletion = (logicalId, definition) => ({
|
|
18
21
|
logicalId,
|
|
19
22
|
action: 'delete',
|
|
@@ -62,6 +65,8 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
62
65
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
63
66
|
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
64
67
|
};
|
|
68
|
+
if (currentState)
|
|
69
|
+
(0, planCapabilities_1.assertPlanIdentity)(logicalId, 'ALIYUN_APIGW', currentState.definition || {}, desiredDefinition);
|
|
65
70
|
if (!currentState || currentState.status === 'tainted') {
|
|
66
71
|
// No usable local state: probe the provider before planning create.
|
|
67
72
|
// If a same-named group already exists WITHOUT our ownership tag it
|
|
@@ -99,9 +104,42 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
99
104
|
try {
|
|
100
105
|
const groupInstance = currentState.instances.find((i) => i.type === 'ALIYUN_APIGW_GROUP');
|
|
101
106
|
const currentDefinition = currentState.definition || {};
|
|
102
|
-
const
|
|
107
|
+
const previousDomain = currentDefinition.domain;
|
|
108
|
+
const domainRemoved = !!currentDefinition.domain && !desiredDefinition.domain;
|
|
109
|
+
const certificateRemoved = !!desiredDefinition.domain &&
|
|
110
|
+
!!(previousDomain?.certificateId || previousDomain?.certificateBody) &&
|
|
111
|
+
!(desiredDefinition.domain.certificateId || desiredDefinition.domain.certificateBody);
|
|
112
|
+
const logRemoved = !!currentDefinition.log && !logSnapshot;
|
|
113
|
+
const definitionChanged = (0, planCompare_1.definitionsDiffer)(currentDefinition, desiredDefinition) ||
|
|
114
|
+
domainRemoved ||
|
|
115
|
+
logRemoved ||
|
|
116
|
+
certificateRemoved;
|
|
117
|
+
if (context.refresh === false) {
|
|
118
|
+
return definitionChanged
|
|
119
|
+
? {
|
|
120
|
+
logicalId,
|
|
121
|
+
action: 'update',
|
|
122
|
+
resourceType: 'ALIYUN_APIGW',
|
|
123
|
+
changes: {
|
|
124
|
+
before: {
|
|
125
|
+
...(0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition),
|
|
126
|
+
...(domainRemoved || certificateRemoved
|
|
127
|
+
? { domain: currentDefinition.domain }
|
|
128
|
+
: {}),
|
|
129
|
+
...(logRemoved ? { log: currentDefinition.log } : {}),
|
|
130
|
+
},
|
|
131
|
+
after: {
|
|
132
|
+
...(0, planCompare_1.managedDefinition)(desiredDefinition),
|
|
133
|
+
...(certificateRemoved ? { domain: desiredDefinition.domain } : {}),
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
: { logicalId, action: 'noop', resourceType: 'ALIYUN_APIGW' };
|
|
138
|
+
}
|
|
103
139
|
let groupRemoteDiffers = false;
|
|
104
140
|
let triggersDiffer = false;
|
|
141
|
+
let domainDiffers = false;
|
|
142
|
+
let domainPlan;
|
|
105
143
|
// Issue #246: live group attributes become the diff baseline when the
|
|
106
144
|
// group was readable; trigger-level drift has no attribute mapping and
|
|
107
145
|
// is surfaced as a drift reason instead.
|
|
@@ -118,14 +156,25 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
118
156
|
drifted: true,
|
|
119
157
|
};
|
|
120
158
|
}
|
|
121
|
-
// Issue #234 Phase 1: a local config change already forces update, so
|
|
122
|
-
// the live cloud is only probed when state == config — a console edit
|
|
123
|
-
// to the group/trigger then surfaces as update + drifted, and a read
|
|
124
|
-
// failure cannot degrade a config-driven update into a create.
|
|
125
|
-
// Domain/log stay existence-only in Phase 0-2 — never compared live.
|
|
126
159
|
liveGroupAttrs = (0, apigwTypes_1.cloudApigwGroupToDefinition)(remoteGroup);
|
|
127
|
-
if (
|
|
128
|
-
|
|
160
|
+
if (event.domain && desiredDefinition.domain?.cdnEnabled !== true) {
|
|
161
|
+
domainPlan = await (0, apigwDomainPlan_1.planApigwDomains)(context, client, groupInstance.id, event.domain, remoteGroup.customDomains, certificateRemoved);
|
|
162
|
+
domainDiffers = Object.keys(domainPlan.updates).length > 0;
|
|
163
|
+
if (domainPlan.certificateVerified && currentDefinition.domain) {
|
|
164
|
+
liveGroupAttrs.domain = {
|
|
165
|
+
...currentDefinition.domain,
|
|
166
|
+
certificateId: desiredDefinition.domain?.certificateId,
|
|
167
|
+
certificateBody: desiredDefinition.domain?.certificateBody,
|
|
168
|
+
certificatePrivateKey: desiredDefinition.domain?.certificatePrivateKey,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (event.log) {
|
|
173
|
+
const log = await (0, refreshCache_1.cachedRefreshRead)(context, 'apigw.describeGatewayLogConfig', () => client.apigw.describeGatewayLogConfig());
|
|
174
|
+
liveGroupAttrs.log = (0, apigwTypes_1.cloudGatewayLogToLogConfig)(log) ?? { logEnabled: false };
|
|
175
|
+
}
|
|
176
|
+
{
|
|
177
|
+
groupRemoteDiffers = (0, planCompare_2.remoteDiffersFromDesired)(liveGroupAttrs, desiredDefinition);
|
|
129
178
|
if (event.triggers.length > 0) {
|
|
130
179
|
const desiredApis = new Map(event.triggers.map((trigger) => {
|
|
131
180
|
const apiName = buildDesiredTriggerApiName(event, trigger, context.stage);
|
|
@@ -169,19 +218,116 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
169
218
|
}
|
|
170
219
|
}
|
|
171
220
|
}
|
|
172
|
-
|
|
221
|
+
const effectiveChanged = domainRemoved ||
|
|
222
|
+
logRemoved ||
|
|
223
|
+
(certificateRemoved && !domainPlan?.certificateVerified) ||
|
|
224
|
+
(0, planCompare_1.definitionsDiffer)((0, planCompare_2.mergeLiveBefore)(currentDefinition, liveGroupAttrs ?? {}, desiredDefinition), desiredDefinition);
|
|
225
|
+
if (definitionChanged && !effectiveChanged && !triggersDiffer && !domainDiffers) {
|
|
226
|
+
return {
|
|
227
|
+
logicalId,
|
|
228
|
+
action: 'noop',
|
|
229
|
+
resourceType: 'ALIYUN_APIGW',
|
|
230
|
+
stateUpdate: desiredDefinition,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
if (effectiveChanged || groupRemoteDiffers || triggersDiffer || domainDiffers) {
|
|
234
|
+
const certificateIntentChanged = !(0, hashUtils_1.attributesEqual)({
|
|
235
|
+
id: previousDomain?.certificateId ?? null,
|
|
236
|
+
body: previousDomain?.certificateBody ?? null,
|
|
237
|
+
}, {
|
|
238
|
+
id: desiredDefinition.domain?.certificateId ?? null,
|
|
239
|
+
body: desiredDefinition.domain?.certificateBody ?? null,
|
|
240
|
+
});
|
|
241
|
+
const domainUpdates = { ...domainPlan?.updates };
|
|
242
|
+
if (domainPlan && certificateIntentChanged && !domainPlan.certificateVerified) {
|
|
243
|
+
Object.keys(domainPlan.after).forEach((name) => {
|
|
244
|
+
if (domainPlan.before[name].certificateFingerprint !== undefined)
|
|
245
|
+
return;
|
|
246
|
+
domainUpdates[name] = {
|
|
247
|
+
exists: domainPlan.before[name].exists === true,
|
|
248
|
+
binding: domainPlan.updates[name]?.binding ?? false,
|
|
249
|
+
certificate: true,
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const domainProtocolChanged = !(0, hashUtils_1.attributesEqual)({ protocol: previousDomain?.protocol ?? 'HTTP' }, { protocol: desiredDefinition.domain?.protocol ?? 'HTTP' });
|
|
254
|
+
const bindingIntentChanged = domainProtocolChanged ||
|
|
255
|
+
!(0, hashUtils_1.attributesEqual)({ name: previousDomain?.domainName, www: previousDomain?.wwwBindApex ?? false }, {
|
|
256
|
+
name: desiredDefinition.domain?.domainName,
|
|
257
|
+
www: desiredDefinition.domain?.wwwBindApex ?? false,
|
|
258
|
+
});
|
|
259
|
+
if (domainPlan && bindingIntentChanged) {
|
|
260
|
+
Object.keys(domainPlan.after).forEach((name) => {
|
|
261
|
+
if (domainPlan.before[name].redirectToHttps === undefined) {
|
|
262
|
+
domainUpdates[name] = {
|
|
263
|
+
exists: domainPlan.before[name].exists === true,
|
|
264
|
+
binding: true,
|
|
265
|
+
certificate: domainUpdates[name]?.certificate ?? false,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const before = liveGroupAttrs
|
|
271
|
+
? (0, planCompare_2.mergeLiveBefore)(currentDefinition, liveGroupAttrs, desiredDefinition)
|
|
272
|
+
: (0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition);
|
|
273
|
+
const after = (0, planCompare_1.managedDefinition)(desiredDefinition);
|
|
274
|
+
if (domainRemoved || certificateRemoved)
|
|
275
|
+
before.domain = currentDefinition.domain;
|
|
276
|
+
if (certificateRemoved)
|
|
277
|
+
after.domain = desiredDefinition.domain;
|
|
278
|
+
if (logRemoved)
|
|
279
|
+
before.log = currentDefinition.log;
|
|
280
|
+
const revertKeys = [
|
|
281
|
+
...(0, planCompare_2.computeRevertKeys)(currentDefinition, liveGroupAttrs ?? {}, desiredDefinition),
|
|
282
|
+
...(domainPlan &&
|
|
283
|
+
(0, hashUtils_1.attributesEqual)({ domain: currentDefinition.domain ?? null }, { domain: desiredDefinition.domain })
|
|
284
|
+
? (0, planCompare_2.computeRevertKeys)({ domainBindings: domainPlan.after }, { domainBindings: domainPlan.before }, { domainBindings: domainPlan.after })
|
|
285
|
+
: []),
|
|
286
|
+
];
|
|
173
287
|
return {
|
|
174
288
|
logicalId,
|
|
175
289
|
action: 'update',
|
|
176
290
|
resourceType: 'ALIYUN_APIGW',
|
|
291
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
177
292
|
changes: {
|
|
178
|
-
before:
|
|
179
|
-
|
|
180
|
-
: currentDefinition,
|
|
181
|
-
after: desiredDefinition,
|
|
293
|
+
before: { ...before, ...(domainPlan ? { domainBindings: domainPlan.before } : {}) },
|
|
294
|
+
after: { ...after, ...(domainPlan ? { domainBindings: domainPlan.after } : {}) },
|
|
182
295
|
},
|
|
183
|
-
|
|
184
|
-
|
|
296
|
+
...(liveGroupAttrs &&
|
|
297
|
+
desiredDefinition.domain?.cdnEnabled !== true &&
|
|
298
|
+
previousDomain?.cdnEnabled !== true
|
|
299
|
+
? {
|
|
300
|
+
gatewayUpdate: {
|
|
301
|
+
group: (0, planCompare_1.definitionsDiffer)(liveGroupAttrs, groupDefinition),
|
|
302
|
+
apis: triggersDiffer ||
|
|
303
|
+
(0, planCompare_1.definitionsDiffer)(currentDefinition, {
|
|
304
|
+
triggers: desiredDefinition.triggers,
|
|
305
|
+
}) ||
|
|
306
|
+
domainProtocolChanged,
|
|
307
|
+
logging: logRemoved ||
|
|
308
|
+
(0, planCompare_1.definitionsDiffer)(currentDefinition, { log: desiredDefinition.log }) ||
|
|
309
|
+
(0, planCompare_2.remoteDiffersFromDesired)(liveGroupAttrs, {
|
|
310
|
+
log: desiredDefinition.log,
|
|
311
|
+
}),
|
|
312
|
+
domains: domainUpdates,
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
: {}),
|
|
316
|
+
...((0, planCompare_2.remoteDiffersFromDesired)(liveGroupAttrs ?? {}, currentDefinition) ||
|
|
317
|
+
(domainDiffers &&
|
|
318
|
+
!(0, planCompare_1.definitionsDiffer)({ domain: currentDefinition.domain }, { domain: desiredDefinition.domain })) ||
|
|
319
|
+
(triggersDiffer &&
|
|
320
|
+
!(0, planCompare_1.definitionsDiffer)(currentDefinition, { triggers: desiredDefinition.triggers }))
|
|
321
|
+
? { drifted: true }
|
|
322
|
+
: {}),
|
|
323
|
+
...(triggersDiffer || domainDiffers
|
|
324
|
+
? {
|
|
325
|
+
driftReasons: [
|
|
326
|
+
...(triggersDiffer ? ['PLAN_DRIFT_TRIGGERS'] : []),
|
|
327
|
+
...(domainDiffers ? ['PLAN_DRIFT_EVENT_DOMAIN'] : []),
|
|
328
|
+
],
|
|
329
|
+
}
|
|
330
|
+
: {}),
|
|
185
331
|
};
|
|
186
332
|
}
|
|
187
333
|
return { logicalId, action: 'noop', resourceType: 'ALIYUN_APIGW' };
|
|
@@ -191,13 +337,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
191
337
|
logicalId,
|
|
192
338
|
error: error instanceof Error ? error.message : String(error),
|
|
193
339
|
}));
|
|
194
|
-
|
|
195
|
-
logicalId,
|
|
196
|
-
action: 'create',
|
|
197
|
-
resourceType: 'ALIYUN_APIGW',
|
|
198
|
-
changes: { before: currentState.definition, after: desiredDefinition },
|
|
199
|
-
drifted: true,
|
|
200
|
-
};
|
|
340
|
+
throw error;
|
|
201
341
|
}
|
|
202
342
|
});
|
|
203
343
|
// Find resources in state that are no longer in config
|