Skip to content

Commit b3c6964

Browse files
committed
fix: optimize outputs for one region
1 parent f66d8d8 commit b3c6964

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

example/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ inputs:
1414
protocols:
1515
- http
1616
- https
17-
environment: test
17+
environment: release

src/serverless.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,21 @@ class Express extends Component {
184184
this.deployFunction(credentials, functionConf, regionList, outputs)
185185
])
186186

187-
outputs['apigw'] = apigwOutputs
188-
outputs['scf'] = functionOutputs
187+
// optimize outputs for one region
188+
if (regionList.length === 1) {
189+
const [oneRegion] = regionList
190+
outputs.region = oneRegion
191+
outputs['apigw'] = apigwOutputs[oneRegion]
192+
outputs['scf'] = functionOutputs[oneRegion]
193+
} else {
194+
outputs['apigw'] = apigwOutputs
195+
outputs['scf'] = functionOutputs
196+
}
189197

190198
// 云解析遇到等API网关部署完成才可以继续部署
191-
outputs['cns'] = await this.deployCns(credentials, cnsConf, regionList, apigwOutputs)
199+
if (cnsConf.length > 0) {
200+
outputs['cns'] = await this.deployCns(credentials, cnsConf, regionList, apigwOutputs)
201+
}
192202

193203
this.state.region = regionList[0]
194204
this.state.regionList = regionList

0 commit comments

Comments
 (0)