'Amazon S3 403 AccessDenied error

I'm getting some odd 403 errors from amazon when requesting objects from an S3 bucket. It seems be intermittent and it only happens in rapid succession.

If I try to access the same objects at a later time, I can usually retrieve them without issue.

My gut feeling is that these errors are occurring because of some sort of rate-limiting constraint but I can't find anything in the docs. Is rate limiting a possible cause for a 403 error?



Solution 1:[1]

If you're using an S3 bucket as static content website, you have to attach a policy with the action s3:GetObject to arn:aws:s3:::your-bucket/*. Here is an example using a Cloudformation template:

StaticWebsite:
  Type: AWS::S3::Bucket
  Properties:
    AccessControl: PublicRead
    BucketName: your-bucket
    WebsiteConfiguration:
      IndexDocument: index.html
StaticWebsitetPolicy:
  Type: AWS::S3::BucketPolicy
  Properties:
    Bucket: !Ref StaticWebsite
    PolicyDocument:
      Statement:
        - Effect: Allow
          Action:
            - s3:GetObject
          Resource:
            - arn:aws:s3:::your-bucket/*
          Principal: "*"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leopoldo Varela