File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -139,23 +139,35 @@ class Apigw {
139139 apiInputs . requestParameters = endpoint . param
140140 }
141141
142- if ( ! endpoint . apiId ) {
142+ let exist = false
143+ if ( endpoint . apiId ) {
144+ try {
145+ const detail = await this . request ( {
146+ Action : 'DescribeApi' ,
147+ serviceId : serviceId ,
148+ apiId : endpoint . apiId
149+ } )
150+ if ( detail && detail . apiId ) {
151+ exist = true
152+ console . debug ( `Updating api with api id ${ endpoint . apiId } .` )
153+ await this . request ( {
154+ Action : 'ModifyApi' ,
155+ apiId : endpoint . apiId ,
156+ ...apiInputs
157+ } )
158+ output . apiId = endpoint . apiId
159+ console . debug ( `Service with id ${ output . apiId } updated.` )
160+ }
161+ } catch ( e ) { }
162+ }
163+ if ( ! exist ) {
143164 const { apiId } = await this . request ( {
144165 Action : 'CreateApi' ,
145166 ...apiInputs
146167 } )
147168 output . apiId = apiId
148169 output . created = true
149170 console . debug ( `API with id ${ output . apiId } created.` )
150- } else {
151- console . debug ( `Updating api with api id ${ endpoint . apiId } .` )
152- await this . request ( {
153- Action : 'ModifyApi' ,
154- apiId : endpoint . apiId ,
155- ...apiInputs
156- } )
157- output . apiId = endpoint . apiId
158- console . debug ( `Service with id ${ output . apiId } updated.` )
159171 }
160172
161173 const { internalDomain } = await this . request ( {
You can’t perform that action at this time.
0 commit comments