python - 为 boto 脚本提供的 XML 格式不正确
问题描述
我正在开发一个启用 S3 存储桶跨区域复制的 boto 脚本,我的脚本遵循了这个“https://stackoverflow.com/a/57778885/9931092”答案,该脚本似乎对我来说很好,但它没有ExistingObjectReplication
作为代码的一部分,并且在添加时不会使代码运行。这是我的 boto 脚本:
import boto3
s3_client = boto3.client('s3')
response = s3_client.put_bucket_versioning(
Bucket='cross-test-6',
VersioningConfiguration={
'Status': 'Enabled'
},
)
response = s3_client.put_bucket_versioning(
Bucket='cross-test-7',
VersioningConfiguration={
'Status': 'Enabled'
},
)
##Enable
s3_client.put_bucket_replication(Bucket='cross-test-6',
ReplicationConfiguration={
"Role": "arn:aws:iam::196687784845:role/test",
"Rules": [
{
"Status": "Enabled",
"Priority": 1,
"DeleteMarkerReplication": { "Status": "Disabled" },
"ExistingObjectReplication": { "Status": "Enabled" },
"Filter" : { "Prefix": ""},
"Destination": {
"Bucket": "arn:aws:s3:::cross-test-7",
"Account": "196687784845"
},
}
]
}
)
这是我得到的回溯:
Traceback (most recent call last):
File "/home/pranay/Desktop/Amit/main-2.py", line 21, in <module>
s3_client.put_bucket_replication(Bucket='cross-test-6',
File "/home/pranay/.local/lib/python3.8/site-packages/botocore/client.py", line 337, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/pranay/.local/lib/python3.8/site-packages/botocore/client.py", line 656, in _make_api_call
raise error_class(parsed_response, operation_name)
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
我怀疑官方文档有'ExistingObjectReplication'
而不是 "ExistingObjectReplication"
,尽管我也尝试过并且得到了同样的错误。
解决方案
推荐阅读
- r - 使用 pheatmap 在组内聚类
- clojure - Clojure 在验证中使用来自另一个必需键的值
- opengl - Why can I use GL_QUADS with glDrawArrays?
- windows - Windows 8/10 API Detect suspended process
- javascript - javascript 从数组创建嵌套的 JSON 数组
- dart - 如何在 BottomNavigationBarItem 中绝对定位徽章
- html - 对齐框内的图像、文本和标题
- python - 从匿名生成器构造列表的 Pythonic 习语
- laravel - Laravel - 如何在应用服务提供商中获取用户 ID
- php - 用户删除商品时如何自动更新购物车?