41

We currently have an S3 bucket policy which makes everything public.

At the moment we a bucket "bucket1" and inside there are numbered sub folders for each entry numbers 01 upwards (e.g. 01, 02, 03) and inside that always a folder called "128".

What we want to do is make the files in the 128 folders always public.

So we'd need something to allow "bucket1/*/128" and everything else only be accessible with a time stamped signature.

Presuming this is possible but wouldn't know how to create the statement.

2 Answers 2

84

I've done it!

I was trying all kinds of long-winded over-thought methods to try and accomplish this including the little known "not resource" when all I needed to do was take the default "allow all" policy and apply it to my specified sub-folders!

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::BUCKETNAME/*/128/*"
        }
    ]
}

Note: Edited the resource name.

3
  • Which part is for specific sub folders? /128/??
    – Jin Kwon
    Commented Mar 6, 2018 at 10:53
  • @JinKwon Yes exactly
    – RyanQuey
    Commented Feb 22, 2019 at 12:02
  • 1
    Does it work on S3 free tier? I'm trying this solution but it's giving me this error message Unsupported resource ARN in policy and I have no idea what that means Commented Feb 26 at 20:58
5

This seems to be blocked now..

This bucket has public access You have provided public access to this bucket. We highly recommend that you never grant any kind of public access to your S3 bucket.

2
  • That's just a warning, the items are still public like the warning implies
    – csvan
    Commented Aug 29, 2021 at 6:26
  • 1
    Funny how this supposed answer which ought to be a comment under the marked answer got upvoted because other people got similar issues
    – SmartE
    Commented Jan 6, 2022 at 10:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.