Skip to content

Commit 615f626

Browse files
authored
feat(s3): allow specifying a custom IAM Role for bucket replication (#33978)
### Issue # (if applicable) Closes #33974 ### Reason for this change Currently, the `aws-s3` module automatically creates and manages the IAM Role used for S3 replication. This limits integration flexibility, especially in environments where IAM Roles are provisioned externally or reused across stacks/accounts. This change addresses that limitation by allowing users to provide a custom IAM Role for replication. ### Description of changes - Introduced an optional `replicationRole?: iam.IRole` property in `BucketProps`. - When `replicationRole` is provided, the CDK uses it instead of creating a new role. - Required permissions are **NOT** automatically attached to the provided role. It is the user's responsibility to attach the necessary IAM policies. - Added validation to ensure that if `replicationRole` is specified, `replicationRules` must also be defined and non-empty, since both are required by CloudFormation when configuring replication. ### Describe any new or updated permissions being added No new IAM actions are introduced. When a custom role is provided, CDK does not attach any permissions automatically. Users are expected to grant the appropriate replication-related permissions manually. ### Description of how you validated changes Added unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 753ed62 commit 615f626

File tree

14 files changed

+33625
-27
lines changed

14 files changed

+33625
-27
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-s3/test/integ.bucket-replication-use-custom-role.js.snapshot/BucketReplicationTestStack.assets.json

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)