Skip to content

Files

Latest commit

 

History

History
97 lines (39 loc) · 5.79 KB

programming-aws-lambda.md

File metadata and controls

97 lines (39 loc) · 5.79 KB

Programming AWS Lambda

> Home

1. Introduction to Serverless, Amazon Web Services, and AWS Lambda

With a serverless service we expect the vendor to provide HA transparently for us. (link)

Auth0 and Amazon’s Cognito. Both of these products allow mobile apps and web apps to have fully featured authentication and user management, but without a development team having to write or manage any of the code to implement those features. (link)

Backend as a service (BaaS) allows us to replace server-side components that we code and/or manage ourselves with off-the-shelf services (link)

Lambda implements the FaaS pattern by instantiating ephemeral, managed, Linux environments to host each of our function instances. Lambda guarantees that only one event is processed per environment at a time. At the time of writin (link)

the scaling flexibility of Lambda surpasses any other compute option within AWS. (link)

We can build scheduled-task applications, similar to cron programs, using CloudWatch Scheduled Events as the trigger. (link)

We can build message-processing applications, using message buses like Simple Notification Service (SNS), Simple Queue Service (SQS), EventBridge, or Kinesis as the event source. (link)

In RestaurantsFunction we can, for example, make a call to a database—Amazon’s DynamoDB is a popular database to use with Lambda, partly due to the similar scaling capabilities of the two services. (link)

Vikram: [Amazon DynamoDB]

Foreword

he software industry. They�ve greatly improved the productivity of millions of developers by eliminating many of the hassles, costs, and �undifferentiated heavy lifting� of dealing with servers, from security pa (link)

Vikram: [AWS Lambda]

3. Programming AWS Lambda Functions

Most important, however, it specifies a principal, which is the identity that is allowed to assume the role. In this case, we’re allowing the Lambda service’s data plane (lambda.amazonaws.com) to assume this role (link)

Vikram: [Start from here 11/10/2021]

That said, the principle of least privilege is not only applicable to preventing compromises. It’s also an effective means of limiting the “blast radius” of bugs in your application code. (link)

Fortunately, as AWS serverless developers, we have the good fortune to be able to use a different “flavor” of CloudFormation called the Serverless Application Model (SAM), which we used in Chapters 2 and 3. This is essentially a superset of CloudFormation, which allows us to use some special resource types and shortcuts to represent common serverless components and application architectures (link)

A set of AWS resources created from a CloudFormation template file is called a stack. (link)

Rather than manually interacting with AWS via the web console or CLI, we can declaratively specify our desired infrastructure in a JSON or YAML file and submit that file to AWS’s infrastructure-as-code service: CloudFormation (link)

Vikram: [AWS Infrastructure as code tool is called CloudFormation]

First, the uberjar approach unpacks and then overlays libraries on top of each other in the target uberjar file. (link)

Vikram: [So if the same folder & file exists in another jar file, one of them will be overwritten. Lambda runtime ignores the meta data in a jar a file. The jar file contains build timestamps, so a binary is created everytime we run the build process. We want the output to be the same if there are no code changes. This helps in caching and speeds up the processing.]

2. Getting Started with AWS Lambda

For example, to tear down the HelloWorldLambdaJava stack, run the following:

$ aws cloudformation delete-stack --stack-name HelloWorldLambdaJava (link)

$ aws s3 mb s3://bucketname (link)

Vikram: [Create S3 bucket on command line]

A good way to quickly validate your AWS profile is to run the command aws iam get-user (link)

> Home