Syntax of a s3 bucket policy to wildcard SourceArn condition

0

This is the format of a bucket policy generated with a CloudFront using origin access:

        {
            "Effect": "Allow",
            "Principal": {
                "Service": "cloudfront.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::something-s3bucketroot-something/*",
            "Condition": {
                "StringEquals": {
                    "AWS:SourceArn": "arn:aws:cloudfront::0123456789:distribution/ABCDEFGHI"
                }
            }
        }

Is there a way to wildcard the SourceArn to allow for any distributions from the account? I tried "StringLike" and left off the distribution ID but that didn't seem to work. Alternatively, if that's not possible, is there a way to use an OR condition on multiple values on the conditional?

asked 5 months ago229 views
1 Answer
1
Accepted Answer

Yes this works. You need to use splat (wildcard)

"AWS:SourceArn": "arn:aws:cloudfront::0123456789:distribution/*"

profile picture
EXPERT
answered 5 months ago
  • Works! But you need StringLike instead of StringEquals...thought I'd tried that...

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions