@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
|
@@ -369,10 +369,30 @@ const buildDomainBindingConfig = async (domain, groupId, serviceName, eventKey,
|
|
|
369
369
|
return {
|
|
370
370
|
groupId,
|
|
371
371
|
domainName: domain.domain_name,
|
|
372
|
-
isHttpRedirectToHttps: protocolConfig.isHttpRedirectToHttps,
|
|
372
|
+
isHttpRedirectToHttps: protocolConfig.isHttpRedirectToHttps ?? false,
|
|
373
373
|
...certConfig,
|
|
374
374
|
};
|
|
375
375
|
};
|
|
376
|
+
const removeOwnedDomainDns = async (client, state, logicalId, domains) => Object.entries(state.resources)
|
|
377
|
+
.filter(([key, resource]) => key.startsWith(`${logicalId}.dns_`) &&
|
|
378
|
+
resource.mode === 'managed' &&
|
|
379
|
+
domains.includes(String(resource.definition.domainName)) &&
|
|
380
|
+
resource.instances.every((instance) => (instance.type === 'CNAME' || instance.type === 'TXT') &&
|
|
381
|
+
instance.id &&
|
|
382
|
+
instance.id !== 'existing'))
|
|
383
|
+
.reduce(async (previous, [key, resource]) => {
|
|
384
|
+
const current = await previous;
|
|
385
|
+
await Promise.all(resource.instances.map(async (instance) => {
|
|
386
|
+
try {
|
|
387
|
+
await client.dns.deleteDomainRecord(instance.id);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
if (!(0, aliyunClient_1.isApigwNotFoundError)(error))
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
393
|
+
}));
|
|
394
|
+
return (0, stateManager_1.removeResource)(current, key);
|
|
395
|
+
}, Promise.resolve(state));
|
|
376
396
|
const createApigwResource = async (context, event, serviceName, resolveRoleArn, state) => {
|
|
377
397
|
const logicalId = `events.${event.key}`;
|
|
378
398
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
@@ -596,7 +616,7 @@ const readApigwResourceByName = async (context, groupName) => {
|
|
|
596
616
|
return await client.apigw.findApiGroupByName(groupName);
|
|
597
617
|
};
|
|
598
618
|
exports.readApigwResourceByName = readApigwResourceByName;
|
|
599
|
-
const updateApigwResource = async (context, event, serviceName, resolveRoleArn, state) => {
|
|
619
|
+
const updateApigwResource = async (context, event, serviceName, resolveRoleArn, state, options) => {
|
|
600
620
|
const logicalId = `events.${event.key}`;
|
|
601
621
|
const existingState = (0, stateManager_1.getResource)(state, logicalId);
|
|
602
622
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
@@ -695,7 +715,8 @@ const updateApigwResource = async (context, event, serviceName, resolveRoleArn,
|
|
|
695
715
|
}
|
|
696
716
|
}
|
|
697
717
|
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage);
|
|
698
|
-
|
|
718
|
+
if (options?.scope?.group !== false)
|
|
719
|
+
await client.apigw.updateApiGroup(groupId, groupConfig);
|
|
699
720
|
const groupInfo = await client.apigw.getApiGroup(groupId);
|
|
700
721
|
if (!groupInfo) {
|
|
701
722
|
throw new Error(lang_1.lang.__('APIGW_GROUP_INFO_AFTER_UPDATE_FAILED', { error: groupId }));
|
|
@@ -704,56 +725,64 @@ const updateApigwResource = async (context, event, serviceName, resolveRoleArn,
|
|
|
704
725
|
buildApigwGroupInstanceFromProvider(groupInfo, context.stage),
|
|
705
726
|
];
|
|
706
727
|
const existingApis = existingInstances.filter((i) => i.type === 'ALIYUN_APIGW_API');
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
let apiId;
|
|
716
|
-
if (existingApi) {
|
|
717
|
-
apiId = existingApi.id;
|
|
718
|
-
await client.apigw.updateApi(apiId, apiConfig);
|
|
719
|
-
}
|
|
720
|
-
else {
|
|
721
|
-
apiId = await client.apigw.createApi(apiConfig);
|
|
722
|
-
}
|
|
723
|
-
const apiInfo = await client.apigw.getApi(groupId, apiId);
|
|
724
|
-
if (apiInfo) {
|
|
725
|
-
instances.push(buildApigwApiInstanceFromProvider(apiInfo, context.stage, groupId));
|
|
726
|
-
}
|
|
727
|
-
const deploymentConfig = {
|
|
728
|
-
groupId,
|
|
729
|
-
apiId,
|
|
730
|
-
stageName: 'RELEASE',
|
|
731
|
-
description: `${serviceName} API deployment for ${trigger.method} ${trigger.path}`,
|
|
732
|
-
};
|
|
733
|
-
await client.apigw.deployApi(deploymentConfig);
|
|
734
|
-
instances.push(buildApigwDeploymentInstance(groupId, apiId, 'RELEASE', context.stage));
|
|
735
|
-
}
|
|
736
|
-
for (const existingApi of existingApis) {
|
|
737
|
-
const apiInfo = await client.apigw.getApi(groupId, existingApi.id);
|
|
738
|
-
if (apiInfo) {
|
|
739
|
-
const isNeeded = event.triggers.some((t) => {
|
|
740
|
-
const expectedName = (0, apigwTypes_1.triggerToApigwApiConfig)(event, t, groupId, serviceName, context.region, context.stage, roleArnFor(String(t.backend))).apiName;
|
|
741
|
-
return apiInfo.apiName === expectedName;
|
|
728
|
+
if (options?.scope?.apis !== false) {
|
|
729
|
+
const neededApiKeys = new Set();
|
|
730
|
+
for (const trigger of event.triggers) {
|
|
731
|
+
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, groupId, serviceName, context.region, context.stage, roleArnFor(String(trigger.backend)));
|
|
732
|
+
const apiKey = (0, apigwTypes_1.generateApiKey)(trigger.method, trigger.path);
|
|
733
|
+
neededApiKeys.add(apiKey);
|
|
734
|
+
const existingApi = existingApis.find((a) => {
|
|
735
|
+
return a.id && a.apiName === apiConfig.apiName;
|
|
742
736
|
});
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
737
|
+
let apiId;
|
|
738
|
+
if (existingApi) {
|
|
739
|
+
apiId = existingApi.id;
|
|
740
|
+
await client.apigw.updateApi(apiId, apiConfig);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
apiId = await client.apigw.createApi(apiConfig);
|
|
744
|
+
}
|
|
745
|
+
const apiInfo = await client.apigw.getApi(groupId, apiId);
|
|
746
|
+
if (apiInfo) {
|
|
747
|
+
instances.push(buildApigwApiInstanceFromProvider(apiInfo, context.stage, groupId));
|
|
748
|
+
}
|
|
749
|
+
const deploymentConfig = {
|
|
750
|
+
groupId,
|
|
751
|
+
apiId,
|
|
752
|
+
stageName: 'RELEASE',
|
|
753
|
+
description: `${serviceName} API deployment for ${trigger.method} ${trigger.path}`,
|
|
754
|
+
};
|
|
755
|
+
await client.apigw.deployApi(deploymentConfig);
|
|
756
|
+
instances.push(buildApigwDeploymentInstance(groupId, apiId, 'RELEASE', context.stage));
|
|
757
|
+
}
|
|
758
|
+
for (const existingApi of existingApis) {
|
|
759
|
+
const apiInfo = await client.apigw.getApi(groupId, existingApi.id);
|
|
760
|
+
if (apiInfo) {
|
|
761
|
+
const isNeeded = event.triggers.some((t) => {
|
|
762
|
+
const expectedName = (0, apigwTypes_1.triggerToApigwApiConfig)(event, t, groupId, serviceName, context.region, context.stage, roleArnFor(String(t.backend))).apiName;
|
|
763
|
+
return apiInfo.apiName === expectedName;
|
|
764
|
+
});
|
|
765
|
+
if (!isNeeded) {
|
|
766
|
+
try {
|
|
767
|
+
await client.apigw.abolishApi(groupId, existingApi.id, 'RELEASE');
|
|
768
|
+
}
|
|
769
|
+
catch {
|
|
770
|
+
// API might not be deployed
|
|
771
|
+
}
|
|
772
|
+
await client.apigw.deleteApi(groupId, existingApi.id);
|
|
749
773
|
}
|
|
750
|
-
await client.apigw.deleteApi(groupId, existingApi.id);
|
|
751
774
|
}
|
|
752
775
|
}
|
|
753
776
|
}
|
|
777
|
+
else {
|
|
778
|
+
instances.push(...existingInstances.filter((instance) => instance.type === 'ALIYUN_APIGW_API' || instance.type === 'ALIYUN_APIGW_DEPLOYMENT'));
|
|
779
|
+
}
|
|
754
780
|
const logSnapshot = (0, apigwTypes_1.buildEventLogSnapshot)(event, context);
|
|
755
781
|
let sharedProjectState;
|
|
756
|
-
if (
|
|
782
|
+
if (options?.scope?.logging === false) {
|
|
783
|
+
instances.push(...existingInstances.filter((instance) => instance.type === 'ALIYUN_APIGW_LOG_CONFIG'));
|
|
784
|
+
}
|
|
785
|
+
else if (event.log) {
|
|
757
786
|
const logResult = await ensureGatewayLogConfig(context, client, state);
|
|
758
787
|
if (logResult?.sharedProject) {
|
|
759
788
|
sharedProjectState = logResult.sharedProject;
|
|
@@ -782,97 +811,108 @@ const updateApigwResource = async (context, event, serviceName, resolveRoleArn,
|
|
|
782
811
|
Object.keys(state.resources ?? {}).some((k) => k.startsWith(`${logicalId}.dns_`) &&
|
|
783
812
|
k !== `${logicalId}.dns_verification` &&
|
|
784
813
|
k !== `${logicalId}.dns_txt_verification`);
|
|
785
|
-
|
|
814
|
+
const skipDomainBinding = !options?.repairDomain &&
|
|
815
|
+
previousDomainDef &&
|
|
786
816
|
desiredDomainDef &&
|
|
787
817
|
hasBoundDomains &&
|
|
788
|
-
(0, hashUtils_1.attributesEqual)(previousDomainDef, desiredDomainDef)
|
|
818
|
+
(0, hashUtils_1.attributesEqual)(previousDomainDef, desiredDomainDef);
|
|
819
|
+
if (skipDomainBinding)
|
|
789
820
|
logger_1.logger.info(lang_1.lang.__('APIGW_DOMAIN_UNCHANGED_SKIP'));
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
const primaryDomain = event.domain.domain_name;
|
|
804
|
-
const wwwBindApex = event.domain.www_bind_apex === true;
|
|
805
|
-
const wwwDomain = wwwBindApex ? (0, domainUtils_1.deriveWwwDomain)(primaryDomain) : null;
|
|
806
|
-
const isCdnEnabled = getIsCdnEnabled(event);
|
|
807
|
-
const previousWwwBindApex = previousDomainDef?.wwwBindApex === true;
|
|
808
|
-
const previousDomainName = previousDomainDef?.domainName;
|
|
809
|
-
const previousCdnEnabled = previousDomainDef?.cdnEnabled === true;
|
|
810
|
-
const previousTrackedDomains = getApigwTrackedDomains(previousDomainName, previousWwwBindApex);
|
|
811
|
-
const originDomain = groupInfo.subDomain;
|
|
812
|
-
if (isCdnEnabled && !originDomain) {
|
|
813
|
-
throw new Error(lang_1.lang.__('APIGW_GROUP_NO_SUBDOMAIN_CDN', { groupName: groupId }));
|
|
814
|
-
}
|
|
815
|
-
const domainConfig = await buildDomainBindingConfig(event.domain, groupId, serviceName, event.key, context.stage, client);
|
|
816
|
-
if (isCdnEnabled) {
|
|
817
|
-
const desiredDomains = [primaryDomain, ...(wwwDomain ? [wwwDomain] : [])];
|
|
818
|
-
const cdnDomainsToCleanup = previousCdnEnabled
|
|
819
|
-
? previousTrackedDomains.filter((domain) => !desiredDomains.includes(domain))
|
|
820
|
-
: [];
|
|
821
|
-
if (cdnDomainsToCleanup.length > 0) {
|
|
822
|
-
await cleanupApigwCdnResources(client, existingInstances, cdnDomainsToCleanup);
|
|
821
|
+
if (!skipDomainBinding) {
|
|
822
|
+
const primaryDomain = event.domain.domain_name;
|
|
823
|
+
const wwwBindApex = event.domain.www_bind_apex === true;
|
|
824
|
+
const wwwDomain = wwwBindApex ? (0, domainUtils_1.deriveWwwDomain)(primaryDomain) : null;
|
|
825
|
+
const isCdnEnabled = getIsCdnEnabled(event);
|
|
826
|
+
const previousWwwBindApex = previousDomainDef?.wwwBindApex === true;
|
|
827
|
+
const previousDomainName = previousDomainDef?.domainName;
|
|
828
|
+
const previousCdnEnabled = previousDomainDef?.cdnEnabled === true;
|
|
829
|
+
const previousTrackedDomains = getApigwTrackedDomains(previousDomainName, previousWwwBindApex);
|
|
830
|
+
const originDomain = groupInfo.subDomain;
|
|
831
|
+
if (isCdnEnabled && !originDomain) {
|
|
832
|
+
throw new Error(lang_1.lang.__('APIGW_GROUP_NO_SUBDOMAIN_CDN', { groupName: groupId }));
|
|
823
833
|
}
|
|
824
|
-
await
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
};
|
|
837
|
-
await updateApigwCdnDistribution(context, client, event, wwwDomain, originDomain, existingInstances, instances, {
|
|
838
|
-
certificateBody: wwwDomainConfig.certificateBody,
|
|
839
|
-
certificatePrivateKey: wwwDomainConfig.certificatePrivateKey,
|
|
834
|
+
const domainConfig = await buildDomainBindingConfig(event.domain, groupId, serviceName, event.key, context.stage, client);
|
|
835
|
+
if (isCdnEnabled) {
|
|
836
|
+
const desiredDomains = [primaryDomain, ...(wwwDomain ? [wwwDomain] : [])];
|
|
837
|
+
const cdnDomainsToCleanup = previousCdnEnabled
|
|
838
|
+
? previousTrackedDomains.filter((domain) => !desiredDomains.includes(domain))
|
|
839
|
+
: [];
|
|
840
|
+
if (cdnDomainsToCleanup.length > 0) {
|
|
841
|
+
await cleanupApigwCdnResources(client, existingInstances, cdnDomainsToCleanup);
|
|
842
|
+
}
|
|
843
|
+
await updateApigwCdnDistribution(context, client, event, primaryDomain, originDomain, existingInstances, instances, {
|
|
844
|
+
certificateBody: domainConfig.certificateBody,
|
|
845
|
+
certificatePrivateKey: domainConfig.certificatePrivateKey,
|
|
840
846
|
});
|
|
847
|
+
if (wwwDomain) {
|
|
848
|
+
logger_1.logger.info(lang_1.lang.__('APIGW_BINDING_DOMAIN', { domain: wwwDomain }));
|
|
849
|
+
const wwwDomainConfig = {
|
|
850
|
+
...domainConfig,
|
|
851
|
+
domainName: wwwDomain,
|
|
852
|
+
certificateName: domainConfig.certificateName
|
|
853
|
+
? `${domainConfig.certificateName}-www`
|
|
854
|
+
: undefined,
|
|
855
|
+
};
|
|
856
|
+
await updateApigwCdnDistribution(context, client, event, wwwDomain, originDomain, existingInstances, instances, {
|
|
857
|
+
certificateBody: wwwDomainConfig.certificateBody,
|
|
858
|
+
certificatePrivateKey: wwwDomainConfig.certificatePrivateKey,
|
|
859
|
+
});
|
|
860
|
+
}
|
|
841
861
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
862
|
+
else {
|
|
863
|
+
if (previousCdnEnabled && previousTrackedDomains.length > 0) {
|
|
864
|
+
await cleanupApigwCdnResources(client, existingInstances, previousTrackedDomains);
|
|
865
|
+
}
|
|
866
|
+
const reconcileDomain = async (config) => {
|
|
867
|
+
const update = options?.scope?.domains[config.domainName];
|
|
868
|
+
if (options?.scope && !update)
|
|
869
|
+
return;
|
|
870
|
+
if (update?.exists && !update.binding && update.certificate) {
|
|
871
|
+
if (config.certificateBody)
|
|
872
|
+
await client.apigw.setDomainCertificate(config);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
state = update?.exists
|
|
876
|
+
? await client.apigw.bindCustomDomain(config, state, logicalId, true)
|
|
877
|
+
: await client.apigw.bindCustomDomain(config, state, logicalId);
|
|
878
|
+
}
|
|
879
|
+
if (!config.certificateBody &&
|
|
880
|
+
(previousDomainDef?.certificateId || previousDomainDef?.certificateBody)) {
|
|
881
|
+
await client.apigw.deleteDomainCertificate(groupId, config.domainName);
|
|
882
|
+
}
|
|
856
883
|
};
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
884
|
+
await reconcileDomain(domainConfig);
|
|
885
|
+
if (wwwDomain) {
|
|
886
|
+
const wwwDomainConfig = {
|
|
887
|
+
...domainConfig,
|
|
888
|
+
domainName: wwwDomain,
|
|
889
|
+
certificateName: domainConfig.certificateName
|
|
890
|
+
? `${domainConfig.certificateName}-www`
|
|
891
|
+
: undefined,
|
|
892
|
+
};
|
|
893
|
+
await reconcileDomain(wwwDomainConfig);
|
|
865
894
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
895
|
+
}
|
|
896
|
+
if (previousWwwBindApex && previousDomainName) {
|
|
897
|
+
const previousWwwDomain = (0, domainUtils_1.deriveWwwDomain)(previousDomainName);
|
|
898
|
+
if (previousWwwDomain && previousWwwDomain !== wwwDomain && !previousCdnEnabled) {
|
|
899
|
+
try {
|
|
900
|
+
await client.apigw.unbindCustomDomain(groupId, previousWwwDomain);
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
if (!(0, aliyunClient_1.isApigwNotFoundError)(error)) {
|
|
904
|
+
throw error;
|
|
905
|
+
}
|
|
906
|
+
logger_1.logger.warn(lang_1.lang.__('APIGW_WWW_DOMAIN_UNBIND_FAILED', {
|
|
907
|
+
domain: previousWwwDomain,
|
|
908
|
+
error: String(error),
|
|
909
|
+
}));
|
|
869
910
|
}
|
|
870
|
-
logger_1.logger.warn(lang_1.lang.__('APIGW_WWW_DOMAIN_UNBIND_FAILED', {
|
|
871
|
-
domain: previousWwwDomain,
|
|
872
|
-
error: String(error),
|
|
873
|
-
}));
|
|
874
911
|
}
|
|
875
912
|
}
|
|
913
|
+
if (previousDomainName && previousDomainName !== primaryDomain && !previousCdnEnabled) {
|
|
914
|
+
await client.apigw.unbindCustomDomain(groupId, previousDomainName);
|
|
915
|
+
}
|
|
876
916
|
}
|
|
877
917
|
}
|
|
878
918
|
else {
|
|
@@ -913,6 +953,12 @@ const updateApigwResource = async (context, event, serviceName, resolveRoleArn,
|
|
|
913
953
|
}
|
|
914
954
|
}
|
|
915
955
|
}
|
|
956
|
+
const previousDomain = existingState?.definition.domain;
|
|
957
|
+
const desiredNames = event.domain
|
|
958
|
+
? getApigwTrackedDomains(String(event.domain.domain_name), event.domain.www_bind_apex === true)
|
|
959
|
+
: [];
|
|
960
|
+
const removedDomains = getApigwTrackedDomains(previousDomain?.domainName, previousDomain?.wwwBindApex === true).filter((name) => !desiredNames.includes(name));
|
|
961
|
+
state = await removeOwnedDomainDns(client, state, logicalId, removedDomains);
|
|
916
962
|
const groupDefinition = (0, apigwTypes_1.extractApigwGroupDefinition)(groupConfig);
|
|
917
963
|
const resourceState = {
|
|
918
964
|
mode: 'managed',
|
|
@@ -239,17 +239,13 @@ const extractEventDomainDefinition = (domain) => {
|
|
|
239
239
|
certificateId: domain.certificate_id ?? null,
|
|
240
240
|
certificateBody: domain.certificate_body ?? null,
|
|
241
241
|
certificatePrivateKey: domain.certificate_private_key ? '(managed)' : null,
|
|
242
|
-
protocol: domain.protocol ??
|
|
242
|
+
protocol: domain.protocol ?? 'HTTP',
|
|
243
243
|
};
|
|
244
244
|
const cdnConfig = getDomainCdnConfig(domain);
|
|
245
245
|
if (cdnConfig?.enabled === true) {
|
|
246
246
|
definition.cdnEnabled = true;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
if (cdnConfig.scope != null) {
|
|
251
|
-
definition.cdnScope = cdnConfig.scope;
|
|
252
|
-
}
|
|
247
|
+
definition.cdnType = cdnConfig.cdn_type ?? 'web';
|
|
248
|
+
definition.cdnScope = cdnConfig.scope ?? 'global';
|
|
253
249
|
if (cdnConfig.cache_ttl != null) {
|
|
254
250
|
definition.cdnCacheTtl = cdnConfig.cache_ttl;
|
|
255
251
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deployAliyunStack = exports.buildRoleArnResolver = void 0;
|
|
4
|
+
const refreshPlanner_1 = require("../../common/refreshPlanner");
|
|
4
5
|
const common_1 = require("../../common");
|
|
5
6
|
const lang_1 = require("../../lang");
|
|
6
7
|
const fc3Planner_1 = require("./fc3Planner");
|
|
@@ -110,6 +111,7 @@ const deployAliyunStack = async (iac, backend, approvedPlan) => {
|
|
|
110
111
|
...tablePlan.items,
|
|
111
112
|
...eventPlan.items,
|
|
112
113
|
];
|
|
114
|
+
state = (0, refreshPlanner_1.applyPlanStateUpdates)(state, allItems);
|
|
113
115
|
// Build dependency graph for validation (e.g. cycle detection) and logging
|
|
114
116
|
const dependencyInfo = (0, common_1.getDependencyInfo)(allItems);
|
|
115
117
|
if (dependencyInfo.cycleError) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.cloudEsToDefinition = exports.extractEsDefinition = exports.databaseToEsConfig = void 0;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
4
8
|
const lang_1 = require("../../lang");
|
|
5
9
|
// Map database versions to ES versions
|
|
6
10
|
const esVersionMap = new Map([
|
|
@@ -88,10 +92,10 @@ const extractEsDefinition = (config) => {
|
|
|
88
92
|
appVersion: config.appVersion,
|
|
89
93
|
authentication: config.authentication
|
|
90
94
|
? {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
fingerprint: node_crypto_1.default
|
|
96
|
+
.createHash('sha256')
|
|
97
|
+
.update(JSON.stringify(config.authentication))
|
|
98
|
+
.digest('hex'),
|
|
95
99
|
}
|
|
96
100
|
: null,
|
|
97
101
|
quotaInfo: config.quotaInfo
|
|
@@ -13,11 +13,15 @@ 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, drifted) => {
|
|
16
|
+
const executeUpdateAction = async (context, fn, currentState, drifted, driftReasons) => {
|
|
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
19
|
// re-push even when state-vs-desired sees no change.
|
|
20
|
-
const newState = await (0, fc3Resource_1.updateResource)(context, fn, currentState, {
|
|
20
|
+
const newState = await (0, fc3Resource_1.updateResource)(context, fn, currentState, {
|
|
21
|
+
force: drifted === true,
|
|
22
|
+
...(driftReasons?.includes('PLAN_DRIFT_HTTP_TRIGGER') ? { repairHttp: true } : {}),
|
|
23
|
+
...(driftReasons?.includes('PLAN_DRIFT_FUNCTION_DOMAIN') ? { repairDomain: true } : {}),
|
|
24
|
+
});
|
|
21
25
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'function', name: fn.name }));
|
|
22
26
|
return newState;
|
|
23
27
|
};
|
|
@@ -44,7 +48,7 @@ const executeSingleItem = async (context, item, functionsMap, currentState) => {
|
|
|
44
48
|
if (!fn) {
|
|
45
49
|
throw new Error(lang_1.lang.__('RESOURCE_FUNCTION_NOT_FOUND', { logicalId: item.logicalId }));
|
|
46
50
|
}
|
|
47
|
-
return executeUpdateAction(context, fn, currentState, item.drifted);
|
|
51
|
+
return executeUpdateAction(context, fn, currentState, item.drifted, item.driftReasons);
|
|
48
52
|
}
|
|
49
53
|
case 'delete': {
|
|
50
54
|
const state = (0, stateManager_1.getResource)(currentState, item.logicalId);
|