Commit 615f626
authored
feat(s3): allow specifying a custom IAM Role for bucket replication (aws#33978)
### Issue # (if applicable)
Closes aws#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- packages
- @aws-cdk-testing/framework-integ/test/aws-s3/test
- integ.bucket-replication-use-custom-role.js.snapshot
- asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61
- asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle
- aws-cdk-lib/aws-s3
- lib
- test
14 files changed
+33625
-27
lines changedLines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments