Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S3 Invalid Resource in bucket policy

Tags:

amazon-s3

I'm trying to make my entire S3 bucket public, but when I try to add the policy:

{   "Id": "Policy1454540872039",   "Version": "2012-10-17",   "Statement": [     {       "Sid": "Stmt1454540868094",       "Action": [         "s3:GetObject"       ],       "Effect": "Allow",       "Resource": "arn:aws:s3:::sneakysnap/*",       "Principal": {       "AWS": [          "985506495298"     ]   }   }   ] } 

It tells me that my "Resource is invalid", but that is definitely the right arn and that is definitely the right bucket name. Anyone know what's going on?

like image 701
Isaac Wasserman Avatar asked Feb 03 '16 23:02

Isaac Wasserman


People also ask

How do I fix an AWS S3 bucket policy and Public permissions access denied error?

If you're denied permissions, then use another IAM identity that has bucket access, and edit the bucket policy. Or, delete and recreate the bucket policy if no one has access to it. If you're trying to add a public read policy, then disable the bucket's S3 Block Public Access.

Why am I getting the error invalid principal in policy when I try to update my Amazon S3 bucket policy?

You receive the "Error: Invalid principal in policy" message when the value of a Principal in your bucket policy is not valid. To resolve this error, confirm the following: Your bucket policy uses supported values for a Principal element. The Principal value is formatted correctly.

Does bucket policy override IAM policy?

Simple rule: If anything amongst IAM & Bucket Policy denies, then it is denied. Otherwise, if any of them allows, then it is allowed.

Why is my S3 Access Denied?

If you're getting Access Denied errors on public read requests that are allowed, check the bucket's Amazon S3 block public access settings. Review the S3 Block Public Access settings at both the account and bucket level. These settings can override permissions that allow public read access.


2 Answers

I had this "problem" when I was trying to set a policy on the wrong bucket. That is, my arn in the policy was reading arn:aws:s3:::my-bucket-A/* but I was attempting to set it on my-bucket-B

like image 81
vitaly Avatar answered Sep 26 '22 06:09

vitaly


I had solved the problem by this

arn:aws:s3:::your-bucket-name-here/*

'

like image 38
iamsohel Avatar answered Sep 24 '22 06:09

iamsohel