fix(iam): Modify addManagedPolicy to compare ARN instead of instance reference#25529
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
|
Exemption Request This change only affects the |
| return this._precreatedRole.addManagedPolicy(policy); | ||
| } else { | ||
| if (this.managedPolicies.find(mp => mp === policy)) { return; } | ||
| if (this.managedPolicies.some(mp => mp.managedPolicyArn === policy.managedPolicyArn)) { return; } |
There was a problem hiding this comment.
We don't need an integration test, but we do need a unit test.
There was a problem hiding this comment.
I tried writing a unit test. Could you please take a look at it?
I added addToPrincipalPolicy() to this test because this warning only appears when defaultPolicy exists.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Issue
When creating a role, the following warning message appeared:
This was caused by the same managed policy being added multiple times.
Although there was only one managed policy in the created template, it appears that the managedPolicies field of the Role class has multiple instances of the same managed policy added to it.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license