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 {
139
139
apiInputs . requestParameters = endpoint . param
140
140
}
141
141
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 ) {
143
164
const { apiId } = await this . request ( {
144
165
Action : 'CreateApi' ,
145
166
...apiInputs
146
167
} )
147
168
output . apiId = apiId
148
169
output . created = true
149
170
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.` )
159
171
}
160
172
161
173
const { internalDomain } = await this . request ( {
You can’t perform that action at this time.
0 commit comments