My First Export to AWS S3 Bucket

So i made my first (successful) attempt using S3 option (yay).
Here’s my experience:

[context - original site hosted on a GCP Virtual Machine with WordPress on Debian 9 installation]

AWS BUCKET

Wanted to check if my bucket policies were OK: -->

  • Created S3 Bucket with name “mysite.com”,
    –> assigned destination URL as https://mysite.com
    –> assigned region
    –> created new access key with ID and password

  • Enabled “Static website hosting” in Properties
    –> endpoint is therefore http://mysite.com.s3-website-ap-southeast-1.amazonaws.com

  • Permissions
    –> I have switched OFF “Block all public access” --> is this correct? (export won’t work otherwise)
    –> (i didn’t touch Access Control List)
    –> Bucket Policy

    {
    “Version”: “2012-10-17”,
    “Id”: “PolicyForPublicWebsiteContent”,
    “Statement”: [
    {
    “Sid”: “PublicReadGetObject”,
    “Effect”: “Allow”,
    “Principal”: {
    “AWS”: “*”
    },
    “Action”: “s3:GetObject”,
    “Resource”: “arn:aws:s3:::mysite.com/*”
    }
    ]
    }

  • (did not touch CORS configuration)
    ============================================================
    NEXT:

I can see the files in the bucket (yay again). I need to check now:

Embarassing question --> are the two above one and the same? One is secure and the other isn’t? What should my SSL considerations be at this stage?

For the purpose of setting up my DNS for Bucket with a custom Domain my A record should be s3-ap-southeast-1.amazonaws.com

===============================================================
OTHER:

  • As the site is a company 1-pager, the resulting static site came out ALMOST perfectly
    –> BUT fontawesome ICONS are not showing / did not export correctly

  • did a preliminary speed test on the above endpoint and index.html URL using GTMetrix and Google Developer Insights
    –> speed / performance seems to be worse than existing site
    –> not sure if it’s because at this stage i haven’t fully switched over from the existing site with the proper URLs etc
    –> the difference at the moment seems to point towards “Reduce initial server response time”, with GTMetrix recommending enabling compression of

https://s3-ap-southeast-1.amazonaws.com/mysite.com/index.html could save 85.5KiB (71% reduction).

The export didn’t export over an .htaccess file, so i added one to try solve the file compression but i don’t think it’s working…

===================================================================

All in all - a ‘satisfactory’ experience in deploying via WP2Static, but more leg-work to be done to actually improve on my existing speed test scores (primarily for mobile - quite happy with desktop scores for now).

Any insights and recommendations would be most welcome!

S3 has some barebones website support, but you should generally use CloudFront to serve the site. Try creating a CloudFront distribution with the origin set to the S3 bucket’s “website endpoint”. Make sure to check “Compress objects automatically”. You should see significantly improved speeds. CloudFront caches files automatically, so you should see faster results when you run two tests in quick succession.

The difference between the S3 “website endpoint” and the non-website URL is that the website endpoint will use “index.html” and “error.html” as appropriate, and it respects object metadata like “Website-Redirect-Location”. It doesn’t seem to support HTTPS, but that shouldn’t be an issue because you can set up HTTPS/TLS through CloudFront. (SSL has been dead since 2015).

.htaccess only works on Apache servers, and is not supported anywhere else.

1 Like

@john-shaffer

Hi - and thanks for the advice
WRT SSL - yes, HTTPS/TLS --> you can see how much of a novice i am … :wink:
Will set up CloudFront as advised and run the appropriate tests again.

I was expecting a comment about how i setup my Bucket policies, but it seems i may have done that ok!?

Thanks again

The policy is fine, but it’s not necessary for WP2Static. The plugin sets public-read permissions on the files it uploads. I still like to set the policy so that if I upload something manually, it has the correct permissions.

1 Like