You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
☁️ A deep study about serverless applications on aws
When we talk aboutServerless, it basically means:
You have a piece of code
You want it to get executed by some event (HTTP, Topic Message, Cron, etc), only when this event happens
You waits for an useful output
Example:
You have a brand that stores pictures, but in order to not get it expensive, you usually process the pictures to decrease its size
The picture is uploaded to AWS S3 (Bucket)
The AWS S3 triggers an event "PictureCreated"
The Lambda is invoked by the event "PictureCreated"
The Lambda processes the picture in order to decrease its size
The Lambda shuts down
In this study we'll be using theServerless Framework which you can use for almost all the cloud platforms, with help of too many programming languages, such asJavascript, C#, Python and so on
After installing the framework, just typesls on terminal and follow the steps till you get your project started.
Good practices
After starting a new project, try to always get it deployed to the cloud asap in order to avoid some awful and unexpected environmental problems
Trigger the lambda on the cloud and mock the received data, in order to make your tests using it.
Create a config file where you can put all the scripts you execute to the Cloud CLI.
Common errors
My docker is running, I use the flag--docker withsls command and still receive the error:Please start the Docker daemon to use the invoke local Docker integration.
Solution: Execute the command as root user (addsudo before the command).
Useful commands
# Install the framework globally for javascript usersnpm install -g serverless# Init projectsls# Deploy the project to the cloudsls deploy# Invoke the function on cloudsls invoke -f$FUNCTION_NAME# Ex: sls invoke hello# Invoke the function locallysls invokelocal -f$FUNCTION_NAME# Ex: sls invoke local -f hello# Configure serverless dashboardsls dashboard# Listen for invocation logs (like a CloudWatch)sls logs -f$FUNCTION_NAME -t# Ex: sls logs -f hello -t# Make requests to invoke function based on the request.json filesls invokelocal -f$FUNCTION_NAME --path request.json# Ex: sls invoke local -f image-analysis --path request.json# Setup aws credentials for serverless frameworkserverless config credentials --provider aws --key$YOUR_ACCESS_KEY --secret$YOUR_SECRET_KEY
About
☁️ A deep study about serverless applications on aws