Amazon Web Service Lambda Feature and Amazon S3

#**What is AWS Lambda?**

AWS Lambda is a serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you. You can use AWS Lambda to extend other AWS services with custom logic, or create your own back-end services that operate at AWS scale, performance, and security. AWS Lambda can automatically run code in response to multiple events, such as HTTP requests via Amazon API Gateway, modifications to objects in Amazon S3 buckets, table updates in Amazon DynamoDB, and state transitions in AWS Step Functions.
#Benefits
- **No server to manage**: it automatically runs the code without requiring you to provision or manage servers. Just write the code and upload to lambda.
- **Continuous scaling**: it automatically scale your application by running the code in response to each trigger. 
- **Subsecond metering**: with AWS Lambda, you are charged for every 100ms your code executes and the number of times your code is triggered. You don't know anything when your code isn't running. 
    
#**How it works**
- Upload the code to AWS Lambda 
- Set up the code to trigger from other AWS services, HTTP endpoints, or in app-activity.
- Lambda runs the code only when triggered, using only the compute resources need 
- Pay just for compute time you use
![image.png](https://qiita-image-store.s3.amazonaws.com/0/279562/41074dc3-ec7f-6320-b9df-6aa7560e1f01.png)

#**AWS Serverless Application Model (AWS SAM)**
The AWS SAM is a model to define serverless applications. It is natively supported by AWS CloudFormation and defines simplified syntax for expressing serverless resources. The specification currently covers APIs, Lambda functions and Amazon DynamoDB tables. SAM is available under Apache 2.0 for AWS partners and customers to adopt and extend within their own toolsets.

**Serverless Resource within SAM**
An AWS CloudFormation template with serverless resources conforming to the AWS SAM model is referred to as a SAM file or template.

**Lambda Function**
The following shows the notation you use to describes a Lambda Function:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:

    FunctionName:
        Type: AWS::Serverless::Function
        Properties:
           Handler: index.handler
           Runtime: runtime
           CodeUri: s3://bucketName/codepackage.zip
Note the notation at the top:
*AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31*    
This is required in order to include objects defined by the AWS Serverless Application Model within an AWS CloudFormation template.

*Handler: index.handler*: the handler value points to the module containing the code your lambda function will execute when invoked. The index value of the Handler property indicates the name of the file containing the code. 


#**Lambda Pricing**
With AWS Lambda, you pay only for what you use. You are charged based on the number of requests for your functions and the duration, the time it takes for your code to execute. The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month. The more memory you want your function to have the less free seconds of running time per month you have.

#**What is Amazon S3?**
Amazon Simple Storage Service is an Object storage built to store and retrieve any amount of data from anywhere – web sites and mobile apps, corporate applications, and data from IoT sensors or devices. It is designed to deliver 99.999999999% durability, and stores data for millions of applications used by market leaders in every industry. 

![image.png](https://qiita-image-store.s3.amazonaws.com/0/279562/a416e9c3-9766-38d8-3a7b-9e7d90f83e00.png)

#**Benefits**
- **Unmatched durability, availability, and scalability**: Amazon S3 runs on the world’s largest global cloud infrastructure, and is designed from the ground up to deliver 99.999999999% of durability. Amazon S3 can also automatically replicate data to any other AWS Region.
- **Most comprehensive security and compliance capability**: Amazon S3 supports three different forms of encryption. S3 offers sophisticated integration with AWS CloudTrail to log, monitor, and retain storage API call activities for auditing.Amazon S3 is the only cloud storage platform with Amazon Macie, which uses machine learning to automatically discover, classify, and protect sensitive data in AWS.
- **Query in place**: Amazon S3 allows you to run sophisticated Big Data analytics on your data without moving the data into a separate analytics system.
- **Flexible management**: offers the most flexible set of storage management and administration capabilities. Storage administrators can classify, report, and visualize data usage trends to reduce costs and improve service levels. 
- **Most supported by partners, vendors, and AWS services**: In addition to integration with most AWS services, Amazon S3 is supported by tens of thousands of consulting, systems integrator, and independent software vendor partners, with more joining every month.
- **Easy, flexible data transfer**: S3’s simple and reliable APIs make it easy to transfer data over the Internet. Amazon S3 Transfer Acceleration is ideal for data uploads across large geographical distances. AWS Direct Connect provides consistently high bandwidth and low latency data transfer for moving large amounts of data to AWS using a dedicated network connection.  

#**AWS S3 Integration**
You can use Amazon S3 alone or in concert with one or more other Amazon products. The most common products used with Amazon S3 are:

- Amazon EC2
- Amazon Elastic MapReduce
- Amazon SQS
- Amazon CloudFront

#**Making Request**
Amazon S3 is a REST service. You can send requests to Amazon S3 using the REST API or the AWS SDK wrapper libraries that wrap the underlying Amazon S3 REST API, simplifying your programming tasks.