使用aws命令行工具上传到s3的文件的403访问被拒绝错误 [英] 403 access denied error for files uploaded to s3 using aws command line tool

查看:33
本文介绍了使用aws命令行工具上传到s3的文件的403访问被拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用aws命令行工具将图像上传到s3.我不断收到403访问被拒绝的错误.

I'm trying to upload images to s3 using the aws command line tool. I keep getting a 403 access denied error.

我认为这里的--acl标志 http://docs.aws.amazon.com/cli/latest/reference/s3/cp.html 应该可以解决此问题,但我尝试过的所有选项都无济于事.

I think the --acl flag from here http://docs.aws.amazon.com/cli/latest/reference/s3/cp.html should fix this but all the options I've tried haven't helped.

我正在运行一个django应用程序,该应用程序可以上传到s3,并且可以正常访问这些图像.

I have a django app running which uploads to s3 and I can access those images fine.

推荐答案

您是否设置了任何IAM或存储桶策略以允许上传到存储桶?至少有3种方法可以使用户访问存储桶:

did you set any IAM or bucket policy to allow upload to your bucket? There is (at least) 3 ways to enable a user to access a bucket:

  • 在存储桶级别指定一个ACL(转到存储桶页面,选择您的存储桶,然后单击属性",您可以在其中授予更多访问权限)
  • 将策略附加到存储桶本身,例如:
  • specify an acl at the bucket level (go to the bucket page, select your bucket and click "properties", there you can grant more accesses)
  • attach a policy to the bucket itself, e.g to something like:

{"Version":"2012-10-17",陈述": [{"Sid":示例权限",效果":允许",主要的": {"AWS":了解用户或角色"},行动": ["s3:ListBucket","s3:GetBucketLocation","s3:PutObject"],资源":"arn:aws:s3 :::您的存储桶名称"}]}

{ "Version": "2012-10-17", "Statement": [ { "Sid": "Example permissions", "Effect": "Allow", "Principal": { "AWS": "arn of user or role" }, "Action": [ "s3:ListBucket", "s3:GetBucketLocation", "s3:PutObject" ], "Resource": "arn:aws:s3:::your bucket name" } ] }

  • 将策略附加到您的IAM用户,例如,授予管理员权限:转到IAM>用户>您的用户>附加策略> AmazonS3FullAccess
  • 如果您要建立自己的策略,则可以使用aws 策略生成器

    If you want to build your own policy, you can use the aws policy generator

    如果您需要更具体的帮助,请提供更多详细信息(哪些用户应该对您的存储桶具有哪些权限,等等)

    If you want more specific help, please provide more details (which users should have which permissions on your bucket, etc)

    希望这会有所帮助

    这篇关于使用aws命令行工具上传到s3的文件的403访问被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