Cross-region replication within the same account automatically and asynchronously (near-real-time) replicates object operations, such as creation, updates, and deletions, from a source bucket in one region to a destination bucket in another region under the same account. This topic describes how to configure cross-region replication within the same account.
Prerequisites
You have created a bucket (Bucket A) in a specific region to serve as the source bucket. Record the account ID, the name of Bucket A, and its region.
You have created another bucket (Bucket B) in a different region under the same account to serve as the destination bucket. Record the name of Bucket B and its region.
Role types
When you configure cross-region replication, you must specify a role that Object Storage Service (OSS) can assume to replicate objects between the source and destination buckets. You can use any of the following role types.
A RAM user must have the ram:CreateRole, ram:GetRole, ram:ListPoliciesForRole, and ram:AttachPolicyToRole permissions to create a role. However, granting role-related permissions such as ram:CreateRole and ram:GetRole to a RAM user poses a security risk. For better security, use your Alibaba Cloud account to create the RAM role and grant the necessary permissions. The RAM user can then directly use the role.
(Recommended) Create a new role
When you create a cross-region replication rule, you can choose to create a new role. A role is automatically created with a name in the format oss-replication-{uuid}. The permission policy attached to this role depends on whether you choose to replicate objects encrypted with Key Management Service (KMS).
Replicate KMS-encrypted objects
After the role is created, follow the on-screen instructions to grant permissions. Once authorized, the role has a fine-grained permission policy for replicating from the source bucket to the destination bucket, as well as the AliyunKMSCryptoUserAccess policy for managing Key Management Service (KMS).
Do not replicate KMS-encrypted objects
After the role is created, follow the on-screen instructions to grant permissions. Once authorized, the role has a fine-grained permission policy for replicating from the source bucket to the destination bucket.
AliyunOSSRole
When you create a cross-region replication rule, you can select AliyunOSSRole to complete the replication task. If you select this role, different permission policies are attached based on whether you choose to replicate KMS-encrypted objects.
Replicate KMS-encrypted objects
If you select AliyunOSSRole, the AliyunOSSFullAccess (for managing Object Storage Service) and AliyunKMSCryptoUserAccess (for managing Key Management Service) policies are automatically attached to the role.
WarningThis role has full access to all buckets and KMS keys under your account. Because the permissions are extensive, use this role with caution.
Do not replicate KMS-encrypted objects
If you select AliyunOSSRole, the AliyunOSSFullAccess policy (for managing Object Storage Service) is automatically attached to the role.
WarningThis role has full access to all buckets under your account. Because the permissions are extensive, use this role with caution.
Custom role
When you create a cross-region replication rule, you can use a custom role to complete 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.
During role creation, select Alibaba Cloud Service as the trusted entity and OSS as 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 either of the following ways.
Attach system policy
WarningYou can attach the
AliyunOSSFullAccesssystem policy to the RAM role. By default,AliyunOSSFullAccessprovides full permissions on all buckets under the current account. Use this policy with caution.If you want to replicate KMS-encrypted objects to the destination bucket, you must also attach the
AliyunKMSFullAccesssystem policy to the role.For more information, see Manage permissions for a RAM role.
Attach custom policy
Use a RAM policy to grant the minimum permissions required for replication from the source bucket (
src-bucket) to the destination bucket (dest-bucket).NoteReplace the names of the source and destination buckets with your actual bucket 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 Manage permissions for a RAM role.
NoteIf you want to replicate KMS-encrypted objects to the destination bucket, you must also attach the
AliyunKMSFullAccesssystem policy to the role.
When replicating data across regions within the same account, OSS validates only the permission policy of the RAM role used for replication. It does not check the bucket policies of the source or destination buckets.