Same-region replication (SRR) automatically and asynchronously (in near real-time) replicates objects—including their creation, updates, and deletions—from a source bucket to a destination bucket. The source and destination buckets must be in the same region and belong to the same Alibaba Cloud account. This topic describes how to configure SRR for buckets within the same account.
Prerequisites
A source bucket is created in a region under your Alibaba Cloud account. The account UID, source bucket name, and region are recorded.
A destination bucket is created in the same region under the same Alibaba Cloud account. The destination bucket name is recorded.
RAM role types
To perform SRR, you must specify a RAM role that Object Storage Service (OSS) can assume to replicate objects from the source bucket to the destination bucket. You can use one of the following role types for the SRR task.
You can create a role by using a RAM user. The RAM user must have the following permissions: ram:CreateRole, ram:GetRole, ram:ListPoliciesForRole, and ram:AttachPolicyToRole. Because granting role-related permissions such as ram:CreateRole and ram:GetRole to a RAM user involves high risks, we recommend that you use the Alibaba Cloud account associated with the RAM user to create a RAM role and grant permissions to the role. After the authorization is complete, the RAM user can directly reuse the RAM role created by the Alibaba Cloud account.
New RAM role (recommended)
When you create a same-region replication rule within the same account, you can choose to create a new role to complete the replication task. If you choose to create a new role, a role with the name format oss-replication-{uuid} is automatically created in the background and is granted different permission policies based on whether you choose to replicate KMS-encrypted objects.
Replicating KMS-encrypted objects
After the role is created, you must authorize it by following the on-screen instructions. Once authorized, the role receives a fine-grained policy for data replication and the AliyunKMSCryptoUserAccess policy to manage KMS.
Not replicating KMS-encrypted objects
After the role is created, you must authorize it by following the on-screen instructions. Once authorized, the role receives a fine-grained policy for data replication.
AliyunOSSRole
When you create an SRR rule, you can select the AliyunOSSRole for the replication task. After you select this role, a policy is attached based on whether you choose to replicate KMS-encrypted objects.
Replicating KMS-encrypted objects
If you select the AliyunOSSRole, the system automatically attaches the AliyunOSSFullAccess policy (grants permissions to manage OSS) and the AliyunKMSCryptoUserAccess policy (grants permissions to manage KMS) to the role.
WarningThis role has permissions to perform all operations on all buckets and KMS keys in the current account. This is a broad permission scope, so use this role with caution.
Not replicating KMS-encrypted objects
If you select the AliyunOSSRole, the system automatically attaches the AliyunOSSFullAccess policy (grants permissions to manage OSS) to the role.
WarningThis role has permissions to perform all operations on all buckets in the current account. This is a broad permission scope, so use this role with caution.
Custom role
When you create an SRR rule, you can use a custom role for the replication task. You must create a custom role in the RAM console and grant the required permissions to the role.
Create a regular service role.
When you create the role, select Alibaba Cloud Service for the trusted entity type and Object Storage Service for the trusted service. For more information, see Create a regular service role.
Grant permissions to the role.
You can grant permissions to the role in one of the following ways.
System policy
WarningYou can grant the system policy
AliyunOSSFullAccessto a RAM role.AliyunOSSFullAccessgrants full permissions on all buckets in the current account by default. Use this policy with caution.If you want to copy a KMS-encrypted object to the destination bucket, you also need to grant the
AliyunKMSFullAccesssystem policy to the role.For more information, see Grant permissions to a RAM role.
Custom policy
We recommend that you grant the RAM role the minimum permissions required to replicate objects from the source bucket (src-bucket) to the destination bucket (dest-bucket).
NoteWhen you use the policy, replace the names of the source and destination buckets with the actual names.
{ "Version":"1", "Statement":[ { "Effect":"Allow", "Action":[ "oss:ReplicateList", "oss:ReplicateGet" ], "Resource":[ "acs:oss:*:*:src-bucket", "acs:oss:*:*:src-bucket/*" ] }, { "Effect":"Allow", "Action":[ "oss:ReplicateList", "oss:ReplicateGet", "oss:ReplicatePut", "oss:ReplicateDelete" ], "Resource":[ "acs:oss:*:*:dest-bucket", "acs:oss:*:*:dest-bucket/*" ] } ] }For more information, see Grant permissions to a RAM role.
NoteIf you want to copy a KMS-encrypted Object to the destination Bucket, you also need to grant the
AliyunKMSFullAccesssystem policy to the role.
For SRR within the same account, OSS evaluates permissions based only on the policy of the RAM role. It does not check the bucket policies of the source or destination buckets.