Skip to content

Commit 5699981

Browse files
committed
feat: Add construct.node.stack attribute
Makes it easier to access some construct's `Stack`, avoiding having to sprinkle `Stack.find(this)` everywhere. While there, added `construct.node.formatArn` and `construct.node.parseArn` as convenience methods to avoid indirecting via the `Stack`. BREAKING CHANGE: `Stack.find(c)` and `Stack.tryFind(c)` were replaced by `c.node.stack`. Fixes #798
1 parent 2480f0f commit 5699981

File tree

52 files changed

+237
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+237
-192
lines changed

Diff for: packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
104104
constructor(scope: cdk.Construct, id: string, props: PipelineDeployStackActionProps) {
105105
super(scope, id);
106106

107-
if (!cdk.environmentEquals(props.stack.env, cdk.Stack.find(this).env)) {
107+
if (!cdk.environmentEquals(props.stack.env, this.node.stack.env)) {
108108
// FIXME: Add the necessary to extend to stacks in a different account
109109
throw new Error(`Cross-environment deployment is not supported`);
110110
}

Diff for: packages/@aws-cdk/aws-apigateway/lib/integrations/aws.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class AwsIntegration extends Integration {
7373
integrationHttpMethod: 'POST',
7474
uri: new cdk.Token(() => {
7575
if (!this.scope) { throw new Error('AwsIntegration must be used in API'); }
76-
return cdk.Stack.find(this.scope).formatArn({
76+
return this.scope.node.stack.formatArn({
7777
service: 'apigateway',
7878
account: backend,
7979
resource: apiType,

Diff for: packages/@aws-cdk/aws-apigateway/lib/method.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class Method extends cdk.Construct {
189189
} else if (options.credentialsPassthrough) {
190190
// arn:aws:iam::*:user/*
191191
// tslint:disable-next-line:max-line-length
192-
credentials = cdk.Stack.find(this).formatArn({ service: 'iam', region: '', account: '*', resource: 'user', sep: '/', resourceName: '*' });
192+
credentials = this.node.formatArn({ service: 'iam', region: '', account: '*', resource: 'user', sep: '/', resourceName: '*' });
193193
}
194194

195195
return {

Diff for: packages/@aws-cdk/aws-apigateway/lib/restapi.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class RestApi extends cdk.Construct implements IRestApi {
271271
method = '*';
272272
}
273273

274-
return cdk.Stack.find(this).formatArn({
274+
return this.node.formatArn({
275275
service: 'execute-api',
276276
resource: this.restApiId,
277277
sep: '/',
@@ -328,7 +328,7 @@ export class RestApi extends cdk.Construct implements IRestApi {
328328
private configureCloudWatchRole(apiResource: CfnRestApi) {
329329
const role = new iam.Role(this, 'CloudWatchRole', {
330330
assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
331-
managedPolicyArns: [ cdk.Stack.find(this).formatArn({
331+
managedPolicyArns: [ this.node.formatArn({
332332
service: 'iam',
333333
region: '',
334334
account: 'aws',

Diff for: packages/@aws-cdk/aws-apigateway/lib/stage.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import cdk = require('@aws-cdk/cdk');
2-
import { Stack } from '@aws-cdk/cdk';
32
import { CfnStage } from './apigateway.generated';
43
import { Deployment } from './deployment';
54
import { IRestApi } from './restapi';
@@ -179,8 +178,7 @@ export class Stage extends cdk.Construct {
179178
if (!path.startsWith('/')) {
180179
throw new Error(`Path must begin with "/": ${path}`);
181180
}
182-
const stack = Stack.find(this);
183-
return `https://${this.restApi.restApiId}.execute-api.${stack.region}.${stack.urlSuffix}/${this.stageName}${path}`;
181+
return `https://${this.restApi.restApiId}.execute-api.${this.node.stack.region}.${this.node.stack.urlSuffix}/${this.stageName}${path}`;
184182
}
185183

186184
private renderMethodSettings(props: StageProps): CfnStage.MethodSettingProperty[] | undefined {

Diff for: packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class SingletonPolicy extends cdk.Construct {
544544
}
545545

546546
private stackArnFromProps(props: { stackName: string, region?: string }): string {
547-
return cdk.Stack.find(this).formatArn({
547+
return this.node.formatArn({
548548
region: props.region,
549549
service: 'cloudformation',
550550
resource: 'stack',

Diff for: packages/@aws-cdk/aws-cloudformation/test/test.pipeline-actions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function _isOrContains(entity: string | string[], value: string): boolean {
293293
}
294294

295295
function _stackArn(stackName: string, scope: cdk.IConstruct): string {
296-
return cdk.Stack.find(scope).formatArn({
296+
return scope.node.formatArn({
297297
service: 'cloudformation',
298298
resource: 'stack',
299299
resourceName: `${stackName}/*`,
@@ -308,7 +308,7 @@ class PipelineDouble extends cdk.Construct implements cpapi.IPipeline {
308308
constructor(scope: cdk.Construct, id: string, { pipelineName, role }: { pipelineName?: string, role: iam.Role }) {
309309
super(scope, id);
310310
this.pipelineName = pipelineName || 'TestPipeline';
311-
this.pipelineArn = cdk.Stack.find(this).formatArn({ service: 'codepipeline', resource: 'pipeline', resourceName: this.pipelineName });
311+
this.pipelineArn = this.node.formatArn({ service: 'codepipeline', resource: 'pipeline', resourceName: this.pipelineName });
312312
this.role = role;
313313
}
314314

Diff for: packages/@aws-cdk/aws-cloudtrail/lib/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,13 @@ export class CloudTrail extends cdk.Construct {
132132
const s3bucket = new s3.Bucket(this, 'S3', {encryption: s3.BucketEncryption.Unencrypted});
133133
const cloudTrailPrincipal = "cloudtrail.amazonaws.com";
134134

135-
const stack = cdk.Stack.find(this);
136-
137135
s3bucket.addToResourcePolicy(new iam.PolicyStatement()
138136
.addResource(s3bucket.bucketArn)
139137
.addActions('s3:GetBucketAcl')
140138
.addServicePrincipal(cloudTrailPrincipal));
141139

142140
s3bucket.addToResourcePolicy(new iam.PolicyStatement()
143-
.addResource(s3bucket.arnForObjects(`AWSLogs/${stack.accountId}/*`))
141+
.addResource(s3bucket.arnForObjects(`AWSLogs/${this.node.stack.accountId}/*`))
144142
.addActions("s3:PutObject")
145143
.addServicePrincipal(cloudTrailPrincipal)
146144
.setCondition("StringEquals", {'s3:x-amz-acl': "bucket-owner-full-control"}));

Diff for: packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, Stack, Token } from "@aws-cdk/cdk";
1+
import { Construct, Token } from "@aws-cdk/cdk";
22
import { CfnDashboard } from './cloudwatch.generated';
33
import { Column, Row } from "./layout";
44
import { IWidget } from "./widget";
@@ -61,7 +61,6 @@ export class Dashboard extends Construct {
6161
*/
6262
private generateDashboardName(): string {
6363
// Combination of stack name and LogicalID, which are guaranteed to be unique.
64-
const stack = Stack.find(this);
65-
return stack.name + '-' + this.dashboard.logicalId;
64+
return this.node.stack.name + '-' + this.dashboard.logicalId;
6665
}
6766
}

Diff for: packages/@aws-cdk/aws-codebuild/lib/project.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class ImportedProject extends ProjectBase {
409409
constructor(scope: cdk.Construct, id: string, private readonly props: ProjectImportProps) {
410410
super(scope, id);
411411

412-
this.projectArn = cdk.Stack.find(this).formatArn({
412+
this.projectArn = this.node.formatArn({
413413
service: 'codebuild',
414414
resource: 'project',
415415
resourceName: props.projectName,
@@ -744,7 +744,7 @@ export class Project extends ProjectBase {
744744
}
745745

746746
private createLoggingPermission() {
747-
const logGroupArn = cdk.Stack.find(this).formatArn({
747+
const logGroupArn = this.node.formatArn({
748748
service: 'logs',
749749
resource: 'log-group',
750750
sep: ':',

Diff for: packages/@aws-cdk/aws-codecommit/lib/repository.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class ImportedRepository extends RepositoryBase {
230230
constructor(scope: cdk.Construct, id: string, private readonly props: RepositoryImportProps) {
231231
super(scope, id);
232232

233-
this.repositoryArn = cdk.Stack.find(this).formatArn({
233+
this.repositoryArn = this.node.formatArn({
234234
service: 'codecommit',
235235
resource: props.repositoryName,
236236
});
@@ -249,9 +249,8 @@ class ImportedRepository extends RepositoryBase {
249249
return this.repositoryCloneUrl('ssh');
250250
}
251251

252-
private repositoryCloneUrl(protocol: 'https' | 'ssh'): string {
253-
const stack = cdk.Stack.find(this);
254-
return `${protocol}://git-codecommit.${stack.region}.${stack.urlSuffix}/v1/repos/${this.repositoryName}`;
252+
private repositoryCloneUrl(protocol: 'https' | 'ssh'): string {
253+
return `${protocol}://git-codecommit.${this.node.stack.region}.${this.node.stack.urlSuffix}/v1/repos/${this.repositoryName}`;
255254
}
256255
}
257256

Diff for: packages/@aws-cdk/aws-codedeploy/lib/server/deployment-group.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
282282

283283
this._autoScalingGroups = props.autoScalingGroups || [];
284284
this.installAgent = props.installAgent === undefined ? true : props.installAgent;
285-
const stack = cdk.Stack.find(this);
286285
this.codeDeployBucket = s3.Bucket.import(this, 'CodeDeployBucket', {
287-
bucketName: `aws-codedeploy-${stack.region}`,
286+
bucketName: `aws-codedeploy-${this.node.stack.region}`,
288287
});
289288
for (const asg of this._autoScalingGroups) {
290289
this.addCodeDeployAgentInstallUserData(asg);
@@ -359,7 +358,6 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
359358

360359
this.codeDeployBucket.grantRead(asg.role, 'latest/*');
361360

362-
const stack = cdk.Stack.find(this);
363361
switch (asg.osType) {
364362
case ec2.OperatingSystemType.Linux:
365363
asg.addUserData(
@@ -377,7 +375,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
377375
'$PKG_CMD install -y awscli',
378376
'TMP_DIR=`mktemp -d`',
379377
'cd $TMP_DIR',
380-
`aws s3 cp s3://aws-codedeploy-${stack.region}/latest/install . --region ${stack.region}`,
378+
`aws s3 cp s3://aws-codedeploy-${this.node.stack.region}/latest/install . --region ${this.node.stack.region}`,
381379
'chmod +x ./install',
382380
'./install auto',
383381
'rm -fr $TMP_DIR',
@@ -386,7 +384,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
386384
case ec2.OperatingSystemType.Windows:
387385
asg.addUserData(
388386
'Set-Variable -Name TEMPDIR -Value (New-TemporaryFile).DirectoryName',
389-
`aws s3 cp s3://aws-codedeploy-${stack.region}/latest/codedeploy-agent.msi $TEMPDIR\\codedeploy-agent.msi`,
387+
`aws s3 cp s3://aws-codedeploy-${this.node.stack.region}/latest/codedeploy-agent.msi $TEMPDIR\\codedeploy-agent.msi`,
390388
'$TEMPDIR\\codedeploy-agent.msi /quiet /l c:\\temp\\host-agent-install-log.txt',
391389
);
392390
break;

Diff for: packages/@aws-cdk/aws-codedeploy/lib/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CfnDeploymentGroup } from './codedeploy.generated';
44
import { AutoRollbackConfig } from './rollback-config';
55

66
export function applicationNameToArn(applicationName: string, scope: cdk.IConstruct): string {
7-
return cdk.Stack.find(scope).formatArn({
7+
return scope.node.formatArn({
88
service: 'codedeploy',
99
resource: 'application',
1010
resourceName: applicationName,
@@ -13,7 +13,7 @@ export function applicationNameToArn(applicationName: string, scope: cdk.IConstr
1313
}
1414

1515
export function deploymentGroupNameToArn(applicationName: string, deploymentGroupName: string, scope: cdk.IConstruct): string {
16-
return cdk.Stack.find(scope).formatArn({
16+
return scope.node.formatArn({
1717
service: 'codedeploy',
1818
resource: 'deploymentgroup',
1919
resourceName: `${applicationName}/${deploymentGroupName}`,
@@ -22,7 +22,7 @@ export function deploymentGroupNameToArn(applicationName: string, deploymentGrou
2222
}
2323

2424
export function arnForDeploymentConfigName(name: string, scope: cdk.IConstruct): string {
25-
return cdk.Stack.find(scope).formatArn({
25+
return scope.node.formatArn({
2626
service: 'codedeploy',
2727
resource: 'deploymentconfig',
2828
resourceName: name,

Diff for: packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
188188
this.artifactStores = {};
189189

190190
// Does not expose a Fn::GetAtt for the ARN so we'll have to make it ourselves
191-
this.pipelineArn = cdk.Stack.find(this).formatArn({
191+
this.pipelineArn = this.node.formatArn({
192192
service: 'codepipeline',
193193
resource: this.pipelineName
194194
});
@@ -336,8 +336,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
336336
}
337337

338338
// get the region the Pipeline itself is in
339-
const pipelineStack = cdk.Stack.find(this);
340-
const pipelineRegion = pipelineStack.requireRegion(
339+
const pipelineRegion = this.node.stack.requireRegion(
341340
"You need to specify an explicit region when using CodePipeline's cross-region support");
342341

343342
// if we already have an ArtifactStore generated for this region, or it's the Pipeline's region, nothing to do
@@ -347,9 +346,9 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
347346

348347
let replicationBucketName = this.crossRegionReplicationBuckets[action.region];
349348
if (!replicationBucketName) {
350-
const pipelineAccount = pipelineStack.requireAccountId(
349+
const pipelineAccount = this.node.stack.requireAccountId(
351350
"You need to specify an explicit account when using CodePipeline's cross-region support");
352-
const app = pipelineStack.parentApp();
351+
const app = this.node.stack.parentApp();
353352
if (!app) {
354353
throw new Error(`Pipeline stack which uses cross region actions must be part of an application`);
355354
}
@@ -477,7 +476,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
477476

478477
// add the Pipeline's artifact store
479478
const artifactStore = this.renderArtifactStore();
480-
this.artifactStores[cdk.Stack.find(this).requireRegion()] = {
479+
this.artifactStores[this.node.stack.requireRegion()] = {
481480
Location: artifactStore.location,
482481
Type: artifactStore.type,
483482
EncryptionKey: artifactStore.encryptionKey,

Diff for: packages/@aws-cdk/aws-dynamodb/lib/table.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ export class Table extends Construct {
622622
private makeScalingRole(): iam.IRole {
623623
// Use a Service Linked Role.
624624
return iam.Role.import(this, 'ScalingRole', {
625-
roleArn: cdk.Stack.find(this).formatArn({
625+
roleArn: this.node.formatArn({
626626
// https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-service-linked-roles.html
627627
service: 'iam',
628628
resource: 'role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com',

Diff for: packages/@aws-cdk/aws-ec2/lib/machine-image.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, SSMParameterProvider, Stack } from '@aws-cdk/cdk';
1+
import { Construct, SSMParameterProvider } from '@aws-cdk/cdk';
22

33
/**
44
* Interface for classes that can select an appropriate machine image to use
@@ -188,8 +188,7 @@ export class GenericLinuxImage implements IMachineImageSource {
188188
}
189189

190190
public getImage(scope: Construct): MachineImage {
191-
const stack = Stack.find(scope);
192-
const region = stack.requireRegion('AMI cannot be determined');
191+
const region = scope.node.stack.requireRegion('AMI cannot be determined');
193192
const ami = region !== 'test-region' ? this.amiMap[region] : 'ami-12345';
194193
if (!ami) {
195194
throw new Error(`Unable to find AMI in AMI map: no AMI specified for region '${region}'`);

Diff for: packages/@aws-cdk/aws-ec2/lib/security-group.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, IConstruct, Output, Stack, Token } from '@aws-cdk/cdk';
1+
import { Construct, IConstruct, Output, Token } from '@aws-cdk/cdk';
22
import { Connections, IConnectable } from './connections';
33
import { CfnSecurityGroup, CfnSecurityGroupEgress, CfnSecurityGroupIngress } from './ec2.generated';
44
import { IPortRange, ISecurityGroupRule } from './security-group-rule';
@@ -193,7 +193,7 @@ function determineRuleScope(
193193
}
194194

195195
function differentStacks(group1: SecurityGroupBase, group2: SecurityGroupBase) {
196-
return Stack.find(group1) !== Stack.find(group2);
196+
return group1.node.stack !== group2.node.stack;
197197
}
198198

199199
export interface SecurityGroupProps {

Diff for: packages/@aws-cdk/aws-ec2/lib/vpc-ref.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, IConstruct, IDependable, Stack } from "@aws-cdk/cdk";
1+
import { Construct, IConstruct, IDependable } from "@aws-cdk/cdk";
22
import { subnetName } from './util';
33

44
export interface IVpcSubnet extends IConstruct {
@@ -231,7 +231,7 @@ export abstract class VpcNetworkBase extends Construct implements IVpcNetwork {
231231
* The region where this VPC is defined
232232
*/
233233
public get vpcRegion(): string {
234-
return Stack.find(this).region;
234+
return this.node.stack.region;
235235
}
236236

237237
}
@@ -303,4 +303,4 @@ export interface VpcSubnetImportProps {
303303
* The subnetId for this particular subnet
304304
*/
305305
subnetId: string;
306-
}
306+
}

Diff for: packages/@aws-cdk/aws-ecr/lib/repository-ref.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export abstract class RepositoryBase extends cdk.Construct implements IRepositor
119119
* as the current stack.
120120
*/
121121
public static arnForLocalRepository(repositoryName: string, scope: cdk.IConstruct): string {
122-
return cdk.Stack.find(scope).formatArn({
122+
return scope.node.formatArn({
123123
service: 'ecr',
124124
resource: 'repository',
125125
resourceName: repositoryName
@@ -160,7 +160,7 @@ export abstract class RepositoryBase extends cdk.Construct implements IRepositor
160160
*/
161161
public repositoryUriForTag(tag?: string): string {
162162
const tagSuffix = tag ? `:${tag}` : '';
163-
const parts = cdk.Stack.find(this).parseArn(this.repositoryArn);
163+
const parts = this.node.parseArn(this.repositoryArn);
164164
return `${parts.account}.dkr.ecr.${parts.region}.amazonaws.com/${this.repositoryName}${tagSuffix}`;
165165
}
166166

Diff for: packages/@aws-cdk/aws-ecs/lib/base/base-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export abstract class BaseService extends cdk.Construct
224224
private makeAutoScalingRole(): iam.IRole {
225225
// Use a Service Linked Role.
226226
return iam.Role.import(this, 'ScalingRole', {
227-
roleArn: cdk.Stack.find(this).formatArn({
227+
roleArn: this.node.formatArn({
228228
service: 'iam',
229229
resource: 'role/aws-service-role/ecs.application-autoscaling.amazonaws.com',
230230
resourceName: 'AWSServiceRoleForApplicationAutoScaling_ECSService',

Diff for: packages/@aws-cdk/aws-ecs/lib/cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class ImportedCluster extends cdk.Construct implements ICluster {
327327
this.vpc = ec2.VpcNetwork.import(this, "vpc", props.vpc);
328328
this.hasEc2Capacity = props.hasEc2Capacity !== false;
329329

330-
this.clusterArn = props.clusterArn !== undefined ? props.clusterArn : cdk.Stack.find(this).formatArn({
330+
this.clusterArn = props.clusterArn !== undefined ? props.clusterArn : this.node.formatArn({
331331
service: 'ecs',
332332
resource: 'cluster',
333333
resourceName: props.clusterName,

Diff for: packages/@aws-cdk/aws-ecs/lib/log-drivers/aws-log-driver.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ export class AwsLogDriver extends LogDriver {
7373
* Return the log driver CloudFormation JSON
7474
*/
7575
public renderLogDriver(): CfnTaskDefinition.LogConfigurationProperty {
76-
const stack = cdk.Stack.find(this);
7776
return {
7877
logDriver: 'awslogs',
7978
options: removeEmpty({
8079
'awslogs-group': this.logGroup.logGroupName,
8180
'awslogs-stream-prefix': this.props.streamPrefix,
82-
'awslogs-region': stack.region,
81+
'awslogs-region': this.node.stack.region,
8382
'awslogs-datetime-format': this.props.datetimeFormat,
8483
'awslogs-multiline-pattern': this.props.multilinePattern,
8584
}),

Diff for: packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
8282
this.setAttribute('access_logs.s3.bucket', bucket.bucketName.toString());
8383
this.setAttribute('access_logs.s3.prefix', prefix);
8484

85-
const stack = cdk.Stack.find(this);
86-
87-
const region = stack.requireRegion('Enable ELBv2 access logging');
85+
const region = this.node.stack.requireRegion('Enable ELBv2 access logging');
8886
const account = ELBV2_ACCOUNTS[region];
8987
if (!account) {
9088
throw new Error(`Cannot enable access logging; don't know ELBv2 account for region ${region}`);

Diff for: packages/@aws-cdk/aws-iam/lib/managed-policy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class AwsManagedPolicy {
1818
*/
1919
public get policyArn(): string {
2020
// the arn is in the form of - arn:aws:iam::aws:policy/<policyName>
21-
return cdk.Stack.find(this.scope).formatArn({
21+
return this.scope.node.formatArn({
2222
service: "iam",
2323
region: "", // no region for managed policy
2424
account: "aws", // the account for a managed policy is 'aws'

0 commit comments

Comments
 (0)