Amazon Simple Storage Service

2019/11/18 - Amazon Simple Storage Service - 2 updated api methods

Changes  Added support for S3 Replication for existing objects. This release allows customers who have requested and been granted access to replicate existing S3 objects across buckets.

GetBucketReplication (updated) Link ¶
Changes (response)
{'ReplicationConfiguration': {'Rules': {'ExistingObjectReplication': {'Status': 'Enabled '
                                                                                '| '
                                                                                'Disabled'}}}}

Returns the replication configuration of a bucket.

Note

It can take a while to propagate the put or delete a replication configuration to all Amazon S3 systems. Therefore, a get request soon after put or delete can return a wrong result.

For information about replication configuration, see Replication.

This operation requires permissions for the s3:GetReplicationConfiguration action. For more information about permissions, see Using Bucket Policies and User Policies.

If you include the Filter element in a replication configuration, you must also include the DeleteMarkerReplication and Priority elements. The response also returns those elements.

GetBucketReplication has the following special error:

  • Error code: NoSuchReplicationConfiguration

    • Description: There is no replication configuration with that name.

    • HTTP Status Code: 404 Not Found

    • SOAP Fault Code Prefix: Client

The following operations are related to GetBucketReplication :

  • PutBucketReplication

  • DeleteBucketReplication

See also: AWS API Documentation

Request Syntax

client.get_bucket_replication(
    Bucket='string'
)
type Bucket

string

param Bucket

[REQUIRED]

The bucket name for which to get the replication information.

rtype

dict

returns

Response Syntax

{
    'ReplicationConfiguration': {
        'Role': 'string',
        'Rules': [
            {
                'ID': 'string',
                'Priority': 123,
                'Prefix': 'string',
                'Filter': {
                    'Prefix': 'string',
                    'Tag': {
                        'Key': 'string',
                        'Value': 'string'
                    },
                    'And': {
                        'Prefix': 'string',
                        'Tags': [
                            {
                                'Key': 'string',
                                'Value': 'string'
                            },
                        ]
                    }
                },
                'Status': 'Enabled'|'Disabled',
                'SourceSelectionCriteria': {
                    'SseKmsEncryptedObjects': {
                        'Status': 'Enabled'|'Disabled'
                    }
                },
                'ExistingObjectReplication': {
                    'Status': 'Enabled'|'Disabled'
                },
                'Destination': {
                    'Bucket': 'string',
                    'Account': 'string',
                    'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE',
                    'AccessControlTranslation': {
                        'Owner': 'Destination'
                    },
                    'EncryptionConfiguration': {
                        'ReplicaKmsKeyID': 'string'
                    }
                },
                'DeleteMarkerReplication': {
                    'Status': 'Enabled'|'Disabled'
                }
            },
        ]
    }
}

Response Structure

  • (dict) --

    • ReplicationConfiguration (dict) --

      A container for replication rules. You can add up to 1,000 rules. The maximum size of a replication configuration is 2 MB.

      • Role (string) --

        The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that Amazon S3 assumes when replicating objects. For more information, see How to Set Up Replication in the Amazon Simple Storage Service Developer Guide .

      • Rules (list) --

        A container for one or more replication rules. A replication configuration must have at least one rule and can contain a maximum of 1,000 rules.

        • (dict) --

          Specifies which Amazon S3 objects to replicate and where to store the replicas.

          • ID (string) --

            A unique identifier for the rule. The maximum value is 255 characters.

          • Priority (integer) --

            The priority associated with the rule. If you specify multiple rules in a replication configuration, Amazon S3 prioritizes the rules to prevent conflicts when filtering. If two or more rules identify the same object based on a specified filter, the rule with higher priority takes precedence. For example:

            • Same object quality prefix based filter criteria If prefixes you specified in multiple rules overlap

            • Same object qualify tag based filter criteria specified in multiple rules

            For more information, see Replication in the Amazon S3 Developer Guide .

          • Prefix (string) --

            An object keyname prefix that identifies the object or objects to which the rule applies. The maximum prefix length is 1,024 characters. To include all objects in a bucket, specify an empty string.

          • Filter (dict) --

            A filter that identifies the subset of objects to which the replication rule applies. A Filter must specify exactly one Prefix , Tag , or an And child element.

            • Prefix (string) --

              An object keyname prefix that identifies the subset of objects to which the rule applies.

            • Tag (dict) --

              A container for specifying a tag key and value.

              The rule applies only to objects that have the tag in their tag set.

              • Key (string) --

                Name of the tag.

              • Value (string) --

                Value of the tag.

            • And (dict) --

              A container for specifying rule filters. The filters determine the subset of objects to which the rule applies. This element is required only if you specify more than one filter. For example:

              • If you specify both a Prefix and a Tag filter, wrap these filters in an And tag.

              • If you specify a filter based on multiple tags, wrap the Tag elements in an And tag.

              • Prefix (string) --

                An object keyname prefix that identifies the subset of objects to which the rule applies.

              • Tags (list) --

                An array of tags containing key and value pairs.

                • (dict) --

                  A container of a key value name pair.

                  • Key (string) --

                    Name of the tag.

                  • Value (string) --

                    Value of the tag.

          • Status (string) --

            Specifies whether the rule is enabled.

          • SourceSelectionCriteria (dict) --

            A container that describes additional filters for identifying the source objects that you want to replicate. You can choose to enable or disable the replication of these objects. Currently, Amazon S3 supports only the filter that you can specify for objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service (SSE-KMS).

            • SseKmsEncryptedObjects (dict) --

              A container for filter information for the selection of Amazon S3 objects encrypted with AWS KMS. If you include SourceSelectionCriteria in the replication configuration, this element is required.

              • Status (string) --

                Specifies whether Amazon S3 replicates objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service.

          • ExistingObjectReplication (dict) --

            A container that specifies information about existing object replication. You can choose whether to enable or disable the replication of existing objects.

            • Status (string) --

              Specifies whether existing object replication is enabled.

          • Destination (dict) --

            A container for information about the replication destination.

            • Bucket (string) --

              The Amazon Resource Name (ARN) of the bucket where you want Amazon S3 to store the results.

            • Account (string) --

              Destination bucket owner account ID. In a cross-account scenario, if you direct Amazon S3 to change replica ownership to the AWS account that owns the destination bucket by specifying the AccessControlTranslation property, this is the account ID of the destination bucket owner. For more information, see Replication Additional Configuration: Change Replica Owner in the Amazon Simple Storage Service Developer Guide .

            • StorageClass (string) --

              The storage class to use when replicating objects, such as standard or reduced redundancy. By default, Amazon S3 uses the storage class of the source object to create the object replica.

              For valid values, see the StorageClass element of the PUT Bucket replication action in the Amazon Simple Storage Service API Reference .

            • AccessControlTranslation (dict) --

              Specify this only in a cross-account scenario (where source and destination bucket owners are not the same), and you want to change replica ownership to the AWS account that owns the destination bucket. If this is not specified in the replication configuration, the replicas are owned by same AWS account that owns the source object.

              • Owner (string) --

                Specifies the replica ownership. For default and valid values, see PUT bucket replication in the Amazon Simple Storage Service API Reference .

            • EncryptionConfiguration (dict) --

              A container that provides information about encryption. If SourceSelectionCriteria is specified, you must specify this element.

              • ReplicaKmsKeyID (string) --

                Specifies the AWS KMS Key ID (Key ARN or Alias ARN) for the destination bucket. Amazon S3 uses this key to encrypt replica objects.

          • DeleteMarkerReplication (dict) --

            Specifies whether Amazon S3 replicates the delete markers. If you specify a Filter , you must specify this element. However, in the latest version of replication configuration (when Filter is specified), Amazon S3 doesn't replicate delete markers. Therefore, the DeleteMarkerReplication element can contain only <Status>Disabled</Status>. For an example configuration, see Basic Rule Configuration.

            Note

            If you don't specify the Filter element, Amazon S3 assumes the replication configuration is the earlier version, V1. In the earlier version, Amazon S3 handled replication of delete markers differently. For more information, see Backward Compatibility.

            • Status (string) --

              Indicates whether to replicate delete markers.

              Note

              In the current implementation, Amazon S3 doesn't replicate the delete markers. The status must be Disabled .

PutBucketReplication (updated) Link ¶
Changes (request)
{'ReplicationConfiguration': {'Rules': {'ExistingObjectReplication': {'Status': 'Enabled '
                                                                                '| '
                                                                                'Disabled'}}}}

Creates a replication configuration or replaces an existing one. For more information, see Replication in the Amazon S3 Developer Guide .

Note

To perform this operation, the user or role performing the operation must have the iam:PassRole permission.

Specify the replication configuration in the request body. In the replication configuration, you provide the name of the destination bucket where you want Amazon S3 to replicate objects, the IAM role that Amazon S3 can assume to replicate objects on your behalf, and other relevant information.

A replication configuration must include at least one rule, and can contain a maximum of 1,000. Each rule identifies a subset of objects to replicate by filtering the objects in the source bucket. To choose additional subsets of objects to replicate, add a rule for each subset. All rules must specify the same destination bucket.

To specify a subset of the objects in the source bucket to apply a replication rule to, add the Filter element as a child of the Rule element. You can filter objects based on an object key prefix, one or more object tags, or both. When you add the Filter element in the configuration, you must also add the following elements: DeleteMarkerReplication , Status , and Priority .

For information about enabling versioning on a bucket, see Using Versioning.

By default, a resource owner, in this case the AWS account that created the bucket, can perform this operation. The resource owner can also grant others permissions to perform the operation. For more information about permissions, see Specifying Permissions in a Policy and Managing Access Permissions to Your Amazon S3 Resources.

Handling Replication of Encrypted Objects

By default, Amazon S3 doesn't replicate objects that are stored at rest using server-side encryption with CMKs stored in AWS KMS. To replicate AWS KMS-encrypted objects, add the following: SourceSelectionCriteria , SseKmsEncryptedObjects , Status , EncryptionConfiguration , and ReplicaKmsKeyID . For information about replication configuration, see Replicating Objects Created with SSE Using CMKs stored in AWS KMS.

PutBucketReplication has the following special errors:

  • Error code: InvalidRequest

    • Description: If the <Owner> in <AccessControlTranslation> has a value, the <Account> element must be specified.

    • HTTP 400

  • Error code: InvalidArgument

    • Description: The <Account> element is empty. It must contain a valid account ID.

    • HTTP 400

  • Error code: InvalidArgument

    • Description: The AWS account specified in the <Account> element must match the destination bucket owner.

    • HTTP 400

The following operations are related to PutBucketReplication :

  • GetBucketReplication

  • DeleteBucketReplication

See also: AWS API Documentation

Request Syntax

client.put_bucket_replication(
    Bucket='string',
    ContentMD5='string',
    ReplicationConfiguration={
        'Role': 'string',
        'Rules': [
            {
                'ID': 'string',
                'Priority': 123,
                'Prefix': 'string',
                'Filter': {
                    'Prefix': 'string',
                    'Tag': {
                        'Key': 'string',
                        'Value': 'string'
                    },
                    'And': {
                        'Prefix': 'string',
                        'Tags': [
                            {
                                'Key': 'string',
                                'Value': 'string'
                            },
                        ]
                    }
                },
                'Status': 'Enabled'|'Disabled',
                'SourceSelectionCriteria': {
                    'SseKmsEncryptedObjects': {
                        'Status': 'Enabled'|'Disabled'
                    }
                },
                'ExistingObjectReplication': {
                    'Status': 'Enabled'|'Disabled'
                },
                'Destination': {
                    'Bucket': 'string',
                    'Account': 'string',
                    'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE',
                    'AccessControlTranslation': {
                        'Owner': 'Destination'
                    },
                    'EncryptionConfiguration': {
                        'ReplicaKmsKeyID': 'string'
                    }
                },
                'DeleteMarkerReplication': {
                    'Status': 'Enabled'|'Disabled'
                }
            },
        ]
    },
    Token='string'
)
type Bucket

string

param Bucket

[REQUIRED]

The name of the bucket

type ContentMD5

string

param ContentMD5

The base64-encoded 128-bit MD5 digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see RFC 1864.

type ReplicationConfiguration

dict

param ReplicationConfiguration

[REQUIRED]

