diff --git a/src/modules/apigw/index.ts b/src/modules/apigw/index.ts index fe79ab2..e213ef6 100644 --- a/src/modules/apigw/index.ts +++ b/src/modules/apigw/index.ts @@ -240,6 +240,8 @@ export default class Apigw { oldState = {}, serviceId, isAutoRelease = true, + serviceName, + serviceDesc, } = inputs; inputs.protocols = getProtocolString(inputs.protocols as ('http' | 'https')[]); @@ -248,6 +250,27 @@ export default class Apigw { const detail = await this.service.getById(serviceId); if (detail) { + // 如果 serviceName,serviceDesc,protocols任意字段更新了,则更新服务 + if ( + !(serviceName === detail.ServiceName && serviceDesc === detail.ServiceDesc) && + !(serviceName === undefined && serviceDesc === undefined) + ) { + const apiInputs = { + Action: 'ModifyService' as const, + serviceId, + serviceDesc: serviceDesc || detail.ServiceDesc || undefined, + serviceName: serviceName || detail.ServiceName || undefined, + }; + if (!serviceName) { + delete apiInputs.serviceName; + } + if (!serviceDesc) { + delete apiInputs.serviceDesc; + } + + await this.request(apiInputs); + } + const apiList: ApiEndpoint[] = await this.api.bulkDeploy({ apiList: endpoints, stateList: stateApiList, @@ -269,7 +292,7 @@ export default class Apigw { const outputs: ApigwDeployOutputs = { created: false, serviceId, - serviceName: detail.ServiceName, + serviceName: serviceName || detail.ServiceName, subDomain: subDomain, protocols: inputs.protocols, environment: environment, @@ -291,7 +314,8 @@ export default class Apigw { })); } - return this.formatApigwOutputs(outputs); + // return this.formatApigwOutputs(outputs); + return outputs; } throw new ApiError({ type: 'API_APIGW_DescribeService',