week#12(LambdaFunction)
week#12(LambdaFunction)
Yin Hua Li
Centennial College
1
¡ AWS Lambda, launched in 2014, is a compute service that
allows you run code without provisioning or managing servers
¡ AWS Lambda is AWS’s Serverless service. You pay only for the
compute time you consume, and there is no charge when your
code is not running
¡ Use AWS Lambda to run your code in response to the following
§ RequestResponse invocation type
▪ Execute synchronously
§ Event invocation type, and the events are raised in AWS
▪ Execute asynchronously
▪ Available triggers
▪ S3, DynamoDB, etc.
§ API calls made using the AWS SDK
¡ Supported languages
§ Node.js, Python, Java, C#, Go, and Ruby
2
¡ Functions (e.g., send email) with small amount of
execution time
§ Log analysis on the fly
§ Automated backups
§ Process uploaded S3 objects
§ Backend cleaning
§ Bulk real-time data processing
§ Etc.
3
¡ AWS lambda functions include two types of
permission
§ Execution permissions enable the AWS Lambda
function to access other AWS resources in your
account.
▪ For example, if the AWS lambda function needs to access to
S3 object, you grant permission through an AWS IAM role
that AWS lambda refers to as an execution role
§ Invocation permissions are the permission that an
event source needs to communicate with your AWS
lambda function
4
¡ A Lambda Function
§ The code that runs on AWS Lambda
¡ An Event Source
§ After you upload your code to AWS Lambda, you need to
associate your function with specific AWS resources (e.g.
particular Amazon S3 bucket, Amazon DynamoDB table,
etc.)
¡ The AWS Lambda service
¡ AWS Lambda Runtime
§ AWS Lambda supports multiple languages runtimes
§ A runtime is to pass requests and response between
Lambda and the function code
5
¡ Security
§ AWS Lambda stores code in Amazon S3 and encrypts it at rest
§ AWS Lambda performs additional integrity checks while the
code is in use
¡ Execution
§ All calls made to AWS Lambda must complete within 900
seconds (15 minutes)
§ The default timeout is 30 seconds, but you can set the timeout
to any value between 1 to 900 seconds
6
¡ Function handler
§ It is what the Lambda runtime calls to run your function. In other words, it is
the entry point
¡ Event object
§ Contains information about the event and the source that triggered the
Lambda function
¡ Context object
§ Provides a number of useful properties(e.g., function name, function version,
etc.) for getting information about Lambda’s runtime
¡ Callback function
§ An optional third parameter in the handler function. It’s used to return
information to the caller in Request/Response invocation type.
¡ Logging
§ Logging to CloudWatch can be done using console.log(“message”)
7
8
9
The entry point of the lambda function
10
11
The CPU share is proportionally
based on the amount of memory
allocated to the function
12
13
¡ Amazon Rekognition was launched in 2016, and video support was
added in 2017
§ It is a service to analyze visual content included in an image or video
§ It is based on the proven, highly scalable, deep learning technology
developed by Amazon’s computer vision scientists to analyze billions of
images and videos daily. It requires no machine learning expertise to use
20
21
¡ Add trigger to a Lambda function to associate with Event source(s)
22
23
24
¡ https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-rekognition-
example.html
¡ https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model.html
¡ https://www.youtube.com/watch?v=f46o5vsBNpk
¡ https://www.contino.io/insights/aws-lambda-use-cases
¡ https://www.rahulpnath.com/blog/aws-lambda-net-core/
¡ https://dotnet.microsoft.com/platform/support/policy/dotnet-core
¡ https://github.com/aws/aws-lambda-
dotnet/tree/master/Libraries/src/Amazon.Lambda.RuntimeSupport
25