Live data from Hacker News

Hosting your static site with AWS S3, Route 53, and CloudFront for free

vickylai.com

31–40 of 51 posts

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#31
The article's from December 2017 and you can see from the response headers that it's hosted on GitHub Pages again.

There are plenty of gotchas when serving a static site via CloudFront. Let's say you have a page at example.com/foo/index.html. If you want it serve it from example.com/foo/ then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront's default root objects handle this, but they don't. That's for the domain root only.

There's also the case of redirecting example.com/foo to example.com/foo/ (adding the trailing slash). That requires a Lambda@Edge response function. It's all a lot of fun to get working, but you do start to wonder if your static site really is static.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#32
post #31

The article's from December 2017 and you can see from the response headers that it's hosted on GitHub Pages again. There are plenty of gotchas when serving a static site via CloudFront. Let's say you have a page at example.com/foo/index.html. If you want it serve it from example.com/foo/ then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront's default…

Hm, while I agree that there are some gotchas serving static sites via AWS, the one you mention seems to work fine for me. See e.g. https://visidata.org/releases/ which is definitely served via CloudFront and definitely does not use a Lambda@Edge request function.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#33
post #31

The article's from December 2017 and you can see from the response headers that it's hosted on GitHub Pages again. There are plenty of gotchas when serving a static site via CloudFront. Let's say you have a page at example.com/foo/index.html. If you want it serve it from example.com/foo/ then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront's default…

Hm, while I agree that there are some gotchas serving static sites via AWS, the one you mention seems to work fine for me. See e.g. https://visidata.org/releases/ which is definitely served via CloudFront and definitely does not use a Lambda@Edge request function.

Well that's interesting. An AWS blog post from October 2017 says:

> CloudFront does allow you to specify a default root object (index.html), but it only works on the root of the website (such as http://www.example.com > http://www.example.com/index.html). It does not work on any subdirectory (such as http://www.example.com/about/). If you were to attempt to request this URL through CloudFront, CloudFront would do a S3 GetObject API call against a key that does not exist.

https://aws.amazon.com/blogs/compute/implementing-default-di...

A request for https://visidata.org/releases (no trailing slash) also results in an HTTP 302 to https://visidata.org/releases/ (with a trailing slash). Is there something other than Lambda@Edge functions handling this on visidata.org?

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#35
post #20

This isn't really free - it's just free for first year until your free tier runs out. It's still super cheap though. I host several sites with this setup and never have a bill over $2 / month. Benefit of this setup over github pages / netlify / etc is it uses standard primitives and will always exist. I used to use Heroku to host several sites and had to go through a massive migration when they stopped offering a fre…

The odds are good that it will "always" exist, not really always of course but long enough that we don't care. However, Amazon may come to the decision that it's not worth keeping this low spending tier of customer and price them out of the service.

Hopefully, it's a good enough of a hook to get you started on AWS that it is worth it to keep it cheap like it is now.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#36
post #13

Earlier quoted context omitted.

I think that depends highly on which country you are in, I've never experienced this in Denmark before EDIT: and I've used pretty much all the ISPs we have around

Same here stateside, neither Comcast, Centurylink, Cox, Charter, Wave, Verizon or Frontier blocks port 80 or 443. Some do block mail ports 25 & 587, Comcast & Centurylink leaves these mail ports open unless you do some spamming (then you have to call and have 'em unblock them).

Cox has blocked port 80 for residential customers for a long time, probably since around when @home went away.

https://www.cox.com/residential/support/internet-ports-block...

They don't block 443 though

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#37
post #31

The article's from December 2017 and you can see from the response headers that it's hosted on GitHub Pages again. There are plenty of gotchas when serving a static site via CloudFront. Let's say you have a page at example.com/foo/index.html. If you want it serve it from example.com/foo/ then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront's default…

Both problems you mentioned are solved by using S3 configured to serve the buckets contents as static site as origin for CloudFront.

While it’s not strictly CloudFront only doing the work, it’s still a static site.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#38

If this post gets very popular, we might see a second post from same author titled "How CloudFront charged me 300$ in one day?" :)

The exposure could be worth $300 suppose for example it landed the author a lucrative job offer or business opportunity. The other alternative is generally your site goes down.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#39
post #31

The article's from December 2017 and you can see from the response headers that it's hosted on GitHub Pages again. There are plenty of gotchas when serving a static site via CloudFront. Let's say you have a page at example.com/foo/index.html. If you want it serve it from example.com/foo/ then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront's default…

Both problems you mentioned are solved by using S3 configured to serve the buckets contents as static site as origin for CloudFront. While it’s not strictly CloudFront only doing the work, it’s still a static site.

Ah, that explains it. I store my websites in private S3 buckets, and give CloudFront access using an IAM policy. I must need to jump through extra hoops because of that.

Re: Hosting your static site with AWS S3, Route 53, and CloudFront for free

#40
post #20

This isn't really free - it's just free for first year until your free tier runs out. It's still super cheap though. I host several sites with this setup and never have a bill over $2 / month. Benefit of this setup over github pages / netlify / etc is it uses standard primitives and will always exist. I used to use Heroku to host several sites and had to go through a massive migration when they stopped offering a fre…

The odds are good that it will "always" exist, not really always of course but long enough that we don't care. However, Amazon may come to the decision that it's not worth keeping this low spending tier of customer and price them out of the service. Hopefully, it's a good enough of a hook to get you started on AWS that it is worth it to keep it cheap like it is now.

>Amazon may come to the decision that it's not worth keeping this low spending tier of customer and price them out of the service.

Given the downward pricing trends of cloud providers for past few years as well as increased competition (Azure & GCP primarily) I think we can safely assume pricing tiers will remain reasonable.

Post reply on HN