DEV Community

Cover image for How to deploy your own website on AWS

How to deploy your own website on AWS

Rolf Streefkerk on May 28, 2024

Originally published on rolfstreefkerk.com Take full control of your website, and following along with our how-to guide. Benefits of building a...
Collapse
 
jangelodev profile image
João Angelo

Hi Rolf Streefkerk,
Top, very nice !
Thanks for sharing

Collapse
 
alonch profile image
Alonso Suarez

I need this setup often, there has to be an easier way than investing an hour or so on this 🤔
I managed to write a Github action that goes all this with minimal dependencies, blog repo

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

Yes you could host on github actions the terraform script and run everything based on a git action.

This article was meant as a starting poiint that you can adjust as you see fit with your workflow.

Thanks for reading!

Collapse
 
moldab profile image
Chen Beygel

Very comprehensive and detailed article!
Can you specify the cost of the caused cloud resources? How much does it cost for a month?

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk • Edited

This would really depend on your traffic, but lets say for any starting website with a few thousand viewers a month you're looking at;

Domain (yearly one time fee, for a .com ~ 10 USD) = ~10 USD = 0.83 USD

Route 53 Hosted zone ; $0.50 per month for the first 25 hosted zones = 0.5 USD

S3 5GB of Amazon S3 storage in the S3 Standard storage class; 20,000 GET Requests; 2,000 PUT, COPY, POST, or LIST Requests; and 100 GB of Data Transfer Out each month. Free storage probably, otherwise very low cost storage. Traffic beyond free tier it's 0.005 USD for 1000 in requests, 0.0004 USD for 1000 out requests.

Cloudfront you're likely operating in the free tier, including SSL, request in-out
aws.amazon.com/cloudfront/pricing/

Total: 1.33 USD per month incl. ".com" domain name for most small to medium use-cases.

Collapse
 
kakauandme profile image
Kirill Kliavin

Looks pretty straightforward for a static website 🙃

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

what do you mean exactly?

Collapse
 
mozillalives profile image
Phil

I’m assuming the commenter above is referring to the vast number of steps required to setup a static website on AWS. There are actually easier ways with fewer steps, for instance using AWS Amplify.

The upside to the approach you present here though is that you explain many of the details that a solution like Amplify hides. If someone just wants to deploy a static site without knowing much about the details, Amplify is probably what they want. But if someone wants to understand the steps involved so they can grow to more complicated deploys or even move to other cloud providers, then I think your article is a nice resource. :)

Thread Thread
 
rolfstreefkerk profile image
Rolf Streefkerk

Yes i believe you've summarized it perfectly.

This is a "vehicle" for learning, and at the same time if you prefer control over what is deployed exactly you will have that with Terraform over something like Ampllify that hides much of this.

Thanks for your time

Collapse
 
andrew_park_f271aaaf73d5d profile image
Andrew Park

Thanks for this, the one thing that would hold me back would be the risk of very high AWS fees as a consequence of some error with the code and so other external factor.

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

You can verify all resources deployed in the github repo's I've provided.
github.com/rpstreef/terraform-stat...

In my opinion;

  • S3 is not publicly exposed: CloudFront access only via Route53 domain.
  • CloudFront has standard AWS Shield protection that prevents DDoS attacks: This prevents traffic costs against your account in case of such activities.
  • IAM user created has;
    • limited access, can only upload to your S3 bucket, invalidate CloudFront caches.
    • don't expose your access key anywhere, should avoid this risk of data ingress / egress cost

You make a valid point with regards to AWS cost tracking.

In my opinion, what you can do is:

Add Budget Alerts to your AWS Account and set several of them with different value amounts to track your overal account spend.

Use this Terraform module to implement them:
github.com/cloudposse/terraform-aw...

Alternatively, use the AWS Console UI to set it in the Budget screen.

I hope that helps