Same-account same-region replication automatically and asynchronously (in near real time) replicates operations such as the creation, update, and deletion of objects in a source bucket in a region of an account to a destination bucket in the same region of the same account. This topic describes how to configure same-account same-region replication.
Prerequisites
A bucket (Bucket A, the source bucket) is created in a region of an account, and the account UID, the name of Bucket A, and the region are recorded.
A bucket (Bucket B, the destination bucket) is created in the same account and region, and the name of Bucket B is recorded.
Role types
When you perform same-account same-region replication, you must specify a role that is used to perform replication operations between the source bucket and the destination bucket. You can select any of the following roles to complete the same-account same-region replication task.
You can create the 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 a RAM user role-related permissions such as ram:CreateRole and ram:GetRole poses relatively high risks, we recommend that you create a RAM role and complete role authorization by using the Alibaba Cloud account associated with the RAM user. After the authorization is complete, the RAM user can directly reuse the RAM role created by the Alibaba Cloud account.
(Recommended) Create a role
When you create a same-account same-region replication rule, you can select to create a role to complete the replication task. After you select to create a role, the system automatically creates a role in the oss-replication-{uuid} format and grants different permission policies based on whether you select to replicate KMS-encrypted objects.
Replicate KMS-encrypted objects
After you create the role, you must complete role authorization based on the on-screen instructions. After the authorization is complete, the role has the precise permission policy for synchronizing data from the source bucket to the destination bucket, and the AliyunKMSCryptoUserAccess policy (permissions to manage Key Management Service (KMS)).
Do not replicate KMS-encrypted objects
After you create the role, you must complete role authorization based on the on-screen instructions. After the authorization is complete, the role has the precise permission policy for synchronizing data from the source bucket to the destination bucket.
AliyunOSSRole
When you create a same-account same-region replication rule, you can select the AliyunOSSRole role to complete the replication task. After you select this role, the system grants different permission policies based on whether you select to replicate KMS-encrypted objects.
Replicate KMS-encrypted objects
After you select the AliyunOSSRole role, the system automatically grants the following permission policies to the AliyunOSSRole role: AliyunOSSFullAccess (permissions to manage OSS) and AliyunKMSCryptoUserAccess (permissions to manage KMS).
WarningThis role has permissions to perform all operations on all buckets and KMS under the current account. The permission scope is large. Exercise caution.
Do not replicate KMS-encrypted objects
After you select the AliyunOSSRole role, the system automatically grants AliyunOSSFullAccess (permissions to manage OSS) to the AliyunOSSRole role.
WarningThis role has permissions to perform all operations on all buckets under the current account. The permission scope is large. Exercise caution.
Custom role
When you create a same-account same-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 normal service role.
When you create the role, set the trusted entity type to Alibaba Cloud Service and the trusted service to Object Storage Service. For the specific steps, see Create a normal service role.
Grant permissions to the role.
You can grant permissions to the role in any of the following ways.
Grant a system policy to the RAM role
WarningYou can grant the system policy
AliyunOSSFullAccessto the RAM role. By default,AliyunOSSFullAccesshas permissions to perform all operations on all buckets under the current account. Exercise caution.If you want to replicate KMS-encrypted objects to the destination bucket, you must also grant the
AliyunKMSFullAccesssystem policy to the role.For the specific steps, see Manage the permissions of a RAM role.
Grant a custom policy to the RAM role
We recommend that you grant the RAM role the minimum permissions required for replication between the source bucket (src-bucket) and the destination bucket (dest-bucket).
NoteIn actual use, replace the source bucket and destination bucket names accordingly.
{ "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 the specific steps, see Manage the permissions of 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 in the same region under the same account, OSS verifies only the permission policy of the RAM role used for replication, and does not verify the bucket policy configured for the source or destination bucket.