[AWS Architect] (44) Lambda

Lambda is a FaaS (Function as a service) product where you can upload your code and create functions. Functions are invoked by events and can be executed for up to 15 minutes.

Features

  • Lambda is a serverless computing platform and scales out (not up) automatically.
  • Functions are stateless – each run is clean.
  • Execution Role is assumed by Lambda and temporary security credentials are available via STS.
  • You can specify the Environment variables, which can be retrieved through the event object.
  • Lambda is charged based on the run duration – the minimum billing duration is 100ms.
  • Functions can trigger other functions. The architecture can be complicated. AWS X-ray can debug the function.

Lambda Function Configurations

  • You can import code to Lambda in 3 ways:
    • Uploading a zip file, uploading a file from S3, and editing inline code
  • Supported Languages
    • Node.js, .Net Core (C#/PowerShell), Java, Python, Ruby, and Go.
  • Handler
  • Memory Allocation: CPU scales with memory.
  • Permission

Running a Lambda from Scratch

  • Implement the logic in a supported programming language.
  • Create a function, which has a unique name in a region in your account.
    • Need to select the proper runtime to run the function.
  • Proper permissions are needed: run the Lambda function, access CloudWatch’s log, and any necessary permission to access other services if required.

Invoking Lambda Functions

Events

  • API Gateway – used to expose HTTP endpoint
  • S3 file uploads
  • CloudWatch scheduled events
  • DynamoDB Streams change
  • Direct Invocations – SDK or CLI

Synchronous Invokes

  • Elastic Load Balancing (Application Load Balancer)
  • Amazon Cognito
  • Amazon Lex
  • Amazon Alexa
  • Amazon API Gateway
  • Amazon CloudFront (Lambda@Edge)
  • Amazon Kinesis Data Firehose

Asynchronous Invokes

  • Amazon Simple Storage Service (S3)
  • Amazon Simple Notification Service (SNS)
  • Amazon Simple Email Service (SES)
  • AWS CloudFormation
  • Amazon CloudWatch Logs
  • Amazon CloudWatch Events
  • AWS CodeCommit
  • AWS Config

Poll-Based Invokes

Lambda will poll the following services, retrieve data, and invoke functions.

  • Amazon Kinesis
  • Amazon SQS
  • Amazon DynamoDB Streams

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s