python - Python Boto3 PutBucketReplication 操作:您提供的 XML 格式不正确或未针对我们发布的架构进行验证
问题描述
我正在尝试使用 python boto3 更新存储桶的复制规则。但我不断收到错误: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
我正在按照此处的文档执行此操作:https ://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.put_bucket_replication
这是我正在运行的函数。谁能看到我传递的 xml 有什么问题?
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)
解决方案
我遇到了同样的问题,按照 (stackoverflow.com/a/57778885/9931092) 的回答为我工作,这是我的工作代码示例:
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)
推荐阅读
- python - 使用python的排队系统问题
- javascript - TypeError:无法解析模块说明符“remarkable”。相对引用必须以“/”、“./”或“../”开头
- javascript - 如何让 navigator.share 为 Facebook 工作?
- javascript - 在辅助函数中调用上下文函数 - React
- regex - 可选的千位分隔符处理不完整的字符串
- c++ - C ++:如何更改表达式模板以处理无限数量的总和?
- typescript - 使用泛型在另一个参数中重用第一个参数的键
- android - 未解决的参考:getTargetUrlFromInboundIntent FacebookSDK
- r - 如何解决错误:第 1 列必须在 R 中命名
- node.js - 尝试使用 tus 上传到 vimeo 时出现“内容长度 0 太小”