unpangloss
unpangloss

Reputation: 409

Can I restrict access to S3 from a specific subdomain only?

I have several subdomains that will have their own S3 bucket. Is there a way to set S3 bucket to allow GET requests only from a specific subdomain?

Upvotes: 0

Views: 1345

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269101

Use an aws:Referer condition. From Restricting Access to a Specific HTTP Referrer:

{
  "Version":"2012-10-17",
  "Id":"http referer policy example",
  "Statement":[
    {
      "Sid":"Allow get requests originated from www.example.com and example.com",
      "Effect":"Allow",
      "Principal":"*",
      "Action":"s3:GetObject",
      "Resource":"arn:aws:s3:::examplebucket/*",
      "Condition":{
        "StringLike":{"aws:Referer":["http://www.example.com/*","http://example.com/*"]}
      }
    }
  ]
}

Upvotes: 3

Related Questions