Small static website hosting on AWS - Amplify vs S3
A few years ago hosting a static website on AWS was easy. You knew that you should use S3 for storing the files, expose it to the internet, do some other actions and it is done. Now, AWS Amplify comes to the picture. Not as an alternative but even as a default solution. Most of new AWS tutorials that show how to host a static website, do that using AWS Amplify. Is it worth doing that? Is it expensive?
What is AWS Amplify
AWS Amplify is a set of tools that can help you build and host frontend and mobile apps. As you may expect, it actually uses other AWS services like S3, Route 53, CloudFront to do the job. As Amazon already has multiple powerful services, you take advantage of that power through AWS Amplify.
Can I still use AWS S3 for a static website hosting?
Of course, you can. You can do it exactly in the same way you used to do that - put files on S3, made them publicly available and read only, add a domain etc.
Why should I consider AWS Amplify?
Oh, there are a few reasons. First of all, it is easy to do. Amplify has a wizard that will walk you through the process of configuring everything that you need for hosting a static website. If you choose S3, you will have to do most of those things manually. AWS Amplify will take care of all aspects of hosting, load balancing, speeding up the website access etc. You still can do choosing S3 and configuring additional services and CloudFront but AWS Amplify gives you all that.
A totally different aspect is building the website. AWS Amplify has a simple CI/CD functionality that allows you to configure a Git code repository, set up building process, deployment and verification of the website. At the end you will have a fully working CI/CD pipeline totally within AWS Amplify. If you are interested in details, check this Amplify hands on.
AWS Amplify pricing
Detailed pricing is described on Amazon website. However, I will make some calculations to compare it with S3.
Let's assume that I have a simple static website to host. There will be in average 1000 visits daily, the website is 50 MB in size and each visit cause serving 1 MB to the guest.
Amplify pricing consists of two elements, I will calculate them separately:
- Build & deploy. Each processing minute costs $0.01. As that will be a small website, I will need not more than 2 deployments a month. Amazon wrote that an average build takes 3 minutes so the total monthly processing cost will be $0.01 * 2 * 3 = $0.06 which is almost nothing.
- Hosting. Here we pay for each GB stored ($0.023) and for each GB served ($0.15). The cost is calculated as follows: $0.023 * 0.05GB + $0.15 * 1000 * 0.001 GB * 30 = $0.00115 + $4.5 = $4.500115
Total monthly cost using AWS Amplify would be $0.06 + $4.5 = $4.56
When using S3, you pay for:
- Storage. $0.0245 per each GB stored. In my case it will be 0.05 GB * $0.0245 = $0.001.
- Data transfer. The first 100 GB transfer out to the internet is free each month. I need 1000 * 0.001 GB * 30 = 30 GB. It is lower than 100 GB free limit so I will not pay for transfer.
Total monthly cost using S3 would be $0.001.
Of course none of those options contains a domain cost. In the above example, the cost of Amplify is small, but still it is significantly higher than the solution based on S3. However, before making a decision, you need to know that those options are not exactly equal. S3 does not contain CI/CD pipeline which you need to do separately. Maybe totally outside AWS or even manually if that is a small rarely changing website. There are no optimizations, caching nor geographic distribution that CloudFront does for Amplify.
On the other hand the above example is about a small website with relatively low traffic (1000 visits daily). I could risk that such website may not need advanced possibilities of Amplify.