@@ -178,30 +178,24 @@ export class RestApi extends Resource implements IRestApi {
178
178
public readonly restApiRootResourceId : string ;
179
179
180
180
/**
181
- * API Gateway deployment that represents the latest changes of the API.
182
- * This resource will be automatically updated every time the REST API model changes.
183
- * This will be undefined if `deploy` is false.
181
+ * Represents the root resource ("/") of this API. Use it to define the API model:
182
+ *
183
+ * api.root.addMethod('ANY', redirectToHomePage); // "ANY /"
184
+ * api.root.addResource('friends').addMethod('GET', getFriendsHandler); // "GET /friends"
185
+ *
184
186
*/
185
- public latestDeployment ?: Deployment ;
187
+ public readonly root : IResource ;
186
188
187
189
/**
188
190
* API Gateway stage that points to the latest deployment (if defined).
189
191
*
190
192
* If `deploy` is disabled, you will need to explicitly assign this value in order to
191
193
* set up integrations.
192
194
*/
193
- public deploymentStage ?: Stage ;
194
-
195
- /**
196
- * Represents the root resource ("/") of this API. Use it to define the API model:
197
- *
198
- * api.root.addMethod('ANY', redirectToHomePage); // "ANY /"
199
- * api.root.addResource('friends').addMethod('GET', getFriendsHandler); // "GET /friends"
200
- *
201
- */
202
- public readonly root : IResource ;
195
+ public deploymentStage : Stage ;
203
196
204
197
private readonly methods = new Array < Method > ( ) ;
198
+ private _latestDeployment : Deployment | undefined ;
205
199
206
200
constructor ( scope : Construct , id : string , props : RestApiProps = { } ) {
207
201
super ( scope , id ) ;
@@ -231,6 +225,15 @@ export class RestApi extends Resource implements IRestApi {
231
225
this . root = new RootResource ( this , props , resource . attrRootResourceId ) ;
232
226
}
233
227
228
+ /**
229
+ * API Gateway deployment that represents the latest changes of the API.
230
+ * This resource will be automatically updated every time the REST API model changes.
231
+ * This will be undefined if `deploy` is false.
232
+ */
233
+ public get latestDeployment ( ) {
234
+ return this . _latestDeployment ;
235
+ }
236
+
234
237
/**
235
238
* The deployed root URL of this REST API.
236
239
*/
@@ -275,7 +278,7 @@ export class RestApi extends Resource implements IRestApi {
275
278
* @param path The resource path. Must start with '/' (default `*`)
276
279
* @param stage The stage (default `*`)
277
280
*/
278
- public executeApiArn ( method : string = '*' , path : string = '/*' , stage : string = '*' ) {
281
+ public arnForExecuteApi ( method : string = '*' , path : string = '/*' , stage : string = '*' ) {
279
282
if ( ! path . startsWith ( '/' ) ) {
280
283
throw new Error ( `"path" must begin with a "/": '${ path } '` ) ;
281
284
}
@@ -317,7 +320,7 @@ export class RestApi extends Resource implements IRestApi {
317
320
const deploy = props . deploy === undefined ? true : props . deploy ;
318
321
if ( deploy ) {
319
322
320
- this . latestDeployment = new Deployment ( this , 'Deployment' , {
323
+ this . _latestDeployment = new Deployment ( this , 'Deployment' , {
321
324
description : 'Automatically created by the RestApi construct' ,
322
325
api : this ,
323
326
retainDeployments : props . retainDeployments
@@ -328,7 +331,7 @@ export class RestApi extends Resource implements IRestApi {
328
331
const stageName = ( props . deployOptions && props . deployOptions . stageName ) || 'prod' ;
329
332
330
333
this . deploymentStage = new Stage ( this , `DeploymentStage.${ stageName } ` , {
331
- deployment : this . latestDeployment ,
334
+ deployment : this . _latestDeployment ,
332
335
...props . deployOptions
333
336
} ) ;
334
337
0 commit comments