-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(s3): allow specifying a custom IAM Role for bucket replication #33978
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
feat(s3): allow specifying a custom IAM Role for bucket replication #33978
Conversation
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.
(This review is outdated)
Additional informationBehavior when
|
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33978 +/- ##
==========================================
+ Coverage 83.98% 84.00% +0.01%
==========================================
Files 120 121 +1
Lines 6976 6984 +8
Branches 1178 1179 +1
==========================================
+ Hits 5859 5867 +8
Misses 1005 1005
Partials 112 112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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 added two minor comments.
postCliContext: { | ||
[SET_UNIQUE_REPLICATION_ROLE_NAME]: false, | ||
}, |
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.
You probably don't need to explicitly disable this function flag. It will be set true
implicitly.
postCliContext: { | |
[SET_UNIQUE_REPLICATION_ROLE_NAME]: false, | |
}, |
This fix should not cause any differences in the snapshot generation in this integration test, but if it does, I would appreciate it if you could run the snapshot update again.
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 feedback. You're right, it doesn't seem necessary to consider this in the current test scenario. I will remove it.
replicationRole: new iam.Role(stack, 'ReplicationRole', { | ||
assumedBy: new iam.ServicePrincipal('s3.amazonaws.com'), | ||
}), | ||
replicationRules: [], |
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.
It's probably correct not to specify replicationRules, right?
replicationRules: [], |
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.
You are absolutely right. This replicationRule
did not reflect the original intent of testing the unspecified state. I have removed it in the latest commit.
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.
Thanks!!
Thank you @hassaku63 for this contribution, I agree with abstracting the permissions under a new method , which can be added in a follow up PR. Note: added |
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). |
This pull request has been removed from the queue for the following reason: Pull request #33978 has been dequeued. The pull request rule doesn't match anymore. The following conditions don't match anymore:
You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. |
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). |
Thank you @hstern, there is already an integration test to check the cross-account functionality in this PR, do you see anything missing from this integration test that you would like to add? |
Thanks for the note. I don't have decision-making authority on this, so I generally intend to follow the maintainers' guidance. That said, while I'm not entirely sure whether this pull request is the right place to have the discussion, I'd like to share my personal thoughts. From my perspective, if the proposed integ test is well-motivated and works as expected, I think there's value in including the commit. In that case, I assume I should merge your commit into my remote branch (please let me know if there's a preferred approach you'd recommend instead). At the same time, I do have a few concerns about the proposed integ test, which I'd like to bring up. First, I find the assumed setup somewhat unusual. In most cases, wouldn't it be the source stack that takes responsibility for creating the replication role? These stacks will likely deploy successfully since they belong to the same account. However, I'm not sure this setup accurately reflects a typical cross-stack use case. Personally, I think it's more common for either the source or destination stack to be deployed independently first. If the goal here is to detect circular dependencies, that feels like a separate topic—perhaps one that warrants its own validation logic and discussion. Second, I'm wondering whether this test assumes that the replication role is created automatically in the source stack. Based on the comment, I understand this test is intended for the case where the replication role is explicitly specified. However, looking at the SourceStack implementation, it seems to rely on the automatic creation of the IAM role used for S3 replication. Meanwhile, what appears to be the explicitly created IAM role is defined in the DestStack, which seems a bit counterintuitive to me. |
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). |
Comments on closed issues and PRs are hard for our team to see. |
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
replicationRole?: iam.IRole
property inBucketProps
.replicationRole
is provided, the CDK uses it instead of creating a new role.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
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license