I Love Lambda but don't especially love the learning curve to get a full app going. Spoiler alert, U can test some simple lambda right inside lambda to drastically reduce the learning curve or u can write a full stack app which is what I am doing.
Recently (2021) I was playing around with React because I am an old dinosaur and have been using JQuery for years. Then soon in I realized this Serverless craze out there in Dev Land. Since I already had an Apache24 instance on AWS EC2 I started getting curious about how I could use ONLY Lambda and S3 so I could eliminate EC2.
I dug up lots of Lambda tutorials and immediately found out how to manipulate a Dynamo NoSQL database on AWS. This NOSQL idea started nagging me because I am very old school and have been using MySQL for ions. I was also playing around with axios on the front end as my http client.
Then it dawns on me that data is always rendered in JSON and that NoSQL is also JSON. But using Dynamo was getting to me so I thought I would cut to the chase and Do JSON directly in S3. Why not make S3 my database? I thought. There are more reasons not to do this than to do, but I am experimenting here.
I also ran into rendering problems in React. Array.reduce was taking too long on large tables. Hellooo….introducing Latency and Cold Starts. At first I got real discouraged with Lambda because of Latency but I found a way around it all and my SQL background helped immensely here. I discovered that Lodash was a more user friendly way to write reduce code. Objective here is to have a nice reduced view of my data, a dashboard view so to speak. A much condensed view of the data. But to do all this with Dynamo became unwieldy and complex, not to mention pricey. So I thought of a down and dirty S3 approach where I insert new data, save, fetch, reduce and save again all in the background with a small Lambda program.
Since I was new to Lambda this project seemed very daunting at first. But I was not new to ad hoc requests from my team mates at work. When they request a certain view of the data they simply want it on a dashboard and they never seems to care how I make this magic work. They just want it and they want it now. Since many of these ad hoc requests most always only involve 1 table that constantly gets updated and re rendered I figured S3 and Lambda would do the trick, and it turns out that I was right about this.
By now folks, I am sure u just want to see some code so I can show u my plain frontend calling a Lambda right now
Then there are all the little caveats and obstacles u need to know about how to actually get this all up and running in AWS
Examples of gotchas and caveats
1 In Lambda we need to import 2 node libraries
2 we also need an api gateway in AWS to provide a link to Lambda
3 we need a json file in S3 and need to know how to write to this file
4 beware of AWS IAM permissions...as they are always a problem for beginners
5 Newsflash!! BTW we also need AWS style SSL and a Cloudfront distribution
6 and DNS pointed to AWS route53…..had enough yet?
Hold on there pardner !!! way too much information...there is no way I can teach all of this without going on a massive tangent and it is overwhelming at first but we gain much satisfaction after crossing this hurdle because it catapults us right into modern day 2020s Serverless Knowhow.
Remember this is all just to get some Lambda going. But don’t u as a developer want to be cutting edge? I do and for me this is all in the rear view mirror now. Take a deep breath and convince urself that this endeavor is a must do.
BTW…..all the above is on a Windows platform..I don’t have a clue about doing this in Linux or whatever else is out there.
Now may be a good time to introduce u to my Old Stack vs my New Stack
show table herego to howtolearnJava Homepage