I'm trying to restrict my bucket to deny everything, but allow uploads from one specific IAM user and get objects based on referer
header. Here is my policy:
{
"Version": "2012-10-17",
"Id": "Meteor refer policy",
"Statement": [
{
"Sid": "allow upload",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::556754141176:user/username"
},
"Action": "s3:PutObject*",
"Resource": [
"arn:aws:s3:::bucketname",
"arn:aws:s3:::bucketname/*"
]
},
{
"Sid": "Allow get",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "bucketname/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://myapp.com*",
"http://localhost*"
]
}
}
},
{
"Sid": "Explicit deny",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "bucketname/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"http://myapp.com*",
"http://localhost*"
]
}
}
}
]
}
This policy correctly enforces the GetObject directive to only the referer header, but I'm not able to upload anything with that user like I stated. If I take out the explicit deny, I can access the object from anywhere and the referer doesn't matter. What is wrong with my policy? Also, I can't access anything in the bucket from the console. What do I need to do for that?
Thanks,