dredbound
dredbound

Reputation: 1659

Python Boto3 PutBucketReplication operation: The XML you provided was not well-formed or did not validate against our published schema

I'm trying to update the bucket's replication rule using python boto3. But I keep getting the error: botocore.exceptions.ClientError: An error occurred (MalformedXML) when calling the PutBucketReplication operation: The XML you provided was not well-formed or did not validate against our published schema

I'm following the documentation here to do this: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.put_bucket_replication

Here is my function that's getting run. Can anyone see what's wrong with the xml that I'm passing?

def apply_bucket_replication_rule(client):
    response = client.put_bucket_replication(
        Bucket= 'my-bucket',
            'Role': 'arn:aws:iam::0123456:role/replicate_s3_buckets',
            'Rules': [
                {
                    'Status': 'Enabled',
                    'Destination': {
                        'Bucket': 'arn:aws:s3:::my-bucket-backup',
                        'Account': '111222333'
                    }
                }
            ]
        },
    )
    print (response)

Upvotes: 4

Views: 2980

Answers (1)

Luan Kevin Ferreira
Luan Kevin Ferreira

Reputation: 1380

I was with the same problem, following the answer of (stackoverflow.com/a/57778885/9931092) worked for me, that's my example of working code:

def apply_bucket_replication_rule(client):
response = client.put_bucket_replication(
    Bucket='mybucket',
    ReplicationConfiguration={
        'Role': 'arn:aws:iam::0123456:role/replicate_s3_buckets',
        'Rules': [
            {
                "Status": "Disabled",
                "Priority": 1,
                "DeleteMarkerReplication": {"Status": "Disabled"},
                "Filter": {"Prefix": ""},
                "Destination": {
                    "Bucket": "arn:aws:s3:::my-bucket-backup",
                    "Account": "111222333"
                }
            }
        ]
    }
)
print(response)

Upvotes: 2

Related Questions