You can call this operation to configure cross-region replication (CRR) rules for a bucket.
Usage notes
CRR enables the automatic and asynchronous (near real-time) replication of objects across buckets in different OSS regions. Operations such as the creation, overwriting, and deletion of objects can be synchronized from a source bucket to a destination bucket.When you use CRR, take note of the following items:
CRR is an asynchronous process. Based on the size of the data to replicate, it takes several minutes to several hours to replicate data from the source bucket to the destination bucket.
The source bucket and destination bucket must be located in different regions and cannot have the same name.
For more information, see Cross-region replication.
Request structure
POST /?replication&comp=add HTTP/1.1 Date: GMT Date Content-Length: ContentLength Content-Type: application/xml Authorization: SignatureValue Host: BucketName.oss-cn-hangzhou.aliyuncs.com <?xml version="1.0" encoding="UTF-8"?> <ReplicationConfiguration> <Rule> <PrefixSet> <Prefix>prefix_1</Prefix> <Prefix>prefix_2</Prefix> </PrefixSet> <Action>ALL,PUT</Action> <Destination> <Bucket>Target Bucket Name</Bucket> <Location>cn-hangzhou</Location> <TransferType>oss_acc</TransferType> </Destination> <HistoricalObjectReplication>enabled or disabled</HistoricalObjectReplication> </Rule> </ReplicationConfiguration>
Request elements
Parameter | Type | Required | Description |
---|---|---|---|
ReplicationConfiguration | Container | Yes | The container that is used to store CRR rules. Parent nodes: none Child nodes: Rule |
Rule | Container | Yes | The container that is used to store the CRR rule. Parent nodes: ReplicationConfiguration Child nodes: Destination, HistoricalObjectReplication, and ID |
ID | String | No | The ID of the CRR rule corresponding to the CRR task. The ID of a CRR rule can be up to 255 characters in length and is globally unique in a bucket. If the ID of a CRR rule is null or is not specified, OSS generates a unique ID for the CRR rule. Parent nodes: Rule Child nodes: none |
PrefixSet | Container | No | The container that is used to store prefixes.You can specify up to 10 prefixes in each CRR rule. Parent nodes: Rule Child nodes: Prefix |
Prefix | String | No | The prefix used to specify the object to replicate.Only objects that match the prefix are replicated to the destination bucket.
Parent nodes: PrefixSet Child nodes: none |
Action | String | No | The operations that can be synchronized to the destination bucket.If you configure Action in a CRR rule, CRR synchronizes new data and historical data based on the Action specified. You can set Action to one or more of the following operation types. Valid values:
Parent nodes: Rule Child nodes: none |
Destination | Container | Yes | The container that is used to store the information about the destination bucket. Parent nodes: Rule Child nodes: Bucket and Location |
Bucket | String | Yes | The destination bucket to which the data is replicated. Parent nodes: Destination Child nodes: none |
Location | String | Yes | The region in which the destination bucket is located. Parent nodes: Destination Child nodes: none |
TransferType | String | Yes | The link used to transfer data in CRR. Default value: internal. Valid values:
Parent nodes: Destination Child nodes: none |
HistoricalObjectReplication | String | No | Specifies whether to replicate historical datafrom the source bucket to the destination bucket before CRR is enabled. Default value: Enabled. Valid values:
Parent nodes: Rule Child nodes: none |
SyncRole | String | No | The role that you authorize OSS to use to replicate data.If SSE-KMS is specified to encrypt the objects replicated to the destination bucket, SyncRole must be specified. |
SourceSelectionCriteria | Container | No | The container that specifies other conditions used to filter the source objects to replicate.Filter conditions can be specified for only source objects encrypted by using SSE-KMS. |
SseKmsEncryptedObjects | Container | No | The container used to filter source objects encrypted by using SSE-KMS.This element must be specified if SourceSelectionCriteria is specified in the CRR rule. |
Status | String | No | Specifies whether to replicate objects encrypted by using SSE-KMS. |
EncryptionConfiguration | Container | No | The encryption configuration of the objects replicated to the destination bucket. |
ReplicaKmsKeyID | String | No | The CMK ID used in SSE-KMS. |
Examples
Sample requests
POST /?replication&comp=add HTTP/1.1 Host: oss-example.oss-cn-hangzhou.aliyuncs.com Content-Type: application/xml Content-Length: 186 Date: Thu, 24 Sep 2015 15:39:12 GMT Authorization: OSS qn6qrrqxo2oawuk53otf****:KU5h8YMUC78M30dXqf3JxrTZ**** <?xml version="1.0" encoding="UTF-8"?> <ReplicationConfiguration> <Rule> <ID>test_replication_1</ID> <PrefixSet> <Prefix>source_image</Prefix> <Prefix>video</Prefix> </PrefixSet> <Action>PUT</Action> <Destination> <Bucket>target-bucket</Bucket> <Location>oss-cn-beijing</Location> <TransferType>oss_acc</TransferType> </Destination> <HistoricalObjectReplication>enabled</HistoricalObjectReplication> <SyncRole>acs:ram::174649585760****:role/aliyunramrole</SyncRole> <SourceSelectionCriteria> <SseKmsEncryptedObjects> <Status>Enabled</Status> </SseKmsEncryptedObjects> </SourceSelectionCriteria> <EncryptionConfiguration> <ReplicaKmsKeyID>c4d49f85-ee30-426b-a5ed-95e9139d****</ReplicaKmsKeyID> </EncryptionConfiguration> </Rule> </ReplicationConfiguration>
Sample responses
HTTP/1.1 200 OK x-oss-request-id: 534B371674E88A4D8906**** Date: Thu, 24 Sep 2015 15:39:12 GMT Content-Length: 0 Connection: close Server: AliyunOSS
Error codes
Error code | HTTP status code | Description |
---|---|---|
InvalidTargetBucket | 400 BadRequest |
|
InvalidTargetLocation | 400 BadRequest | The error message returned because the region of the destination bucket is different from the region specified in the XML body of the request. |
BucketReplicationAlreadyExist | 400 BadRequest | The error message returned because a CRR rule already exist between the source bucket and destination bucket. To configure a CRR rule between the source bucket and destination bucket, delete the existing rule. |
BadReplicationLocation | 400 BadRequest | The error message returned because the region of the destination bucket is invalid. You can call the GetBucketReplicationLocation operation to query valid regions in which the destination bucket can be located. |
NoReplicationLocation | 400 BadRequest | The error message returned because the region of the source bucket does not have a matching region for which CRR can be configured. For more information about the matching regions for which CRR can be configured, see Regions and endpoints. |
TooManyReplicationRules | 400 BadRequest | The error message returned because more than one CRR rule is configured in the request. You can configure only one CRR rule in a single request. |
TooManyIncomingReplication | 400 BadRequest | The error message returned because 100 CRR rules are configured for the bucket.Delete the rules that you no longer use and try again. You can configure up to 100 CRR rules for a bucket.If your business requirements are not met due to the limit, submit a ticket. |
TooManyOutgoingReplication | 400 BadRequest | The error message returned because 100 CRR rules are configured for the bucket.Delete the rules that you no longer use and try again. You can configure up to 100 CRR rules for a bucket.If your business business requires more than 100 CCR rules for a bucket, submit a ticket. |
MissingArgument | 400 BadRequest | The error message returned because the transmission link is not specified. |
InvalidArgument | 400 BadRequest | The error message returned because the specified transmission link is not supported. |