As I'm working on getting AWS certified, I'm always in need for a examples to play with new services. What better way to do it while also testing out the newest Drupal version?
Ever since I learned that one can host static websites on S3 I wanted to test it out, but I never had a good use- case. I also run a personal blog that was collecting so much dust it would have been a health hazard to even log-in to try and edit it. With a bit of time on my hands this weekend, I finally decided to just get started.
The Drupal setup is as follows:
The .lando file after running 'lando init' looks like this:
The only tricky part here was that the database/user/pwd is not named 'drupal9', but still 'drupal8'.
To generate the static site all I have to do now is to run:
lando drush tome:static --uri=https://reginahack.com
After it is generated, I commit/push the changes to GitHub. AWS CodePipeline gets notified automatically via GitHub Webhooks and the static site gets upload to the S3 bucket.
To setup your S3 bucket with static website hosting, change the properties of the bucket. Don't forget to set the right policies otherwise you won't be able to access the site.
The Route 53 setup can get tricky as we need CloudFront for SSL using the Amazon Certificates. What we need to do is:
- add an A record pointing to the alias of our CloudFront distribution
- redirect www to the main domain
- get SSL certificates in US-East (otherwise CloudFront doesn't work)
- add the DNS verification entries to the hosted zone
In CloudFront the redirect http to https options needs to be switched on under 'behavior settings'.