A container for replication rules. You can add up to 1,000 rules. The maximum size of a replication configuration is 2 MB.

  • Role (string) -- [REQUIRED]

    The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that Amazon S3 assumes when replicating objects. For more information, see How to Set Up Replication in the Amazon Simple Storage Service Developer Guide .

  • Rules (list) -- [REQUIRED]

    A container for one or more replication rules. A replication configuration must have at least one rule and can contain a maximum of 1,000 rules.

    • (dict) --

      Specifies which Amazon S3 objects to replicate and where to store the replicas.

      • ID (string) --

        A unique identifier for the rule. The maximum value is 255 characters.

      • Priority (integer) --

        The priority associated with the rule. If you specify multiple rules in a replication configuration, Amazon S3 prioritizes the rules to prevent conflicts when filtering. If two or more rules identify the same object based on a specified filter, the rule with higher priority takes precedence. For example:

        • Same object quality prefix based filter criteria If prefixes you specified in multiple rules overlap

        • Same object qualify tag based filter criteria specified in multiple rules

        For more information, see Replication in the Amazon S3 Developer Guide .

      • Prefix (string) --

        An object keyname prefix that identifies the object or objects to which the rule applies. The maximum prefix length is 1,024 characters. To include all objects in a bucket, specify an empty string.

      • Filter (dict) --

        A filter that identifies the subset of objects to which the replication rule applies. A Filter must specify exactly one Prefix , Tag , or an And child element.

        • Prefix (string) --

          An object keyname prefix that identifies the subset of objects to which the rule applies.

        • Tag (dict) --

          A container for specifying a tag key and value.

          The rule applies only to objects that have the tag in their tag set.

          • Key (string) -- [REQUIRED]

            Name of the tag.

          • Value (string) -- [REQUIRED]

            Value of the tag.

        • And (dict) --

          A container for specifying rule filters. The filters determine the subset of objects to which the rule applies. This element is required only if you specify more than one filter. For example:

          • If you specify both a Prefix and a Tag filter, wrap these filters in an And tag.

          • If you specify a filter based on multiple tags, wrap the Tag elements in an And tag.

          • Prefix (string) --

            An object keyname prefix that identifies the subset of objects to which the rule applies.

          • Tags (list) --

            An array of tags containing key and value pairs.

            • (dict) --

              A container of a key value name pair.

              • Key (string) -- [REQUIRED]

                Name of the tag.

              • Value (string) -- [REQUIRED]

                Value of the tag.

      • Status (string) -- [REQUIRED]

        Specifies whether the rule is enabled.

      • SourceSelectionCriteria (dict) --

        A container that describes additional filters for identifying the source objects that you want to replicate. You can choose to enable or disable the replication of these objects. Currently, Amazon S3 supports only the filter that you can specify for objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service (SSE-KMS).

        • SseKmsEncryptedObjects (dict) --

          A container for filter information for the selection of Amazon S3 objects encrypted with AWS KMS. If you include SourceSelectionCriteria in the replication configuration, this element is required.

          • Status (string) -- [REQUIRED]

            Specifies whether Amazon S3 replicates objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service.

      • ExistingObjectReplication (dict) --

        A container that specifies information about existing object replication. You can choose whether to enable or disable the replication of existing objects.

        • Status (string) -- [REQUIRED]

          Specifies whether existing object replication is enabled.

      • Destination (dict) -- [REQUIRED]

        A container for information about the replication destination.

        • Bucket (string) -- [REQUIRED]

          The Amazon Resource Name (ARN) of the bucket where you want Amazon S3 to store the results.

        • Account (string) --

          Destination bucket owner account ID. In a cross-account scenario, if you direct Amazon S3 to change replica ownership to the AWS account that owns the destination bucket by specifying the AccessControlTranslation property, this is the account ID of the destination bucket owner. For more information, see Replication Additional Configuration: Change Replica Owner in the Amazon Simple Storage Service Developer Guide .

        • StorageClass (string) --

          The storage class to use when replicating objects, such as standard or reduced redundancy. By default, Amazon S3 uses the storage class of the source object to create the object replica.

          For valid values, see the StorageClass element of the PUT Bucket replication action in the Amazon Simple Storage Service API Reference .

        • AccessControlTranslation (dict) --

          Specify this only in a cross-account scenario (where source and destination bucket owners are not the same), and you want to change replica ownership to the AWS account that owns the destination bucket. If this is not specified in the replication configuration, the replicas are owned by same AWS account that owns the source object.

          • Owner (string) -- [REQUIRED]

            Specifies the replica ownership. For default and valid values, see PUT bucket replication in the Amazon Simple Storage Service API Reference .

        • EncryptionConfiguration (dict) --

          A container that provides information about encryption. If SourceSelectionCriteria is specified, you must specify this element.

          • ReplicaKmsKeyID (string) --

            Specifies the AWS KMS Key ID (Key ARN or Alias ARN) for the destination bucket. Amazon S3 uses this key to encrypt replica objects.

      • DeleteMarkerReplication (dict) --

        Specifies whether Amazon S3 replicates the delete markers. If you specify a Filter , you must specify this element. However, in the latest version of replication configuration (when Filter is specified), Amazon S3 doesn't replicate delete markers. Therefore, the DeleteMarkerReplication element can contain only <Status>Disabled</Status>. For an example configuration, see Basic Rule Configuration.

        Note

        If you don't specify the Filter element, Amazon S3 assumes the replication configuration is the earlier version, V1. In the earlier version, Amazon S3 handled replication of delete markers differently. For more information, see Backward Compatibility.

        • Status (string) --

          Indicates whether to replicate delete markers.

          Note

          In the current implementation, Amazon S3 doesn't replicate the delete markers. The status must be Disabled .

type Token

string

param Token

returns

None