ALIYUN::OSS::BucketReplication

ALIYUN::OSS::BucketReplication类型用于为存储空间(Bucket)指定数据复制规则。

语法

{
  "Type": "ALIYUN::OSS::BucketReplication",
  "Properties": {
    "BucketName": String,
    "ReplicationConfiguration": Map
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

BucketName

String

指定数据要复制到的目标Bucket。

ReplicationConfiguration

Map

配置Bucket数据复制规则的容器。

更多信息,请参考ReplicationConfiguration属性

ReplicationConfiguration语法

"ReplicationConfiguration": {
  "Rule": Map
}

ReplicationConfiguration属性

属性名称

类型

必须

允许更新

描述

约束

Rule

Map

保存数据复制规则的容器。

更多信息,请参考Rule属性

Rule语法

"Rule": {
  "RTC": Map,
  "Destination": Map,
  "Action": String,
  "SyncRole": String,
  "EncryptionConfiguration": Map,
  "SourceSelectionCriteria": Map,
  "PrefixSet": List,
  "Id": String,
  "HistoricalObjectReplication": String
}

Rule属性

属性名称

类型

必须

允许更新

描述

约束

Destination

Map

保存目标Bucket信息的容器。

Action

String

指定可以被复制到目标Bucket的操作。

如果配置了Action,则新写入的数据和历史数据的同步都会遵循Action指定的复制操作。

Action允许以下操作类型,您可以指定一项或多项。

取值:

  • ALL(默认值):表示PUT、DELETE、ABORT操作均会被同步到目标Bucket。

    重要

    该策略下新增、更新和删除Object都会被复制到目标Bucket。通过这种方式,确保了数据的一致性,适用于需要共享和访问同一数据集的多用户或应用程序环境。但是配置该策略后,当手动删除或者通过生命周期自动删除源Bucket内的Object时,目标Bucket也会删除对应的Object,且Object删除后无法恢复。

  • PUT:表示被同步到目标Bucket的写入操作,包括PutObject、PostObject、AppendObject、CopyObject、PutObjectACL、InitiateMultipartUpload、UploadPart、UploadPartCopy、CompleteMultipartUpload。

    重要

    该策略下仅新增和更新的Object会被复制,而删除操作不会影响目标Bucket。通过这种方式,可以有效防止因源Bucket手动删除、通过生命周期自动删除的行为导致目标Bucket数据丢失的问题。

EncryptionConfiguration

Map

目标对象加密配置。

如果指定StatusEnabled,则必须指定该元素。

HistoricalObjectReplication

String

指定是否复制历史数据。

即开启数据复制前,是否将源Bucket中的数据复制到目标Bucket。

取值:

  • enabled(默认值):表示复制历史数据。

  • disabled:表示不复制历史数据。即仅复制创建数据复制规则后新写入的数据。

Id

String

数据复制规则的唯一标识。

PrefixSet

List

保存前缀(Prefix)的容器。

每条数据复制规则中,最多可指定10Prefix。

RTC

Map

数据复制时间控制功能的状态。

SyncRole

String

授权OSS使用哪个RAM角色来进行数据复制。

数据复制权限有同账号复制与跨账号复制两种使用场景。对于同账号与跨账号复制,您必须授予RAM角色相应的复制权限,否则无法完成复制任务。详情请参见数据复制权限介绍

SourceSelectionCriteria

Map

用于标识要复制的源对象的其他筛选条件的容器。

当前OSS仅支持针对SSE-KMS加密的源对象指定筛选条件。

RTC语法

"RTC": {
  "Status": String
}

RTC属性

属性名称

类型

必须

允许更新

描述

约束

Status

String

指定OSS是否复制通过SSE-KMS加密创建的对象。

取值范围如下:

  • Enabled:表示复制通过SSE-KMS加密创建的对象。

  • Disabled(默认值):表示不复制通过SSE-KMS加密创建的对象。

Destination语法

"Destination": {
  "Bucket": String,
  "TransferType": String,
  "Location": String
}

Destination属性

属性名称

类型

必须

允许更新

描述

约束

Bucket

String

指定数据要复制到的目标Bucket。

Location

String

目标Bucket所处的地域。

TransferType

String

指定数据复制时使用的数据传输链路。

取值:

  • internal(默认值):OSS默认传输链路。

  • oss_acc:传输加速链路。只有创建跨区域复制规则时才能使用传输加速链路。

EncryptionConfiguration语法

"EncryptionConfiguration": {
  "ReplicaKmsKeyID": String
}

EncryptionConfiguration属性

属性名称

类型

必须

允许更新

描述

约束

ReplicaKmsKeyID

String

指定SSE-KMS密钥ID。

如果指定StatusEnabled,则必须指定该元素。

SourceSelectionCriteria语法

"SourceSelectionCriteria": {
  "SseKmsEncryptedObjects": Map
}

SourceSelectionCriteria属性

属性名称

类型

必须

允许更新

描述

约束

SseKmsEncryptedObjects

Map

用于筛选使用SSE-KMS加密对象的容器。

如果在数据复制规则中指定了SourceSelectionCriteria,则必须指定该元素。

SseKmsEncryptedObjects语法

"SseKmsEncryptedObjects": {
  "Status": String
}

SseKmsEncryptedObjects属性

属性名称

类型

必须

允许更新

描述

约束

Status

String

指定OSS是否复制通过SSE-KMS加密创建的对象。

取值范围如下:

  • Enabled:表示复制通过SSE-KMS加密创建的对象。

  • Disabled(默认值):表示不复制通过SSE-KMS加密创建的对象。

返回值

Fn::GetAtt

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  BucketName:
    Type: String
    Description:
      en: Bucket name.
    Required: true
  ReplicationConfiguration:
    AssociationPropertyMetadata:
      Parameters:
        Rule:
          AssociationPropertyMetadata:
            Parameters:
              RTC:
                AssociationPropertyMetadata:
                  Parameters:
                    Status:
                      Type: String
                      Description:
                        en: Whether to enable real-time replication.
                      AllowedValues:
                        - enabled
                        - disabled
                      Required: false
                Type: Json
                Required: false
              Destination:
                AssociationPropertyMetadata:
                  Parameters:
                    Bucket:
                      Type: String
                      Description:
                        en: Destination bucket name.
                      Required: true
                    TransferType:
                      Type: String
                      Description:
                        en: Transfer type for replication.
                      AllowedValues:
                        - internal
                        - accelerate
                      Required: true
                      Default: internal
                    Location:
                      Type: String
                      Description:
                        en: Destination region.
                      Required: true
                Type: Json
                Description:
                  en: Destination bucket and location for replication.
                Required: true
              Action:
                Type: String
                Description:
                  en: Action to be taken on matching objects. Valid values are ALL, PUT, DELETE.
                AllowedValues:
                  - ALL
                  - PUT
                  - DELETE
                Required: false
              SyncRole:
                Type: String
                Description:
                  en: Role used for replication synchronization.
                Required: false
              EncryptionConfiguration:
                AssociationPropertyMetadata:
                  Parameters:
                    ReplicaKmsKeyID:
                      Type: String
                      Description:
                        en: ARN of the KMS key used to encrypt replica objects.
                      Required: false
                Type: Json
                Required: false
              SourceSelectionCriteria:
                AssociationPropertyMetadata:
                  Parameters:
                    SseKmsEncryptedObjects:
                      AssociationPropertyMetadata:
                        Parameters:
                          Status:
                            Type: String
                            Description:
                              en: Status of KMS encrypted object replication.
                            AllowedValues:
                              - Enabled
                              - Disabled
                            Required: false
                      Type: Json
                      Required: false
                Type: Json
                Description:
                  en: Criteria for selecting source objects.
                Required: false
              PrefixSet:
                AssociationPropertyMetadata:
                  Parameter:
                    Type: String
                    Required: false
                AssociationProperty: List[Parameter]
                Type: Json
                Description:
                  en: List of prefixes to which this rule applies.
                Required: false
              Id:
                Type: String
                Description:
                  en: ID of the rule applied.
                Required: false
              HistoricalObjectReplication:
                Type: String
                Description:
                  en: Whether to replicate existing objects.
                AllowedValues:
                  - enabled
                  - disabled
                Required: false
          Type: Json
          Description:
            en: Replication Rule
          Required: true
    Type: Json
    Description:
      en: Replication configuration.
    Required: true
Resources:
  Replication:
    Type: ALIYUN::OSS::BucketReplication
    Properties:
      BucketName:
        Ref: BucketName
      ReplicationConfiguration:
        Ref: ReplicationConfiguration
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "BucketName": {
      "Type": "String",
      "Description": {
        "en": "Bucket name."
      },
      "Required": true
    },
    "ReplicationConfiguration": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "Rule": {
            "AssociationPropertyMetadata": {
              "Parameters": {
                "RTC": {
                  "AssociationPropertyMetadata": {
                    "Parameters": {
                      "Status": {
                        "Type": "String",
                        "Description": {
                          "en": "Whether to enable real-time replication."
                        },
                        "AllowedValues": [
                          "enabled",
                          "disabled"
                        ],
                        "Required": false
                      }
                    }
                  },
                  "Type": "Json",
                  "Required": false
                },
                "Destination": {
                  "AssociationPropertyMetadata": {
                    "Parameters": {
                      "Bucket": {
                        "Type": "String",
                        "Description": {
                          "en": "Destination bucket name."
                        },
                        "Required": true
                      },
                      "TransferType": {
                        "Type": "String",
                        "Description": {
                          "en": "Transfer type for replication."
                        },
                        "AllowedValues": [
                          "internal",
                          "accelerate"
                        ],
                        "Required": true,
                        "Default": "internal"
                      },
                      "Location": {
                        "Type": "String",
                        "Description": {
                          "en": "Destination region."
                        },
                        "Required": true
                      }
                    }
                  },
                  "Type": "Json",
                  "Description": {
                    "en": "Destination bucket and location for replication."
                  },
                  "Required": true
                },
                "Action": {
                  "Type": "String",
                  "Description": {
                    "en": "Action to be taken on matching objects. Valid values are ALL, PUT, DELETE."
                  },
                  "AllowedValues": [
                    "ALL",
                    "PUT",
                    "DELETE"
                  ],
                  "Required": false
                },
                "SyncRole": {
                  "Type": "String",
                  "Description": {
                    "en": "Role used for replication synchronization."
                  },
                  "Required": false
                },
                "EncryptionConfiguration": {
                  "AssociationPropertyMetadata": {
                    "Parameters": {
                      "ReplicaKmsKeyID": {
                        "Type": "String",
                        "Description": {
                          "en": "ARN of the KMS key used to encrypt replica objects."
                        },
                        "Required": false
                      }
                    }
                  },
                  "Type": "Json",
                  "Required": false
                },
                "SourceSelectionCriteria": {
                  "AssociationPropertyMetadata": {
                    "Parameters": {
                      "SseKmsEncryptedObjects": {
                        "AssociationPropertyMetadata": {
                          "Parameters": {
                            "Status": {
                              "Type": "String",
                              "Description": {
                                "en": "Status of KMS encrypted object replication."
                              },
                              "AllowedValues": [
                                "Enabled",
                                "Disabled"
                              ],
                              "Required": false
                            }
                          }
                        },
                        "Type": "Json",
                        "Required": false
                      }
                    }
                  },
                  "Type": "Json",
                  "Description": {
                    "en": "Criteria for selecting source objects."
                  },
                  "Required": false
                },
                "PrefixSet": {
                  "AssociationPropertyMetadata": {
                    "Parameter": {
                      "Type": "String",
                      "Required": false
                    }
                  },
                  "AssociationProperty": "List[Parameter]",
                  "Type": "Json",
                  "Description": {
                    "en": "List of prefixes to which this rule applies."
                  },
                  "Required": false
                },
                "Id": {
                  "Type": "String",
                  "Description": {
                    "en": "ID of the rule applied."
                  },
                  "Required": false
                },
                "HistoricalObjectReplication": {
                  "Type": "String",
                  "Description": {
                    "en": "Whether to replicate existing objects."
                  },
                  "AllowedValues": [
                    "enabled",
                    "disabled"
                  ],
                  "Required": false
                }
              }
            },
            "Type": "Json",
            "Description": {
              "en": "Replication Rule"
            },
            "Required": true
          }
        }
      },
      "Type": "Json",
      "Description": {
        "en": "Replication configuration."
      },
      "Required": true
    }
  },
  "Resources": {
    "Replication": {
      "Type": "ALIYUN::OSS::BucketReplication",
      "Properties": {
        "BucketName": {
          "Ref": "BucketName"
        },
        "ReplicationConfiguration": {
          "Ref": "ReplicationConfiguration"
        }
      }
    }
  }
}