AWS Lambda in 3 Minutes
Tags: aws, lambda, cloudskills, serverless
Published: 2021-01-26 17:13:25

## Overview

AWS [Lambda](https://aws.amazon.com/lambda/) is a [serverless](https://aws.amazon.com/serverless/) compute service that executes provided code on fully managed infrastructure. It is classified as a [Function-as-a-Service (FaaS)](https://www.ibm.com/cloud/learn/faas), which means that everything, except your code, is managed for you.

That enables the many benefits:
* [Automatic Scaling](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html)
* [Billed for Executing Code](https://aws.amazon.com/lambda/pricing/); Not Billed for Idle Time
* [Built-in Fault Tolerance](https://aws.amazon.com/lambda/features)

## Serverless

> [Serverless computing](https://aws.amazon.com/serverless/) allows you to build and run applications and services without thinking about servers. With serverless computing, your application still runs on servers, but all the server management is done by AWS. 

* Better Availability
* Better Performance
* No Manual Scaling
* No Patching
* No Wasted Capacity

https://aws.amazon.com/lambda/faqs/

## Configuration

### Layers

Additional code that can be loaded into your function without the need to package that code along with your deployment package. This can be really useful if you have a lot of functions that rely on the same dependencies. 

https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

### Memory

Controls the amount of memory a function can use.
Value must be between 128 and 10240 MB. 

> CPU scales proportional to memory

### Timeout

Controls the amount of time a function can execute for.
Value must be less than 15 minutes.

> long-running processes are not suited for Lambda

## Invocation

### Streaming
* AWS [Kinesis](https://aws.amazon.com/kinesis/)
* AWS [Simple Queue Service (SQS)](https://aws.amazon.com/sqs/)
* Apache [Kafka](https://kafka.apache.org/)

### Synchronous
* AWS [Alexa](https://developer.amazon.com/en-US/alexa)
* AWS [API Gateway](https://aws.amazon.com/api-gateway/)
* AWS [Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/application-load-balancer/)

![ALB Trigger](https://dev-to-uploads.s3.amazonaws.com/i/bfhpp551mp0yjk3c0268.PNG)

### Asynchronous
* AWS [CloudFormation](https://aws.amazon.com/cloudformation/)
* AWS [Simple Notification Service (SNS)](https://aws.amazon.com/sns/)
* AWS [Simple Storage Service (S3)](https://aws.amazon.com/s3/)

![S3 Trigger Example](https://dev-to-uploads.s3.amazonaws.com/i/zm6arg9fy6lcjimc1v0k.PNG)

> services listed above are examples only and not a complete list https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html

## Language Support

Lambda supports most popular programming languages natively, but still provides the ability to use any language by configuring a [Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html) or packaging your code as a [Container](https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html).

* C#
* Go
* Java
* Node.js
* PowerShell
* Python
* Ruby

## Deployment
With serverless applications traditional processes and methods will not work. There are frameworks that exist to solve these types of problems. 

Here are my two favorite frameworks: 
* [AWS Serverless Application Model (SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)
* [The Serverless Application Framework (sls)](https://www.serverless.com/)

https://geekflare.com/serverless-apps-frameworks/

## Walkthrough Guides

AWS Console
https://aws.amazon.com/getting-started/hands-on/run-serverless-code/

AWS SAM
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html

AWS Serverless Workshops
https://data-processing.serverlessworkshops.io/

The Serverless Application Framework (sls)
https://www.serverless.com/framework/docs/providers/aws/examples/hello-world/node/