-
-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3: An error occurred (403) when calling the HeadObject operation: Forbidden #1104
Comments
I've encountered a similar problem. Our stack trace looks basically identical, including the line numbers. I also encountered: An error occurred (403) when calling the HeadObject operation: Forbidden For us the problem was solved by properly configuring the bucket policy as described in https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#iam-policy. Since we are using a S3 compatible API and not AWS S3, we had to slightly alter the policy by separating the bucket and bucket object permissions into two separate statements instead of configuring them as a single one: {
"Sid": "userCRUDObject",
"Effect": "Allow",
"Principal": {
"AWS": [
"<your user here>"
]
},
"Action": [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::<bucket-name-here>/*"
]
},
{
"Sid": "userListBucket",
"Effect": "Allow",
"Principal": {
"AWS": [
"<your user here>"
]
},
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::<bucket-name-here>"
]
} Before, we were using the bucket without the s3:ListBucket permission, because of a misconfiguration. Hope this helps. However, I am a bit confused why this only happened in 1.12.3, but not in 1.11.1. |
@andreasschmitz Thanks a lot for sharing this information, we will also check our S3 configs. +1 for finding the related change in the library ;) |
@th3hamm0r it's because of changes in this commit: For full context, they are using Head object request to find out whether or not object exists in S3 bucket (more on this request here). It's response depends on the fact if file exists and what permissions you have:
In the mentioned comment, they changed the behavior (to correct one I must say), for checking if file exists:
although this is correct, I think some more log output or more specific error would be great, something like: |
I encountered the same issue and ensuring that the IAM user has these two permissions fixed the problem:
|
We've upgraded django-storages in a wagtail installation from 1.11.1 to 1.12.3, which seems to break the image admin when a thumbnail/rendition does not exist.
Maybe this has something to do with #1084/#1085 or #938?
Downgrading to 1.11.1 fixes the issue for now.
The text was updated successfully, but these errors were encountered: