您如何允许授予对上载到AWS S3的对象的公共读取访问权限?

西普里亚尼

我创建了一个策略,该策略允许访问帐户中的单个S3存储桶。然后,我创建了一个仅包含此策略的组,并且该组中包含一个用户。

用户可以按预期查看,删除文件并将其上传到存储桶。但是,用户似乎无法授予公众对上载文件的读取访问权限

在此处输入图片说明

选择授予对此对象的公共读取权限选项时,上传将失败。

该存储桶托管着一个静态网站,我想允许前端开发人员上传文件并将其公开。

用户角色的策略如下:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "s3:*"
        ],
        "Resource": "arn:aws:s3:::my-bucket"
    },
    {
        "Effect": "Allow",
        "Action": [
            "s3:*"
        ],
        "Resource": "arn:aws:s3:::my-bucket/*"
    }
  ]
}

This is what happens when the IAM user tries to grant public access to the uploaded file: 在此处输入图片说明

The proxy error seems unrelated, but essentially the upload is stuck and nothing happens. If they don't select the Grant public access option, the upload goes through immediately (despite the proxy error showing up as well).

John Rotenstein

To reproduce your situation, I did the following:

  • Created a new Amazon S3 bucket with default settings (Block Public Access = On)
  • Created an IAM User (with no policies attached)
  • Created an IAM Group (with no policies attached)
  • Added the IAM User to the IAM Group
  • Attached your policy (from the Question) to the IAM Group (updating the bucket name) as an inline policy
  • Logged into the Amazon S3 management console as the new IAM User

At this point, the user received an Access Denied error because they were not permitted to list all Amazon S3 buckets. Thus, the console was not usable.

Instead, I ran this AWS CLI command:

aws s3 cp foo.txt s3://new-bucket/ --acl public-read

The result was:

An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

However, the operation succeeded with:

aws s3 cp foo.txt s3://new-bucket/

This means that the --acl is the component that was denied.

I then went to Block Public Access for the bucket and turned OFF the option called "Block public access to buckets and objects granted through new access control lists (ACLs)". My settings were:

阻止公共访问

I then ran this command again:

aws s3 cp foo.txt s3://new-bucket/ --acl public-read

It worked!

为了验证这一点,我回到了阻止公共访问并打开了所有选项(通过顶部的复选框)。我重新运行了该命令,它再次拒绝访问确认原因是“阻止公共访问”设置

底线:关闭第一个“阻止公共访问”设置。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

您希望何时授予对 s3 存储桶的公共读取访问权限

仅授予特定用户对S3存储桶的访问权限,无公共访问权限

AWS:S3 存储桶 AWS 您无法授予公共访问权限,因为此帐户已启用阻止公共访问设置

S3存储桶AWS您无法授予公共访问权限,因为已为此帐户启用了阻止公共访问设置

将文件上传到AWS S3并授予公共访问权限

S3向用户授予对象访问权限

如何在授予公共访问权限的情况下将文件上传到AWS S3?

具有公共读取权限的AWS S3 putobject-.Net SDK

如何在Amazon S3存储桶上设置公共只读访问权限?

AWS S3:无法从具有公共访问权限的存储桶中获取非拥有对象(通过非身份验证方式)

AWS S3:关闭“存储桶阻止公共访问”时,拒绝访问对象

授予 aws s3 对 fargate 集群的读取权限

AWS为什么会警告“不要授予对此对象的公共读取访问权限(推荐)”

授予访问权限以读取Amazon S3存储桶中的子目录

对在Amazon S3中通过PutObjectRequest上传的对象授予读取权限

S3:如何授予对多个存储桶的访问权限?

如何更新AWS S3对象的ACL访问权限?

AWS S3 对象权限

如何从Amazon S3存储桶撤消公共权限

AWS:无法通过s3存储桶策略授予s3访问权限

如何授予AWS用户访问s3存储桶托管的网站的权限?

如何使用经过身份验证的经过身份验证的用户授予对非公共Amazon S3存储桶文件夹的访问权限

上载到AWS S3失败

根据角色名称授予对S3资源的访问权限

无法从S3获取对象元数据。在AWS Rekognition中检查对象密钥,区域和/或访问权限

我应该设置什么最低权限才能授予S3文件上载访问权限?

权限不足,无法在S3中访问数据-AWS

上载到S3,而不会暴露您的accessKeyId

有没有办法在不提供公共访问权限的情况下在 AWS S3 上托管静态网站?