Skip to content

Commit 6c3c1a7

Browse files
authored
Merge branch 'master' into huijbers/pipelines-names
2 parents f57d662 + f11766e commit 6c3c1a7

28 files changed

Lines changed: 490 additions & 42 deletions

packages/@aws-cdk/aws-apigateway/lib/restapi.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ export abstract class RestApiBase extends Resource implements IRestApi {
319319
private _latestDeployment?: Deployment;
320320
private _domainName?: DomainName;
321321

322+
protected cloudWatchAccount?: CfnAccount;
323+
322324
constructor(scope: Construct, id: string, props: RestApiBaseProps = { }) {
323325
super(scope, id);
324326
this.restApiName = props.restApiName ?? id;
@@ -500,6 +502,17 @@ export abstract class RestApiBase extends Resource implements IRestApi {
500502
ignore(deployment);
501503
}
502504

505+
/**
506+
* Associates a Stage with this REST API
507+
*
508+
* @internal
509+
*/
510+
public _attachStage(stage: Stage) {
511+
if (this.cloudWatchAccount) {
512+
stage.node.addDependency(this.cloudWatchAccount);
513+
}
514+
}
515+
503516
/**
504517
* @internal
505518
*/
@@ -509,11 +522,11 @@ export abstract class RestApiBase extends Resource implements IRestApi {
509522
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonAPIGatewayPushToCloudWatchLogs')],
510523
});
511524

512-
const resource = new CfnAccount(this, 'Account', {
525+
this.cloudWatchAccount = new CfnAccount(this, 'Account', {
513526
cloudWatchRoleArn: role.roleArn,
514527
});
515528

516-
resource.node.addDependency(apiResource);
529+
this.cloudWatchAccount.node.addDependency(apiResource);
517530
}
518531

519532
/**

packages/@aws-cdk/aws-apigateway/lib/stage.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Construct } from 'constructs';
33
import { AccessLogFormat, IAccessLogDestination } from './access-log';
44
import { CfnStage } from './apigateway.generated';
55
import { Deployment } from './deployment';
6-
import { IRestApi } from './restapi';
6+
import { IRestApi, RestApiBase } from './restapi';
77
import { parseMethodOptionsPath } from './util';
88

99
/**
@@ -256,6 +256,10 @@ export class Stage extends Resource implements IStage {
256256

257257
this.stageName = resource.ref;
258258
this.restApi = props.deployment.api;
259+
260+
if (RestApiBase._isRestApiBase(this.restApi)) {
261+
this.restApi._attachStage(this);
262+
}
259263
}
260264

261265
/**

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.cognito-authorizer.expected.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
"myauthorizer23CB99DD": {
3535
"Type": "AWS::ApiGateway::Authorizer",
3636
"Properties": {
37+
"Name": "CognitoUserPoolsAuthorizerIntegmyauthorizer10C804C1",
3738
"RestApiId": {
3839
"Ref": "myrestapi551C8392"
3940
},
4041
"Type": "COGNITO_USER_POOLS",
4142
"IdentitySource": "method.request.header.Authorization",
42-
"Name": "CognitoUserPoolsAuthorizerIntegmyauthorizer10C804C1",
4343
"ProviderARNs": [
4444
{
4545
"Fn::GetAtt": [
@@ -123,7 +123,10 @@
123123
"Ref": "myrestapiDeployment419B1464b903292b53d7532ca4296973bcb95b1a"
124124
},
125125
"StageName": "prod"
126-
}
126+
},
127+
"DependsOn": [
128+
"myrestapiAccountA49A05BE"
129+
]
127130
},
128131
"myrestapiANY94B0497F": {
129132
"Type": "AWS::ApiGateway::Method",

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.request-authorizer.lit.expected.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@
198198
"Ref": "MyRestApiDeploymentB555B582dcff966d69deeda8d47e3bf409ce29cb"
199199
},
200200
"StageName": "prod"
201-
}
201+
},
202+
"DependsOn": [
203+
"MyRestApiAccount2FB6DB7A"
204+
]
202205
},
203206
"MyRestApiANY05143F93": {
204207
"Type": "AWS::ApiGateway::Method",
@@ -239,6 +242,7 @@
239242
"MyAuthorizer6575980E": {
240243
"Type": "AWS::ApiGateway::Authorizer",
241244
"Properties": {
245+
"Name": "RequestAuthorizerIntegMyAuthorizer5D9D41C5",
242246
"RestApiId": {
243247
"Ref": "MyRestApi2D1F47A9"
244248
},
@@ -266,8 +270,7 @@
266270
]
267271
]
268272
},
269-
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow",
270-
"Name": "RequestAuthorizerIntegMyAuthorizer5D9D41C5"
273+
"IdentitySource": "method.request.header.Authorization,method.request.querystring.allow"
271274
}
272275
}
273276
},

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"MyAuthorizer6575980E": {
106106
"Type": "AWS::ApiGateway::Authorizer",
107107
"Properties": {
108+
"Name": "TokenAuthorizerIAMRoleIntegMyAuthorizer1DFDE3B5",
108109
"RestApiId": {
109110
"Ref": "MyRestApi2D1F47A9"
110111
},
@@ -138,8 +139,7 @@
138139
]
139140
]
140141
},
141-
"IdentitySource": "method.request.header.Authorization",
142-
"Name": "TokenAuthorizerIAMRoleIntegMyAuthorizer1DFDE3B5"
142+
"IdentitySource": "method.request.header.Authorization"
143143
}
144144
},
145145
"MyAuthorizerauthorizerInvokePolicy0F88B8E1": {
@@ -241,7 +241,10 @@
241241
"Ref": "MyRestApiDeploymentB555B582dcff966d69deeda8d47e3bf409ce29cb"
242242
},
243243
"StageName": "prod"
244-
}
244+
},
245+
"DependsOn": [
246+
"MyRestApiAccount2FB6DB7A"
247+
]
245248
},
246249
"MyRestApiANY05143F93": {
247250
"Type": "AWS::ApiGateway::Method",

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.lit.expected.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@
198198
"Ref": "MyRestApiDeploymentB555B582dcff966d69deeda8d47e3bf409ce29cb"
199199
},
200200
"StageName": "prod"
201-
}
201+
},
202+
"DependsOn": [
203+
"MyRestApiAccount2FB6DB7A"
204+
]
202205
},
203206
"MyRestApiANY05143F93": {
204207
"Type": "AWS::ApiGateway::Method",
@@ -239,6 +242,7 @@
239242
"MyAuthorizer6575980E": {
240243
"Type": "AWS::ApiGateway::Authorizer",
241244
"Properties": {
245+
"Name": "TokenAuthorizerIntegMyAuthorizer793B1D5F",
242246
"RestApiId": {
243247
"Ref": "MyRestApi2D1F47A9"
244248
},
@@ -266,8 +270,7 @@
266270
]
267271
]
268272
},
269-
"IdentitySource": "method.request.header.Authorization",
270-
"Name": "TokenAuthorizerIntegMyAuthorizer793B1D5F"
273+
"IdentitySource": "method.request.header.Authorization"
271274
}
272275
}
273276
},

packages/@aws-cdk/aws-apigateway/test/integ.cors.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@
7777
"Ref": "corsapitestDeployment2BF1633A228079ea05e5799220dd4ca13512b92d"
7878
},
7979
"StageName": "prod"
80-
}
80+
},
81+
"DependsOn": [
82+
"corsapitestAccount7D1D6854"
83+
]
8184
},
8285
"corsapitesttwitch0E3D1559": {
8386
"Type": "AWS::ApiGateway::Resource",

packages/@aws-cdk/aws-apigateway/test/integ.lambda-api.latebound-deploymentstage.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,10 @@
377377
"Ref": "deployment3338197541aef5f15bf9a60b10e06fdbe72854f4"
378378
},
379379
"StageName": "prod"
380-
}
380+
},
381+
"DependsOn": [
382+
"lambdarestapiAccount856938D8"
383+
]
381384
}
382385
}
383386
}

packages/@aws-cdk/aws-apigateway/test/integ.restapi.books.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@
229229
"Ref": "booksapiDeployment308B08F132cc25cf8168bd5e99b9e6d4915866b5"
230230
},
231231
"StageName": "prod"
232-
}
232+
},
233+
"DependsOn": [
234+
"booksapiAccountDBA98FB9"
235+
]
233236
},
234237
"booksapiANYApiPermissionrestapibooksexamplebooksapi4538F335ANY73B3CDDC": {
235238
"Type": "AWS::Lambda::Permission",

packages/@aws-cdk/aws-apigateway/test/integ.restapi.defaults.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
"Ref": "myapiDeployment92F2CB4972a890db5063ec679071ba7eefc76f2a"
7474
},
7575
"StageName": "prod"
76-
}
76+
},
77+
"DependsOn": [
78+
"myapiAccountEC421A0A"
79+
]
7780
},
7881
"myapiGETF990CE3C": {
7982
"Type": "AWS::ApiGateway::Method",

0 commit comments

Comments
 (0)