lets learn aws
Today we will build lambdas using nodejs.
We will touch upon serverless framework and
aws command line interface
Node.js has better spin-up times than C# or
Java which make it a better option for client
facing applications that risk suffering from
uneven traffic distribution.
aws runs its functions or lambdas in containers
that gets recycled after a period of inactivity.
This is why spin up time is important.
A work around is to always keep some lambdas
warm by listening to cloud watch events.
i have a very old version of node on my laptop.
Time to upgrade to latest and greatest version
nodejs 14
Serverless is a framework for building lambda
applications
It is an abstraction on cloud foundry
And cloud foundary is an abstration of aws
infrastructure
I now create my first serverless app.
You can do this online using app.serverless.com
Or you can do this offline
you can login to serverless website with your
google account.
that makes it one less password to keep track
of
To learn how to setup aws with serverless
visit the website shown on screen
link in description
create serverless access key so that you can
work by just using the command line option
using the environmental variable pass in the
access key and run your sls commands such
as deploy and invoke
For offline use
install serverless on your machine using npm
command
-g installs the package globally so that i
can run the sls command from any folder path
this command downloads a lot of dependencies
, so sit back patiently wait for the command
to complete
look at the final response, 716 packages from
500 contributors installed on your machine
after some failed attempts with serverless
framework on my laptop
i decided to use aws cli for my lambda configuration
screen shows a simple nodejs function that
responds a hardcoded string
Also notice that i have switched from intellij
editor to vscode editor
vscode editor has quick start time and i prefer
that over everything else on my slow laptop
i use zip command to move my nodejs files
to a compressed package.
i can now pass this zip file to aws cli to
create a lambda
i have uploaded the latest code as a zip file
to aws
output from the command is shown on screen.
It gives you details about the lambda such
as timeout , memorySize, codeSize etc
i invoked this nodejs code synchronously and
it replied with text "hello code2blog viewers"
command line interface makes your life easier
i tried installing serverless framework on
my laptop.
I then provided aws and serverless access
key as environment variables
it fails with the error shown on screen.
i stopped there and moved to using amazon
cli
if you know how to resolve this serverless
issue, reply in comments
