@@ -184,24 +184,33 @@ class ServerlessComponent extends Component {
184184 outputs . templateUrl = CONFIGS . templateUrl
185185 }
186186
187- const deployTasks = [ this . deployFunction ( credentials , functionConf , regionList , outputs ) ]
187+ let apigwOutputs
188+ const functionOutputs = await this . deployFunction (
189+ credentials ,
190+ functionConf ,
191+ regionList ,
192+ outputs
193+ )
188194 // support apigatewayConf.isDisabled
189195 if ( apigatewayConf . isDisabled !== true ) {
190- deployTasks . push ( this . deployApigateway ( credentials , apigatewayConf , regionList , outputs ) )
196+ apigwOutputs = await this . deployApigateway ( credentials , apigatewayConf , regionList , outputs )
191197 } else {
192198 this . state . apigwDisabled = true
193199 }
194- const [ functionOutputs , apigwOutputs = { } ] = await Promise . all ( deployTasks )
195200
196201 // optimize outputs for one region
197202 if ( regionList . length === 1 ) {
198203 const [ oneRegion ] = regionList
199204 outputs . region = oneRegion
200- outputs [ 'apigw' ] = apigwOutputs [ oneRegion ]
201205 outputs [ 'scf' ] = functionOutputs [ oneRegion ]
206+ if ( apigwOutputs ) {
207+ outputs [ 'apigw' ] = apigwOutputs [ oneRegion ]
208+ }
202209 } else {
203- outputs [ 'apigw' ] = apigwOutputs
204210 outputs [ 'scf' ] = functionOutputs
211+ if ( apigwOutputs ) {
212+ outputs [ 'apigw' ] = apigwOutputs
213+ }
205214 }
206215
207216 this . state . region = regionList [ 0 ]
@@ -226,10 +235,6 @@ class ServerlessComponent extends Component {
226235 const scf = new Scf ( credentials , curRegion )
227236 const apigw = new Apigw ( credentials , curRegion )
228237 const handler = async ( ) => {
229- await scf . remove ( {
230- functionName : curState . functionName ,
231- namespace : curState . namespace
232- } )
233238 // if disable apigw, no need to remove
234239 if ( state . apigwDisabled !== true ) {
235240 await apigw . remove ( {
@@ -240,6 +245,10 @@ class ServerlessComponent extends Component {
240245 customDomains : curState . customDomains
241246 } )
242247 }
248+ await scf . remove ( {
249+ functionName : curState . functionName ,
250+ namespace : curState . namespace
251+ } )
243252 }
244253 removeHandlers . push ( handler ( ) )
245254 }
0 commit comments