Cross-region replication (CRR) within the same account automatically and asynchronously copies objects from a source bucket in one region to a destination bucket in another region. This includes object creation, updates, and deletions. This topic describes how to configure CRR within the same account.
Prerequisites
A source bucket (Bucket A) is created in a region. Note the account UID, the name of Bucket A, and its region.
A destination bucket (Bucket B) is created in a different region under the same account. Note the name of Bucket B and its region.
Role types
To configure CRR within the same account, you must specify a role for replication. You can choose one of the following roles for the task.
You can create a role using a RAM user. The RAM user must have the following permissions: ram:CreateRole, ram:GetRole, ram:ListPoliciesForRole, and ram:AttachPolicyToRole. However, because granting a RAM user role-related permissions, such as ram:CreateRole and ram:GetRole, poses a high security risk, you can use the associated Alibaba Cloud account to create a RAM role and grant permissions to it. The RAM user can then assume the RAM role that is created by the Alibaba Cloud account.
(Recommended) Create a new role
When you create a CRR rule for the same account, you can create a new role for the replication task. If you choose to create a new role, a role named oss-replication-{uuid} is automatically created. Different access policies are granted based on whether you choose to replicate objects that are encrypted using Key Management Service (KMS).
Replicate KMS-encrypted objects
After you create the role, follow the on-screen instructions to grant permissions. After authorization, the role is granted a fine-grained policy for replication from the source bucket to the destination bucket and the AliyunKMSFullAccess policy, which grants permission to manage KMS.
Do not replicate KMS-encrypted objects
After you create the role, follow the on-screen instructions to grant permissions. After authorization, the role is granted a fine-grained policy for replication from the source bucket to the destination bucket.
AliyunOSSRole
When you create a CRR rule for the same account, you can select the AliyunOSSRole to complete the replication task. If you select this role, different access policies are granted based on whether you choose to replicate KMS-encrypted objects.
Replicate KMS-encrypted objects
If you select the AliyunOSSRole, the role is automatically granted the AliyunOSSFullAccess policy, which grants permission to manage Object Storage Service (OSS), and the AliyunKMSFullAccess policy, which grants permission to manage KMS.
WarningThis role has permissions to perform all operations on all buckets and KMS keys under the current account. The scope of permissions is large. Use this role with caution.
Do not replicate KMS-encrypted objects.
If you select the AliyunOSSRole, the role is automatically granted the AliyunOSSFullAccess policy, which provides full management permissions for OSS.
WarningThis role has permissions to perform all operations on all buckets under the current account. The scope of permissions is large. Use this role with caution.
Custom role
When you create a CRR rule for the same account, 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 service role.
When you create the role, set the trusted entity type to Alibaba Cloud Service and the trusted entity name to Object Storage Service. For more information, see Create a service role.
Grant permissions to the role.
You can grant permissions to the role in one of the following ways.
Grant system policies to the RAM role
WarningYou can grant the
AliyunOSSFullAccesssystem policy to the RAM role. TheAliyunOSSFullAccesspolicy grants permissions to perform all operations on all buckets under the current account by default. Use this policy with caution.If you want to replicate KMS-encrypted objects to the destination bucket, you must also grant the
AliyunKMSFullAccesssystem policy to the role.For more information, see Grant permissions to a RAM role.
Grant a custom policy to the RAM role
You can use a RAM policy to grant the RAM role the least privilege required for replication 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 their 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 replicate KMS-encrypted objects to the destination bucket, you must also grant the
AliyunKMSFullAccesssystem policy to the role.
When you replicate data across regions within the same account, OSS checks only the access policy of the RAM role used for replication. OSS does not check the bucket policies of the source and destination buckets.