Cloudformation S3 Website Template

The following snippet of Cloudformation will give you an S3 website hosted on S3, with access logs in a parallel bucket:

  WebsiteBucket:
    Type: "AWS::S3::Bucket"
    Properties:
      LoggingConfiguration:
        DestinationBucketName: !Ref WebsiteLogsBucket
      WebsiteConfiguration:
        IndexDocument: "index.html"
        ErrorDocument: "error.html"

  WebsiteBucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties:
      Bucket: !Ref WebsiteBucket
      PolicyDocument:
        Statement:
          - 
            Action:
              - "s3:GetObject"
            Effect: "Allow"
            Resource:
              Fn::Join:
                - ""
                - 
                  - "arn:aws:s3:::"
                  - 
                    Ref: "WebsiteBucket"
                  - "/*"
            Principal: "*"

  WebsiteLogsBucket:
    Type: "AWS::S3::Bucket"
    Properties:
      AccessControl: LogDeliveryWrite

Outputs:
  WebsiteBucketUrl:
    Description: Website Bucket Url
    Value: !GetAtt WebsiteBucket.WebsiteURL