Basic setup via tutorial, can't figure out why I'm getting 403 errors

0

I've followed https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html to test my basic understanding and assumptions about permissions in S3 buckets and I'm running into 403 errors when I try to access the files in my bucket. I can see the files there -- they uploaded fine using collectstatic -- so it must be something basic regarding permissions.

I also worked through https://aws.amazon.com/premiumsupport/knowledge-center/s3-troubleshoot-403/ as far as I could get. I've verified that the files giving me 403 errors are owned by the same canonical ID of the bucket owner... I'm using the standard ACL policy that comes with a new bucket (bucket owner can list/write objects and read/write the bucket ACL)... I haven't added a bucket policy...

Basically, I'm working with a brand new bucket, as the tutorial suggests. I can upload files to it, but I can't read them.

This feels very basic. What am I missing? What should I check to track down why I'm getting the 403 errors?

More... To be clear about what I'm seeing. When the tutorial's home.html page loads, it shows these errors:

Failed to load resource: the server responded with a status of 403 (Forbidden)
https://snapdoor-tutorial.s3.amazonaws.com/static/css/app.css
Failed to load resource: the server responded with a status of 403 (Forbidden)
https://snapdoor-tutorial.s3.amazonaws.com/static/img/thumbs-up.png

The files are in the bucket at those locations.

Edited by: kohlab on May 19, 2021 6:28 PM

kohlab
已提问 3 年前238 查看次数
1 回答
0

After much experimentation, I've concluded that S3 policies have changed since the tutorial was written. Importantly, it seems access to objects is by default private. By adding the following bucket policy to my bucket's permissions, I got the files to display:

{
"Version": "2012-10-17",
"Id": "Policy1621539673651",
"Statement": [
{
"Sid": "Stmt1621539600741",
"Effect": "Allow",
"Principal": "",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::snaptut/static/
"
},
{
"Sid": "Stmt1621539665305",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::063892473623:user/snapdoor"
},
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::snaptut/*"
}
]
}

kohlab
已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则