4 ms·
> Most of these sites are not even that big. I expect maybe a few thousand visitors per month. Incidentally, if you can make a site "static", so far I'm mostly
by neilv 1y ago
> Most of these sites are not even that big. I expect maybe a few thousand visitors per month.
Incidentally, if you can make a site "static", so far I'm mostly liking AWS CloudFront loaded from S3. After many years serving my site from a series of VPSs/hosters/colo/bedroom. It's fast and inexpensive, and so far perfectly solid.
Deploying consists of updating S3, and then triggering a CloudFront invalidation, which takes several seconds. The two key fragments of my deploy script (not including error checking, etc.), after the Web site generator has spat all the files into a staging directory on my laptop where I can test them as `file:` URLs, are:
aws s3 sync \
--profile "$AwsProfile" \
--exclude "*~" \
--delete \
"$WebStagingDir" \
"s3://${S3Bucket}/"
and then:
aws cloudfront create-invalidation \
--profile "$AwsProfile" \
--distribution-id "$CloudFrontDistId" \
--paths "/*" \
< /dev/null 2>&1 | cat
The main thing I don't like about it (other than the initial setup wizards having a couple bugs) is that it doesn't automatically map `foo/` URLs to `foo/index.html` S3 objects. The recommended solution was to use AWS Lambda, which I did temporarily, and it works. But when I get a chance, I will see whether I can make my deploy script duplicate S3 `foo/index.html` as S3 `foo/` and/or `foo`, so that I can get rid of the worse kludge of using Lambda. Unless CloudFront offers a feature to do this before then.
- hk1337 1y agoIt's still a function you have to create but I would opt to use a cloudfront function instead of creating a whole lambda for the request routing. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope... https://github.com/aws-samples/amazon-cloudfront-functions https://github.com/aws-samples/amazon-cloudfront-functions
- neilv 1y agoThanks, that looks very useful.
- mariusor 1y agoAs far as I remember S3 makes a distinction between the paths /folderLikeResource /folderLikeResource/subResource, so you can basically map "foo/index.html" to distinct resource "foo".