-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Role.fromRoleArn(mutable: false) creates constructs with the wrong ID #7255
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-iamRelated to AWS Identity and Access ManagementRelated to AWS Identity and Access ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp1
Description
This PR:
Broke the following piece of code:
const existingRole = scope.node.tryFindChild(id) as iam.IRole;
if (existingRole) {return existingRole; }
return iam.Role.fromRoleArn(scope, id, arn, { mutable: false });
One would expect the second execution of this code to return the same immutable role that was created on the first go-around.
But in fact, because we create 2 constructs, the mutable one of which has the ID the user requested, the first go-around will return the immutable role as desired, but the second go-around will return the inner, mutable role object, leading to policies being added to a supposedly immutable role.
This is 🐛 Bug Report
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-iamRelated to AWS Identity and Access ManagementRelated to AWS Identity and Access ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp1