-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(s3): add grantReplicationPermission
for IAM Role permissions
#34138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(s3): add grantReplicationPermission
for IAM Role permissions
#34138
Conversation
use grantReplicationPermission method
Regarding the design of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've added a small comment.
if (props.destinations.length === 0) { | ||
throw new ValidationError('destinations must be specified', this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add unit test for throwing this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@badmintoncryer Thank you for your review, yes I have added a unit test that you noted.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue # (if applicable)
Closes #34119
Reason for this change
This change introduces a new method, grantReplicationPermission, to the aws-cdk-lib.aws_s3.Bucket construct. The purpose of this addition is to provide a more convenient and programmatic way for AWS CDK users to grant the necessary IAM permissions to a user-provided IAM Role that will be used for S3 bucket replication.
Description of changes
This pull request includes the following code changes:
grantReplicationPermission
to the Bucket class.renderReplicationConfiguration
method by extracting the IAM permission granting functionality into a dedicatedgrantReplicationPermission
method.Describe any new or updated permissions being added
No new IAM permissions are being added at the CDK level. The permissions granted by the
grantReplicationPermission
method are the same as those already handled internally by the existing replication configuration logic. This change simply exposes that functionality through a dedicated method.Description of how you validated changes
grantReplicationPermission
method, ensuring that the correct IAM policies are attached to the provided role. Notably, the unit tests specifically cover scenarios where an explicitreplicationRole
is provided.integ.bucket-replication-use-custom-role.ts
was refactored to use the newgrantReplicationPermission
method instead of manually attaching the required permissions to the IAM role, and its behavior was verified to remain equivalent.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license