AWS LAMBDA

SAIRAM MANDAPAKA
5 min readJan 17, 2021

AWS Lambda is a serverless compute service where your code is triggered in response to a event occurrence and it also manages the underlying compute resources for us.

It is a platform as a service with a remote platform to run and execute your backend code, It has some environment restrictions as it is restricted for few languages only.

We can choose our environment where we can run the code and push the code to AWS Lambda. It is mainly used for running and executing the backend code.

It is a stateless system, which provides serverless architecture and can be used to write the code and execute it in the environment and also monitors the performance of your code.

Languages which are present in the language editor of Lambda i.e Python, C#, Node.js, Java, and Ruby.

After the code is invoked in Lambda function it will automatically take care of managing and provisioning the required servers.

Lamda is basically depends uopn four concepts they are

  1. Functions : This process an event and returns a response
  2. Runtimes : It executes the function containing the code.
  3. Log streams : These will automatically monitor your function Invocations and reports the metrics to cloud watch
  4. Layers

Layers :

These are a distributed mechanism for libraries, custom runtimes and other function dependencies. Layers let you manage your Indevelopment function code independently for the unchanging code and resources that it uses.

We can configure our functions in layers that we create layers provided by AWS or layers provided by other customers.

These are an archive containing additional code containing libraries, dependencies, or even custom runtimes. These are basically used to share codes among our lambda function.The code in a layer could be anything. It could be dependencies, configurations, helper functions i.e. Logging, Recording metrics, etc.

You can link up-to five lambda layers per function where one of that can optionally be a custom runtime e.g. PHP, rust, etc.. However adding our custom runtime is not the most frequent use-case for lambda layers but sharing code across our serverless microservices.

deploying a application on lambda and use sqs as the input form

  1. On the AWS console go to services and click on SQS.
  2. You will be redirected to the SQS home page and click on get started.On the SQS home page, You will be asked to select a queue to create one.
  3. select the queue click on the quick-create queue on the bottom. After clicking the button you will be getting on the details page of the queue.
  4. There on the dashboard, you can see your queue has been created, Now go to IAM Roles and click on create a role and select the service as Lambda.
  5. Click Next, on the permissions tab assign the lambda execute policy and SQS full access policy by searching them in the search bar, click Next.
  6. Assign the tags and After assigning click on Next button.
  7. On the Roles tab name the role and fill all required parameters and click on create role.
  8. Now Go to S3 on AWS console and create a bucket.
  9. Now On the AWS console click Lambda and click on create function.
  10. Name the function and select the runtime editor of your choice, Now on the permissions tab click on use an existing role.
  11. Select the role that you have created and click on create function.
  12. After the function is created click on Add Trigger, Now on trigger configuration page on the search bar type SQS and select it.
  13. click Add, and modify the code of your qon on the Lambda function.
  14. Now go to SQS and click on the queue actions button which is located at the top and click on send a message.
  15. Now on the message body dialog box fill in the message you want.After filling the message body click on Message attributes and fill in the parameters and click on send message button.
  16. After clicking the send message button you will get the message has been delivered description on thee screen.
  17. Now go to Lambda Function and click on Monitoring and on the log stremas we can have the metadata of the message.
  18. Now go to the configuration and modify the code in order to place your data or metadata in s3 bucket in json format or xml format.
  19. Now go back to SQS and resend the message and go to S3 and click on the bucket you have created and there you van see your data file with .json or .XML format has uploaded.

what is serverless world

Serverless architecture allows us to focus on our application logic without having worry about any server.There will be of no servers to maintain and no operating systems to take care of, No software to manage, No hardware to upgrade.

There will be having high availability and fault tolerance to our applications, We don't need to manage or even install any kind of software, and It is easily scalable as they can be scaled automatically and there will be of no need to create any scalable architecture designs.

Since they have built in availability and fault tolerance they are highly available. Nad it has No idle capacity as we pay only for what we use.

It has lesser server side work with reduced costs, It contains reduced risk and increased efficiency. Its managing state is relatively complex with higher latency.

Examples of serverless technology are AWS Lambda with this a serverless computing platform that adopts an event driven approach.

Google cloud functions is also one of the serverless computing platform and Google cloud firebase is well known serverless architecture to manage and provision the resources for the code.

By using serverless platform we can build static websites, Small E-Commerce platforms, Chatbots, IoT services, and Bigdata applications etc..

Connecting Lambda With the Gateway

We can connect the AWS lambda to a API Gateway in two ways i.e through the Lambda console or API gateway console.

  1. On the AWS console click Lambda and click on create function.
  2. Name the function and select the runtime editor of your choice, Now on the permissions tab click on use an existing role.
  3. Select the role that you have created and click on create function.
  4. fter the function is created click on Add Trigger, Now on trigger configuration page on the search bar type API gateway and click on the Rest API option.
  5. On the security mechanism select the Open and click on the additional settings bar and make sure all the defaults are present and click on the add button at the end.
  6. After clicking add you will see a message containing the API trigger was successful.
  7. Now to verify it expand the API name containing the details on the Lambda dashboard.
  8. Now click on the URL which is present in the details of the API and copy it and paste it in the browser.
  9. You will see an internal server error if you don't have any code and you can modify the code and save it.
  10. you can run the code and can see the result of the code in the URL home page.

--

--