【问题标题】:S3 Object ownership: Bucket Owner Enforced - documentation bug?S3 对象所有权:强制存储桶所有者 - 文档错误?
【发布时间】:2022-01-09 00:41:10
【问题描述】:

我最近遇到了一个“错误”,即使使用S3FullAccess,我仍然会得到

An error occurred (403) when calling the HeadObject operation: Forbidden

运行aws s3api head-object --bucket cool-bucket --key my/key/to/file.png时。

经过一番研究,发现my/key/to/file.png 是匿名上传的,因此我作为经过身份验证的用户不是该对象的合法所有者,因此拒绝了我的 HEAD 请求。

解决方案似乎是 ACL 或将“对象所有权”更改为“禁用 ACL(强制执行存储桶所有者)”。

这确实是解决方案,所以我尝试更改我的 CloudFormation 模板,将 Object Ownership 设置为“Bucket Owner Enforced”,but the documentation lies.

确实,文档只指定了 Allowed values: ObjectWriter | BucketOwnerPreferred,但是当在我手动调整的存储桶上运行 aws s3api get-bucket-ownership-controls --bucket bucketname 时,我得到了以下 JSON:

{
    "OwnershipControls": {
        "Rules": [
            {
                "ObjectOwnership": "BucketOwnerEnforced"
            }
        ]
    }
}

清楚地表明 BucketOwnerEnforced 是 CloudFormation 属性 OwnershipControls.Rules.[].ObjectOwnership 的有效且允许的值。在文档中的其他任何地方,我都没有看到允许我将对象所有权设置为“桶所有者强制”并因此禁用 ACL 的属性。

为什么没有记录?我认为 CloudFormation 文档是自动生成的,可能不完整/过时。

【问题讨论】:

  • 看起来文档可能尚未更新以包含全新功能 BucketOwnerEnforced,该功能于昨天在 re:Invent 2021 上正式推出。
  • 感谢编辑!你说得对,我并没有密切关注 re:Invent。

标签: amazon-web-services amazon-s3 amazon-cloudformation acl


【解决方案1】:

属性OwnershipControls.Rules.[].ObjectOwnership 有一个秘密允许的值,称为BucketOwnerEnforced

可以这样使用:

  MyCoolBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: MyCoolBucket
      OwnershipControls:
        Rules:
          - ObjectOwnership: BucketOwnerEnforced

我在 2021 年 12 月 2 日测试并部署了这个模板,CloudFormation 没有抱怨它不是“允许值”。

【讨论】:

  • 我不会称之为“秘密”。看起来文档尚未更新以反映全新的选项(昨天推出)。
猜你喜欢
  • 2010-10-16
  • 2020-01-24
  • 2021-06-22
  • 2018-03-08
  • 2015-10-23
  • 2021-04-24
  • 2015-02-07
  • 1970-01-01
  • 2012-04-12
相关资源
最近更新 更多