The term `Server-less` has gained so much hyped recently. Everyone talks about executing their code on an server-less architecture but first let's understand what is server-less anyway ?

Server less is only an fancy word. in fact in an server-less architecture there is an server which you shouldn't worry about but the provider will take care of the computing power and up time. you just have to worry about your code and rest is handled by the provider in our case i.e. AWS.

One of the many services AWS provides is AWS lambda. AWS lambda is a function as a service. deploy your code to the server and you are ready to go for production.  So, how do we do that ?

Let's get started

Let's start by creating a lambda function that return the payload send to the function itself.
AWS Lambda provides support for many languages. Some of which are javascript, c#, python, Go etc. Let's create an lambda using python.  

Go to AWS Console & AWS Lambda Section. Click on Create Function

Add the function name and choose python as Runtime Environment.

AWS Lambda Creation Form

basic python code which can be seen in code tab section.

AWS Lambda Code View
import json
def lambda_handler(event, context):
     # TODO implement
     return {'statusCode': 200,'body': json.dumps(event)} 

I have modified the code to return payload send to the lambda functions.

Now let's test if the function works. Go to the Test Tab , change the payload.

Testing AWS lambda

Now click Test.
you can see the logs above with total time taken and resource utilized.

AWS Lambda Execution Log

There are many other ways the function can be triggered. You can using api-gateway, invoke directly using aws credentials, SNS, SQS services etc.

AWS Lambda Trigger List

Benefits of AWS Lambda

AWS lambda makes it easy for developers for deploying code without worrying about the infrastructure. the code scales upon the request and also the cost for lambda depends upon your usage. if the lambda is not triggered,you don't have to pay for the service. You can use it as your email server, process that are triggered on demands only which will cut your cost and increase your saving.

Happy Coding!!!