Not too long ago, I had a competition held within university. It was web-app related and I was supposed to re-design Winnipeg-CrimeStopper website. It was mostly front-end related and I’ve had a lots of fun designing the website.

Now that I got the AWS-SAA certificate, I wanted to host this using my AWS knowledge. As said in the movie, “Oppenheimer”, theory will only take you so far.

Before I begin, I needed to figure out architecutre. Since this is just my side project and I was expecting low traffic. Serverless architecture was the best cost-efficient architecture I could thought of. Here’s the list of service I was gonna use:

Aurora Serverless v2 for DB

Lambda + API Gateway for api request

S3 for static image file

ECS fargate for web-app deployment

First thing first, I was setting up Aurora instance in AWS. But before I initiate my instance, I went into the pricing page of Aurora and found out, while Aurora Serverless v2 does automatically scale from 0.5 ACU to 5 ACU Aurora Serverless v2 techinically incur an idling cost (because it doesn’t scale down to 0 ACU). This implied I had to pay around 40 USD per month minimum.

This didn’t feel much of economical. Besides, I have more and more projects coming so spending $40 monthly just to deploy one project was a bit too priecy for a full time university student making negative wage per hour ;_;

So I needed to come up with alternative. Then I remembered I could use DynamoDB, I quickly went ahead and looked up a pricing

“$0.125 per million read requet units”, this statement alone instantly made me so happy. I can afford that! yay! (But going from RDBMS to NoSQL implies code change and oh no refactoring is so fun)

Anyway, now that we take care of this, I set up my lambda function for retreving criminal’s data, and hook it up to API gateway so I can later fetch this data from my web-app.

And I tested the api using command line

After which, I was trying to see if my website works on my local environment; it didnt. It was not fetching data at all. So I looked up the web console and realized I didn’t configure CORS for my api gateway so browser was blocking my request by Same-Origin-Policy

After configuring CORS, web-app on local was working as intended. Now I needed to deploy it.

I was going to

1. containerize

2. and have ECS use that containerized image

buuuuut… deploying react app using vite was rather … time consuming- I wanted to finish this whole deployment within 24 hours otherwise I wouldn’t have time for it. So I needed to find an easier solution.

That’s when I stumble across AWS amplify. It is fully managed service by AWS and all I had to do was to link my github repo into this. So I linked it, waitied, and …

build failed … which was surprising, because “it works on my machine!”

So I tried to dig around looked for a build log

…oh

For some reason, it was running on outdated node v18.20 when it needed to use node v20 or above.

So I went into Build setting -> Advanced setting and match the node version to the same version I’m using on my local machine.

Then finally, finally it worked !!

After confirming deployment, I went to Route53 and purchased domain so it’s more easily recognizable. Here’s the full website.

https://crimestopper.click/

Posted in

Leave a comment