Python Boto3 S3客户端。是否将存储桶放入日志记录()已损坏?

Python Boto3 S3客户端。是否将存储桶放入日志记录()已损坏?,python,debugging,amazon-s3,boto3,Python,Debugging,Amazon S3,Boto3,当我在boto3中调用以定义最近创建的bucket的日志文件的位置时,我收到以下错误: botocore.exceptions.ClientError: An error occurred (MalformedXML) when calling the PutBucketLogging operation: The XML you provided was not well-formed or did not validate against our published schema 在格

当我在boto3中调用以定义最近创建的bucket的日志文件的位置时,我收到以下错误:

botocore.exceptions.ClientError: An error occurred (MalformedXML) when calling the 
PutBucketLogging operation: The XML you provided was not well-formed or did not 
validate against our published schema
在格式不正确的情况下,Dxml错误表示:

当用户发送格式错误的xml(不正确的xml)时,就会发生这种情况 符合配置的已发布xsd规范。错误消息 是,“您提供的XML格式不正确或未验证 根据我们发布的模式。”

此方法的文档相当精简,但实际存在的内容没有提到将xml传递到参数中的任何内容。所以,我开始相信这可能是boto3的问题,而不是我传递给它的参数。我已经尝试进行调整以解决这个问题(只减少到所需的参数),并仔细检查了我的语法,但找不到解决方案。还有其他人遇到过这个问题吗

编辑:[修订]
答:下面

经过进一步调查,for client.create_bucket()方法似乎缺少“ACL”参数的一些关键选项。具体而言,它缺少:

ACL='log-delivery-write'

幸运的是,可以在@garnaat提供的AWS文档的链接中找到。谢谢你的指点

一旦我为日志bucket实现了这个选项,我就能够使用client.put_bucket_logging()为示例bucket启用日志记录

希望有特权的人有机会在某个时候调整S3的boto3文档。在文档中有一个关于的提示也很好,因为有很多方法可以向组授予权限。

Per--

您还可以使用:

s3c.put_bucket_acl(
    AccessControlPolicy = {
        "Owner": {
            "ID": "canonical_user_id_sdakfjldsakjf" # see https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
        },
        'Grants': [
            {
                'Grantee': {
                    'Type': 'Group',
                    'URI': 'http://acs.amazonaws.com/groups/s3/LogDelivery'
                },
                'Permission': 'WRITE'
            },
            {
                'Grantee': {
                    'Type': 'Group',
                    'URI': 'http://acs.amazonaws.com/groups/s3/LogDelivery'
                },
                'Permission': 'READ_ACP'
            }
        ]
    },
    Bucket=bucket
)

注意:Owner是必需的否则您将得到格式不正确的Dxml错误,即使文档当前未按要求列出它

您能说明您实际上是如何拨打电话的吗?你在传递什么?@gamaat。。。很抱歉。API文档()似乎建议,如果您使用的是CanonicalUser类型,则必须包括ID和DisplayName。
s3c.put_bucket_acl(
    AccessControlPolicy = {
        "Owner": {
            "ID": "canonical_user_id_sdakfjldsakjf" # see https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
        },
        'Grants': [
            {
                'Grantee': {
                    'Type': 'Group',
                    'URI': 'http://acs.amazonaws.com/groups/s3/LogDelivery'
                },
                'Permission': 'WRITE'
            },
            {
                'Grantee': {
                    'Type': 'Group',
                    'URI': 'http://acs.amazonaws.com/groups/s3/LogDelivery'
                },
                'Permission': 'READ_ACP'
            }
        ]
    },
    Bucket=bucket
)