Skip to content

Commit

Permalink
add comment explaining why Names.uniqueId() is retained
Browse files Browse the repository at this point in the history
  • Loading branch information
yamoyamoto committed Dec 19, 2023
1 parent f284e7c commit 4850d82
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-iam/lib/private/imported-role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class ImportedRole extends Resource implements IRole, IComparablePrincipa
public addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResult {
if (!this.defaultPolicy) {
const useUniqueName = FeatureFlags.of(this).isEnabled(IAM_IMPORTED_ROLE_STACK_SAFE_DEFAULT_POLICY_NAME);
// To preserve existing policy names, use Names.uniqueResourceName() only when exceeding the limit of policy names
// See https://github.com/aws/aws-cdk/pull/27548 for more
const prefix = 'Policy';
let defaultDefaultPolicyName = useUniqueName
? `${prefix}${Names.uniqueId(this)}`
Expand Down

0 comments on commit 4850d82

Please sign in to comment.