Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

AWS - Lambda Quizlet

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

AWS - Lambda

Terms in this set (10)

What is 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.
Lambda Description
AWS Lambda lets you run code without provisioning or managing servers. You pay only for
the compute time you consume - there is no charge when your code is not running.
Lamda Features
-- Event Driven
-- Serverless
-- Run as a compute service in response to HTTP requests using API Gateway or API calls
-- scale out automatically
Lambda Supported Event Sources
-- S3
-- DynamoDB
-- Kinesis Data Streams
-- Kinesis Data firehose
-- SNS
-- SES
-- Cognito
-- CloudFormation
-- CloudWatch Logs
-- CloudWatch Events
-- CloudFront
-- API Gateway
-- Codecommit
-- Alexa
-- Scheduled event
-- AWS IOT
Lambda benefits
-- Serverless, NO SERVERS TO MANAGE
-- Continuous scaling
--SUBSECOND METERING: you are charged for every 100ms your code executes and the
number of times your code is triggered
What languages does AWS Lambda support
Node.js (JavaScript), Python, Java (Java 8 compatible), and C# (.NET Core) and Go
Lambda function diskspace
Lambda function receives 500MB of non-persistent disk space in its own /tmp directory.
How does Lambda function scale
Lambda scales them automatically
Lambda can start as - many copies of your function as needed without lengthy deployment
and configuration delays
Debug Lambda
AWS X-ray is used for debug Lambda function
role to be used to use Lambda function
Simple Microservice Permission
Terms in this set (17)

what is lambda abstracting away


Data Centers
Hardware
Assembly code/protocols
HL languages
Operating Systems
Application layer/Aws apis
What is AWS Lambda?
a compute service where u upload ur code & create a lambda function
aws lambda takes care of provisioning and managjng servers to run ur code
Lambda use cases
Event driven - where u want to run code in response to events like data in s3 or dynamo
API driven - where u run ur code in response to http requests through aws api gateway/aws
sdks
Diff types of lambda triggers ❗️
alexa skills & smarthome triggers
api gateway
aws iot
cloudfront
cloud watch events & logs
codecommit
cognito sync trigger
dynamo db
kinesis
s3
sns
When multiple requests come to same lambda function, does it all go to 1 instance of lambda
No, multiple instances of the lambda are created and executed- code within it is identical
across instances
Languages supported by lambda
Node.js
Java
Python
C#
Lambda pricing
Based on number of requests- first 1 mill free
Duration - how long it executes & depending on how much memory is being used
What is maximum threshold of a lambda duration
function cant execute beyond 5 minutes
Does lambda scale up or out
out
Can a lambda function trigger another lambda function
yes
downside of lambda
Architectures can get complicated
Can lambda do things globally
Yes, can use it to back up S3 buckets to other S3 buckets etc
Can RDS trigger lambda
No
How do you give lambda access to aws services
Through policies - these give multiple levels of access to aws services
Flow when lambda is triggered from api gateway
User request comes to api gateway -> goes to lamba proxy -> goes to lambda which executes
function -> response from that goes back to proxy -> to api gateway-> to end user
When using S3 for serverless website, what's important to remember
If you do not have a domain name and just want to use S3 bucket name as DNS, ensure the
S3 bucket name is available and no one else has taken it. Then you can specify the bucket
name as your endpoint for route 53. So, This allows route 53 to connect to S3 bucket
Serverless website components
User -> Route 53 -> S3 hosting html (this html has javascript with a button or something
which when clicked points to api endpoint) aws api gateway -> lamba proxy -> lambda ->
response through lambda proxy -> back to api gateway-> user

Terms in this set (61)

What languages does AWS Lambda support?


Node.js, Python, Java, C#, and Go.
How does AWS Lambda isolate my code?
Each AWS Lambda function runs in its own isolated environment, with its own
resources and file system view. AWS Lambda uses the same techniques as Amazon
EC2 to provide security and separation at the infrastructure and execution levels.
How does AWS Lambda secure my code?
AWS Lambda stores code in Amazon S3 and encrypts it at rest. AWS Lambda
performs additional integrity checks while your code is in use.
What is an AWS Lambda function?
The code you run on AWS Lambda is uploaded as a "Lambda function". Each
function has associated configuration information, such as its name, description,
entry point, and resource requirements. The code must be written in a "stateless"
style i.e. it should assume there is no affinity to the underlying compute
infrastructure. Local file system access, child processes, and similar artifacts may
not extend beyond the lifetime of the request, and any persistent state should be
stored in Amazon S3, Amazon DynamoDB, or another Internet-available storage
service. Lambda functions can include libraries, even native ones.
Will AWS Lambda reuse function instances?
To improve performance, AWS Lambda may choose to retain an instance of your
function and reuse it to serve a subsequent request, rather than creating a new copy.
What if I need scratch space on disk for my AWS Lambda function?
Each Lambda function receives 500MB of non-persistent disk space in its own /tmp
directory.
Why must AWS Lambda functions be stateless?
Keeping functions stateless enables AWS Lambda to rapidly launch as many copies
of the function as needed to scale to the rate of incoming events. While AWS
Lambda's programming model is stateless, your code can access stateful data by
calling other web services, such as Amazon S3 or Amazon DynamoDB.
Can I use threads and processes in my AWS Lambda function code?
Yes. AWS Lambda allows you to use normal language and operating system
features, such as creating additional threads and processes. Resources allocated to
the Lambda function, including memory, execution time, disk, and network use, must
be shared among all the threads/processes it uses. You can launch processes using
any language supported by Amazon Linux.
What restrictions apply to AWS Lambda function code?
Lambda attempts to impose as few restrictions as possible on normal language and
operating system activities, but there are a few activities that are disabled: Inbound
network connections are blocked by AWS Lambda, and for outbound connections
only TCP/IP sockets are supported, and ptrace (debugging) system calls are
blocked. TCP port 25 traffic is also blocked as an anti-spam measure.
How do I create an AWS Lambda function using the Lambda console?
If you are using Node.js or Python, you can author the code for your function using
code editor in the AWS Lambda console which lets you author and test your
functions, and view the results of function executions in a robust, IDE-like
environment. Go to the console to get started.
You can also package the code (and any dependent libraries) as a ZIP and upload it
using the AWS Lambda console from your local environment or specify an Amazon
S3 location where the ZIP file is located. Uploads must be no larger than 50MB
(compressed). You can use the AWS Eclipse plugin to author and deploy Lambda
functions in Java. You can use the Visual Studio plugin to author and deploy Lambda
functions in C#, and Node.js.
Does AWS Lambda support environment variables?
Yes. You can easily create and modify environment variables from the AWS Lambda
Console, CLI or SDKs.
Can I store sensitive information in environment variables?
For sensitive information, such as database passwords, we recommend you use
client-side encryption using AWS Key Management Service and store the resulting
values as ciphertext in your environment variable. You will need to include logic in
your AWS Lambda function code to decrypt these values.
How do I monitor an AWS Lambda function?
AWS Lambda automatically monitors Lambda functions on your behalf, reporting
real-time metrics through Amazon CloudWatch, including total requests, account-
level and function-level concurrency usage, latency, error rates, and throttled
requests.
How do I troubleshoot failures in an AWS Lambda function?
AWS Lambda automatically integrates with Amazon CloudWatch logs, creating a log
group for each Lambda function and providing basic application lifecycle event log
entries, including logging the resources consumed for each use of that function.
How are compute resources assigned to an AWS Lambda function?
In the AWS Lambda resource model, you choose the amount of memory you want
for your function, and are allocated proportional CPU power and other resources. For
example, choosing 256MB of memory allocates approximately twice as much CPU
power to your Lambda function as requesting 128MB of memory and half as much
CPU power as choosing 512MB of memory.
How long can an AWS Lambda function execute?
AWS Lambda functions can be configured to run up to 15 minutes per execution.
You can set the timeout to any value between 1 second and 15 minutes.
Does AWS Lambda support versioning?
Yes. By default, each AWS Lambda function has a single, current version of the
code. Clients of your Lambda function can call a specific version or get the latest
implementation.
How long after uploading my code will my AWS Lambda function be ready to call?
Deployment times may vary with the size of your code, but AWS Lambda functions
are typically ready to call within seconds of upload.
Can I use my own version of a supported library?
Yes. you can include your own copy of a library (including the AWS SDK) in order to
use a different version than the default one provided by AWS Lambda.
What is an event source?
It's what produces events that trigger an AWS Lambda function to run.
How are events represented in AWS Lambda?
Events are passed to a Lambda function as an event input parameter. For event
sources where events arrive in batches, such as Amazon SQS, Amazon Kinesis,
and Amazon DynamoDB Streams, the event parameter may contain multiple events
in a single call, based on the batch size you request.
Q: How do I make an AWS Lambda function respond to changes in an Amazon S3
bucket?
From the AWS Lambda console, you can select a function and associate it with
notifications from an Amazon S3 bucket. Alternatively, you can use the Amazon S3
console and configure the bucket's notifications to send to your AWS Lambda
function. This same functionality is also available through the AWS SDK and CLI.
How do I make an AWS Lambda function respond to updates in an Amazon
DynamoDB table?
You can trigger a Lambda function on DynamoDB table updates by subscribing your
Lambda function to the DynamoDB Stream associated with the table. You can
associate a DynamoDB Stream with a Lambda function using the Amazon
DynamoDB console, the AWS Lambda console or Lambda's registerEventSource
API.
How do I use an AWS Lambda function to process records in an Amazon Kinesis
stream?
From the AWS Lambda console, you can select a Lambda function and associate it
with an Amazon Kinesis stream owned by the same account. This same functionality
is also available through the AWS SDK and CLI.
How does AWS Lambda process data from Amazon Kinesis streams and Amazon
DynamoDB Streams?
The Amazon Kinesis and DynamoDB Streams records sent to your AWS Lambda
function are strictly serialized, per shard. This means that if you put two records in
the same shard, Lambda guarantees that your Lambda function will be successfully
invoked with the first record before it is invoked with the second record. If the
invocation for one record times out, is throttled, or encounters any other error,
Lambda will retry until it succeeds (or the record reaches its 24-hour expiration)
before moving on to the next record. The ordering of records across different shards
is not guaranteed, and processing of each shard happens in parallel.
How do I use an AWS Lambda function to respond to notifications sent by Amazon
Simple Notification Service (SNS)?
From the AWS Lambda console, you can select a Lambda function and associate it
with an Amazon SNS topic. This same functionality is also available through the
AWS SDK and CLI.
How do I use an AWS Lambda function to respond to emails sent by Amazon Simple
Email Service (SES)?
From the Amazon SES Console, you can set up your receipt rule to have Amazon
SES deliver your messages to an AWS Lambda function. The same functionality is
available through the AWS SDK and CLI.
How do I use an AWS Lambda function to respond to Amazon CloudWatch alarms?
First, configure the alarm to send Amazon SNS notifications. Then from the AWS
Lambda console, select a Lambda function and associate it with that Amazon SNS
topic.
How can my application trigger an AWS Lambda function directly?
You can invoke a Lambda function using a custom event through AWS Lambda's
invoke API. Only the function's owner or another AWS account that the owner has
granted permission can invoke the function.
What is the latency of invoking an AWS Lambda function in response to an event?
AWS Lambda is designed to process events within milliseconds. Latency will be
higher immediately after a Lambda function is created, updated, or if it has not been
used recently.
How do I create a mobile back-end using AWS Lambda?
ou upload the code you want AWS Lambda to execute and then invoke it from your
mobile app using the AWS Lambda SDK included in the AWS Mobile SDK. You can
make both direct (synchronous) calls to retrieve or check data in real time as well as
asynchronous calls. You can also define a custom API using Amazon API Gateway
and invoke your Lambda functions through any REST compatible client.
How do I invoke an AWS Lambda function over HTTPS?
You can invoke a Lambda function over HTTPS by defining a custom RESTful API
using Amazon API Gateway. This gives you an endpoint for your function which can
respond to REST calls like GET, PUT and POST.
How can my AWS Lambda function customize its behavior to the device and app
making the request?
When called through the AWS Mobile SDK, AWS Lambda functions automatically
gain insight into the device and application that made the call through the 'context'
object.
How can my AWS Lambda function personalize their behavior based on the identity
of the end user of an application?
When your app uses the Amazon Cognito identity, end users can authenticate
themselves using a variety of public login providers such as Amazon, Facebook,
Google, and other OpenID Connect-compatible services. User identity is then
automatically and secured presented to your Lambda function in the form of an
Amazon Cognito id, allowing it to access user data from Amazon Cognito, or as a
key to store and retrieve data in Amazon DynamoDB or other web services.
What happens if my function fails while processing an event?
For Amazon S3 bucket notifications and custom events, AWS Lambda will attempt
execution of your function three times in the event of an error condition in your code
or if you exceed a service or resource limit.

For ordered event sources that AWS Lambda polls on your behalf, such as Amazon
DynamoDB Streams and Amazon Kinesis streams, Lambda will continue attempting
execution in the event of a developer code error until the data expires. You can
monitor progress through the Amazon Kinesis and Amazon DynamoDB consoles
and through the Amazon CloudWatch metrics that AWS Lambda generates for your
function. You can also set Amazon CloudWatch alarms based on error or execution
throttling rates.
What is a serverless application?
A typical serverless application consists of one or more functions triggered by events
such as object uploads to Amazon S3, Amazon SNS notifications, or API actions.
These functions can stand alone or leverage other resources such as DynamoDB
tables or Amazon S3 buckets. The most basic serverless application is simply a
function.
How do I deploy and manage a serverless application?
You can deploy and manage your serverless applications using the AWS Serverless
Application Model (AWS SAM). AWS SAM is a specification that prescribes the rules
for expressing serverless applications on AWS. This specification aligns with the
syntax used by AWS CloudFormation today and is supported natively within AWS
CloudFormation as a set of resource types (referred to as "serverless resources").
These resources make it easier for AWS customers to use CloudFormation to
configure and deploy serverless applications, using existing CloudFormation APIs.
How can I discover existing serverless applications developed by the AWS
community?
You can choose from a collection of serverless applications published by developers,
companies, and partners in the AWS community with the AWS Serverless
Application Repository. After finding an application, you can configure and deploy it
straight from the Lambda console.
How do I automate deployment for a serverless application?
You can automate your serverless application's release process using AWS
CodePipeline and AWS CodeDeploy. CodePipeline is a continuous delivery service
that enables you to model, visualize and automate the steps required to release your
serverless application. CodeDeploy provides a deployment automation engine for
your Lambda-based applications. CodeDeploy lets you orchestrate deployments
according to established best-practice methodologies such as canary and linear
deployments, and helps you establish the necessary guardrails to verify that newly-
deployed code is safe, stable, and ready to be fully released to production.
How do I get started on building a serverless application?
To get started, visit the AWS Lambda console and download one of our blueprints.
The file you download will contain an AWS SAM file (which defines the AWS
resources in your application), and a .ZIP file (which includes your function's code).
You can then use AWS CloudFormation commands to package and deploy the
serverless application that you just downloaded.
How do I coordinate calls between multiple AWS Lambda functions?
You can use AWS Step Functions to coordinate a series of AWS Lambda functions
in a specific order. You can invoke multiple Lambda functions sequentially, passing
the output of one to the other, and/or in parallel, and Step Functions will maintain
state during executions for you.
How do I troubleshoot a serverless application?
You can enable your Lambda function for tracing with AWS X-Ray by adding X-Ray
permissions to your Lambda function's execution role and changing your function's
"tracing mode" to "active. " When X-Ray is enabled for your Lambda function, AWS
Lambda will emit tracing information to X-Ray regarding the Lambda service
overhead incurred when invoking your function. This will provide you with insights
such as Lambda service overhead, function init time, and function execution time. In
addition, you can include the X-Ray SDK in your Lambda deployment package to
create your own trace segments, annotate your traces, or view trace segments for
downstream calls made from your Lambda function. X-Ray SDKs are currently
available for Node.js and Java.
What is Lambda@Edge?
Lambda@Edge allows you to run code across AWS locations globally without
provisioning or managing servers, responding to end users at the lowest network
latency. You just upload your Node.js code to AWS Lambda and configure your
function to be triggered in response to Amazon CloudFront requests (i.e., when a
viewer request lands, when a request is forwarded to or received back from the
origin, and right before responding back to the end user). The code is then ready to
execute across AWS locations globally when a request for content is received, and
scales with the volume of CloudFront requests globally.
How do I use Lambda@Edge?
To use Lambda@Edge, you just upload your code to AWS Lambda and associate a
function version to be triggered in response to Amazon CloudFront requests. Your
code must satisfy the Lambda@Edge service limits. Lambda@Edge only supports
Node.js for global invocation by CloudFront events at this time. L
When should I use Lambda@Edge?
Lambda@Edge is optimized for latency sensitive use cases where your end viewers
are distributed globally. All the information you need to make a decision should be
available at the CloudFront edge, within the function and the request. This means
that use cases where you are looking to make decisions on how to serve content
based on user characteristics (e.g., location, client device, etc) can now be executed
and served close to your users without having to be routed back to a centralized
server.
Can I deploy my existing Lambda functions for global invocation?
You can associate existing Lambda functions with CloudFront events for global
invocation if the function satisfies the Lambda@Edge service requirements and
limits.
What Amazon CloudFront events can be used to trigger my functions?
Your functions will automatically trigger in response to the following Amazon
CloudFront events:
Viewer Request - This event occurs when an end user or a device on the Internet
makes an HTTP(S) request to CloudFront, and the request arrives at the edge
location closest to that user.
Viewer Response - This event occurs when the CloudFront server at the edge is
ready to respond to the end user or the device that made the request.
Origin Request - This event occurs when the CloudFront edge server does not
already have the requested object in its cache, and the viewer request is ready to be
sent to your backend origin webserver (e.g. Amazon EC2, or Application Load
Balancer, or Amazon S3).
Origin Response - This event occurs when the CloudFront server at the edge
receives a response from your backend origin webserver.
How is AWS Lambda@Edge different from using AWS Lambda behind Amazon API
Gateway?
The difference is that API Gateway and Lambda are regional services. Using
Lambda@Edge and Amazon CloudFront allows you to execute logic across multiple
AWS locations based on where your end viewers are located.
Is there a limit to the number of AWS Lambda functions I can execute at once?
No. AWS Lambda is designed to run many instances of your functions in parallel.
However, AWS Lambda has a default safety throttle for number of concurrent
executions per account per region
What happens if my account exceeds the default throttle limit on concurrent
executions?
On exceeding the throttle limit, AWS Lambda functions being invoked synchronously
will return a throttling error (429 error code). Lambda functions being invoked
asynchronously can absorb reasonable bursts of traffic for approximately 15-30
minutes, after which incoming events will be rejected as throttled. In case the
Lambda function is being invoked in response to Amazon S3 events, events rejected
by AWS Lambda may be retained and retried by S3 for 24 hours. Events from
Amazon Kinesis streams and Amazon DynamoDB streams are retried until the
Lambda function succeeds or the data expires. Amazon Kinesis and Amazon
DynamoDB Streams retain data for 24 hours.
What happens if my Lambda function fails during processing an event?
On failure, Lambda functions being invoked synchronously will respond with an
exception. Lambda functions being invoked asynchronously are retried at least 3
times. Events from Amazon Kinesis streams and Amazon DynamoDB streams are
retried until the Lambda function succeeds or the data expires. Kinesis and
DynamoDB Streams retain data for a minimum of 24 hours.
What happens if my Lambda function invocations exhaust the available policy?
On exceeding the retry policy for asynchronous invocations, you can configure a
"dead letter queue" (DLQ) into which the event will be placed; in the absence of a
configured DLQ the event may be rejected. On exceeding the retry policy for stream
based invocations, the data would have already expired and therefore rejected.
What resources can I configure as a dead letter queue for a Lambda function?
You can configure an Amazon SQS queue or an Amazon SNS topic as your dead
letter queue.
How do I allow my AWS Lambda function access to other AWS resources?
You grant permissions to your Lambda function to access other resources using an
IAM role. AWS Lambda assumes the role while executing your Lambda function, so
you always retain full, secure control of exactly which AWS resources it can use.
How do I control which Amazon S3 buckets can call which AWS Lambda functions?
When you configure an Amazon S3 bucket to send messages to an AWS Lambda
function a resource policy rule will a be created that grants acces
How do I control which Amazon DynamoDB table or Amazon Kinesis stream an
AWS Lambda function can poll?
Access controls are managed through the Lambda function's role. The role you
assign to your Lambda function also determines which resource(s) AWS Lambda
can poll on its behalf.
How do I control which Amazon SQS queue an AWS Lambda function can poll?
Access controls can be managed by the Lambda function's role or a resource policy
setting on the queue itself. If both policies are present, the more restrictive of the two
permissions will be applied.
Can I access resources behind Amazon VPC with my AWS Lambda function?
Yes. You can access resources behind Amazon VPC.
How do I enable and disable the VPC support for my Lambda function?
To enable VPC support, you need to specify one or more subnets in a single VPC
and a security group as part of your function configuration. To disable VPC support,
you need to update the function configuration and specify an empty list for the
subnet and security group. You can change these settings using the AWS APIs, CLI,
or AWS Lambda
Can a single Lambda function have access to multiple VPCs?
No. Lambda functions provide access only to a single VPC. If multiple subnets are
specified, they must all be in the same VPC. You can connect to other VPCs by
peering your VPCs.
Can Lambda functions in a VPC also be able to access the internet and AWS
Service endpoints?
Lambda functions configured to access resources in a particular VPC will not have
access to the internet as a default configuration. If you need access to external
endpoints, you will need to create a NAT in your VPC to forward this traffic and
configure your security group to allow this outbound traffic.

Terms in this set (19)

stateless style
It is best practice to write a AWS Lambda function in a stateless style. It should not
have any affinity with the underlying compute infrastructure.
persistent state
Persistent state should be stored in another cloud service, such as Amazon S3 or
DynamoDB.
lambda handler
It is a recommended to separate core logic from the Lambda handler as the handler
is generally used as an entry point to the function
deploy over a VPC
When a Lambda function is deployed over a VPC, it is a best practice to avoid DNS
resolution for a public hostname, as it may take several seconds to resolve and it
adds several billable seconds.
subnet
It is recommended to specify at least one subnet in each AZ with the Lambda
function configuration.
sufficient subnet IPs
It is recommended to make sure sufficient subnet IPs are free to allow Lambda
functions to scale. If there aren't any free subnet IPs, Lambda functions will not scale
and Lambda function failure will increase.
Static initialization
Rather than re-initializating variables or objects on every invocation, use static
initialization or constructor, global, or static variables and singletons. It helps to
improve the performance of the Lambda function.
reuse connection
Where possible, keep alive and reuse connections such as database or HTTP that
were established in an earlier invocation.
environmental variables
To cope with frequent changes in the operational parameters, pass them using
environment variables to avoid frequent changes in a Lambda
all the dependencies
It is a best practice to pack all the dependencies in a deployment of a Lambda
function. Where possible, control the dependencies in the Lambda function to
minimize the overall size and execution time.
java programming
If you are using a Java programming language, put dependencies in a separate /lib
directory rather than putting all functions, source code in a single jar with a large
number of .class files.
simple framework
It is highly recommended to use a simple framework and minimize the complexity of
the dependencies to quickly load the container startup.
monitor lambda functions
It is a best practice to use Lambda metrics and CloudWatch alarms to monitor
Lambda functions health rather than creating and maintaining custom metrics from
Lambda function code.
memory
The amount of memory that can be allocated to a Lambda function ranges between
128 and 1536 MB. The minimum memory that can be allotted to a Lambda function
is 128 MB. Based on the requirement, you can allot more memory in increments of
64 MB
parameters
Maximum execution time (timeout): The maximum it can be 5 minutes
IAM role (execution role): Lambda can assume an IAM role at the time of execution
Handler name: It refers to the method name to be used by AWS Lambda to start the
execution.
code for a Lambda function
Handler
The context object
Logging
Exceptions
deploying
Once the source code is converted into a deployment package, it can either be
directly uploaded to Lambda from the local machine or first to an Amazon S3 bucket.
The S3 bucket should be in the same region where the Lambda function is being
created. Specify the same S3 link URL while creating a Lambda function.
alia
An alias can only point to the function version. It cannot point to another alias.
stream base aws service
Out of all the supported AWS services, Amazon Kinesis Streams and Amazon
DynamoDB streams are the only stream-based AWS services. The rest of the
services are regular AWS services.

erms in this set (5)

What is Amazon Lambda?


It is a compute service where you can upload your code and create a Lambda
function. AWS Lambda takes care of provisioning and managing the servers that you
use to run the code. You don't have to worry about operating systems, patching,
scaling, etc. You can use Lambda in the following ways.
How can you use Lambda?
> As an event-driven compute service where AWS Lambda runs your code in
response to events. These events could be changes to data in an Amazon S3 bucket
or an Amazon DynamoDB table.
> As a compute service to run your code in response to HTTP requests using
Amazon API Gateway or API calls made using AWS SDKs. Example: this is how A
Cloud Guru was built.
What languages does Lambda support as of May 2017?
> Node.js
> Java
> Python
> C#
How is Lambda priced?
> Number of requests
- First 1 million requests are free. $0.20 per 1 million requests thereafter.

> Duration of a function run


- Duration is calculated from the time you code begins executing until it returns or
otherwise terminates, rounded up to the nearest 100ms. The price depends on the
amount of memory you allocate to your function. You are charged $0.00001667 for
every Gb-second used.
Why is Lambda cool?
> No servers!
> Continuous scaling
> Super, super cheap!

Terms in this set (119)

5. is lambda same as serverless?


no. Serverless is a different by a different company.
6 Lambda is triggered by
events
11. 2 examples of events that can trigger lambda functions
dynamodb table updates and s3 object change
12 Ecplise has a aws toolkit in which you can write your lambda functions. true or false
true
Google Equivalent of Lambda Functions
GCP Serverless
all the lambda functions have to
stateless
however, your lambda functions can connect to 2 persistent data stores
s3 and dynamodb
can aws lambda functions run on schedule like cron
yes
lambda functions are _____ driven
event
2 examples of events that can trigger a lambda functions
file upload, api calls
How many free lambda function requests do you get on amaxon per month?
1 million
How free memory usage do you get on aws lambds
400 Gigabyte-seconds per month
1 Gigabyte-second?
1 Gigabyte of RAM for 1 second
Lamba shows up _______________ section on the AWS console
EC2
Can a table update in Dynamodb trigger a lambda function?
Yes
13 Some example events that trigger lambda function
1. table update in dynamodb
2. change in S3 bucket
3. SNS message
4. new message in kinesis stream
5. AWS API call logs created by CloudTrail
6. data syn even in AWS Cognito
7. custom events from Mobile Apps, Web apps or other web services
Lambda works in 2 event models
push event model
pull event model
Lambda functions can be written in (5 Languages)
1. Node,js (javascript)
2. Go
3. Python
4. Java (8)
5. C# / .NET
14 One difference between Lambda or running code in Container service
You will have to maintain the life-cycle of the contaoners
One difference between lambda and Elastic Beanstalk
Lambda functions are publicly accessible.
Beanstalk apps are only accessible via their REST endpoints
An example scenario where you need a lambda code:
New data coming into dynamodb or kinesis need processing!
True/False: Lambda can work with external event timers
True
Lambda functions are stateless/stateful
stateless
15 Can you add more >1 lambda functions to one source?
Yes
16 How fast is Lambda?
code is executed in milliseconds
Lambda provides built-in logging via __________________
Cloudwatch
First step toward writing a lambda function
AWS Console, find Lambda in Compute Section
can lambda function run on schedule like a cron job?
yes
price. 1 minute 512MB job runs 3 million times
18 dollars
Lambda and API ....... service go together
Gateway
Author Danilo Poccita has degree in
Physics
18 Context
Memory allocation etc
Synchronous function
Function returns a value basically immediately
Asynchronous function
Does not return a value. Goes off and does something
Example of asynchronous function
Subscribed to something
Functions run on what?
Containers
Event driven functions helps with logic and ——
Scale
HTTP verbs
PUT GET POST and 1 more
Can a lambda function subscribe to SNS topic ?
Yes
Can a table update trigger a lambda function?
Yes
Can lambda be triggered by new message in kinesics streams
Yes
Is PHP supported in AWS Lambda?
Yes
How to add HTTP endpoint using Lambda?
Just use API Gateway as trigger
Can functions send messages between them?
Yes
4 ways to send messages between lambda functions. There may be more
SNS, SQS, Direct Calling, Asynchronous calling
Can you create stateful functions using Lambda?
Yes
20 Which one is better suited for lambda: stateful or stateless?
Stateless
21 If you are writing stateful functions in lambda, where can you store the state info?
Dynamodb or s3
22. 3 ways to create aws lamba functions
1. console 2. CLI an d3. SDK
23 Price for authenticating users with AWS Cognito and generating unique keys:
Zero
20 Can Lambda function use roles?
Yes
What can lambda functions use role for?
To get the necessary combinations of permissions to do its job
package that manages modules for node.js ?
npm
package that manages modules for Python?
Pip
24 If your function needs a dependency package (lets say a node.js library), how is that
supplied to you AWS when it is needed by a lambda function?
on your laptop: function goes into "root" folder (not unix root) and the library is in folder
under it and whole thing is zipped up to AWS lambda.
25 maximum size of zip file upload for lambda?
10MB
Where do the lambda functions actually run?
Containers
What does AWS lambda provide to help you write functions so that you don't have to write
from scratch?
Blueprints
26 Which built in role is adequate to run simple lambda functions?
Lambda_basic_execution
3 ways to upload code?
Inline, upload zip file, upload from S3
Handler = ?
Name of the function
What is another name for runtime information
Context
Can you test your function without a actual real life trigger?
Yes. Orange button top right
In JavaScript which method will output something when the lambda function runs?
message
Callback happens when?
When function is done
Callback returns ______ or ______
Error message or result
Each function comes with its own ___________________
Configuration
Lambda function takes input in __________
key value pairs
Is "API Gateway" an option for trigger?
Yes
Name 7 triggers (there are more)
API Gateway
AWS IoT
Cloudfront
Cloudwatch Events: Scchedule
Cloudwatch Logs
Code Commit
Cognito Sync Trigger
When you decide to create a new API Gateway, it asks for a name. What does this name
signify?
Nothing. It's like foobar
FaaS
Function as a service
4 ways a lambda function can finish
Crash
Timeout
Controlled termination
4 ways a lambda function can end?
1. crash
2. timeout
3. default completion???
4. completion when callback returns
Lambda function takes 3 parameters:
1. Event
2. Context
3. Callback function
When will callback is run?
When the function is done running
Which 2 things can the callback function return?
1. result or
2. error message
What's a quick way to write a helloworld lambda function?
Go to Lambda service
Create new function
Choose your favorite language (e.g. node.js 8.10)
In inline code section, there will already be some helloworld type code given to you by AWS.
Save and you are done.
Can you test run an AWS function without a real trigger?
Yes. Orange test button on the top right
If you run a test, how do you find the results?
There is a tiny obscure button towards the top left
A resource in API Gateway is basically
URL segment
Lambda is part of ________ services
Compute
Use strict JavaScript
It's a mode of JavaScript execution. For example, cannot use undeclared variables
In handler function which method writes to cloudwatch logs?
Console.log
In JavaScript code, how to retrieve the first default key value
Event.key1
within exports.handler, (in javascript), how to set variable A to number 1?
let A = 1;
Using JavaScript, within the handler function, how do you send a success message back out
to the world?
Context.succeed("this is my message back out to the world");
How to return value of key1 via callback
Callback(null, event.key1)
In handler function, how to assign the result of math.random function to variable foobar?
let foobar = math.random();
Which two parameters does callback function take?
error code and success message

e.g. callback (error, success)


If there is no error to report back, what value do you pass as the error code in callback
function?
null

e.g.
callback(null, success)
Can you fee the callback function a variable in place of success message?
Yes, e.g.

callback(null, A)
AWS lambda advanced does not specify CPU etc ? So, what do you do you do if your
function will be resource intensive?
increase the memory size. You will get more (equivalent) CPU power
What is the minimum amount of memory you can assign to a lambda function?
128MB
What is the default timeout for a lambda function?
3 seconds
What happens if your function runs longer than the timeout limit specified?
AWS will just kill it and return an error message
why would a lambda function need a vpc?
If the function needs to access resources that live within a VPC e.g. elasticache, RDS,
redshift)
In the lambda configuration there is a setting for hander: It is set to index.handler. What does
that mean?
When you wrote you function, you called your called your handler function (javascript)
literally "handler". So, it refers to that. I guess , here "index" is like a predetermined key word
If you just ran a "test" of a lambda function, how do you know how much time/memory it
took?
Right below "Execution Result: Succeeded", there is a TOGGLE for "Details.

If you click on it, it expands and it gives you those details.

If you click it again, it hides the details.


How does aws Lambda communicate with your lambda function?
via the "context" object that is passed to the function
context is an ______
object
how do you figure out how much time you function has left before it times out (while its
running)
via the context
True/False: AWS Lambda keeps session info once a function terminates?
False
True/False: Lambda functions can create/update/delete other services
True
in node.js how to write to AWS logs?
console.log(event.message)
in Python, how to write to AWS logs?
print (event ['message'])
Lambda helps you couple or de-couple?
de-coiple
True/False: With Lambda, you can have one backend to serve all your application clients?
True
True/False: With Amazon Cognito , clients can use external authentications like
Facebook/Google
True
Name 4 examples of HTTP Verbs
GET
PUT
DELETE
POST
Do you need a Lambda for EACH combination of "resource" and "HTTP Verb"?
No

e.g. One lambda function can process both GET and POST
3 ways you can create a Lambda function:
Console
CLI
SDK
In a Python function how do you use "json" library?
import json
Lambda function executes in a _______ environment without any display
Headless
In Node.js , how do you end your function?
callback
In Python, how do you end your function?
return
If your function is rarely used, the next execution maybe slower , why?
AWS would have released your function execution environment
How can you call your function using AWS Lambda's API?
Use AWS CLI
Can you choose API Gateway as a Trigger?
Yes

Terms in this set (34)

What is AWS Lambda?


A compute service where you can upload code and create a lambda function. AWS
takes care of all provisioning and managing the servers you use to run the code -- no
need to worry about OS, patching, scaling, etc.
What are the two ways to use AWS Lambda?
Event-driven computer service where lambda runs code in response to something
like a change in data in dynamodb, s3, etc. These are called triggers.

You can also use it in conjunction with API gateway to respond to HTTP requests
What languages are supported by lambda?
Nojde.js, Java, Python, C#, Go
How is lambda priced
By number of requests (first 1 million are free, then 20 cents per million requests
thereafter) and by duration (calculated from the time your code begins executing).
how does Lambda scale
out (not up). This means you can have millions of functions running in parallel, but if
you run out of memory you need to upgrade the amount of memory
What does it mean that lambda functions are independent
1 event = 1 function
What can you use to debug lambda?
X-Ray
Can you use Lambda for global functions, like to back up an S3 bucket?
Yes
What services can trigger lambda functions?
S3, DynamoDB, Kinesis Data Streams, SNS, SES, SQS, Cognito, Cloudformation,
Cloudwatch, Alex, API Gateway, Cloudfront
What do restful apis look like?
key-value pairs like json
What does the SOAP API use?
XML and it's old as shit. Looks like html.
What is API Gateway?
Allows you to create an API that acts as a front door/waiter for applications to access
data, business logic, or functionality from back end services like EC2 or code running
on lambda
How do you configure API Gateway
1. Define an API (container)
2. Define resources and nested resources (URL paths)
3. Select a supported HTTP verb for each resource
4. set security
5. choose target (EC2, Lambda, DynamoDB, etc)
6. Set request/response transformations
7. Deploy to a stage (test, prod, etc)
What is API caching?
Allows you to cache common endpoint responses to increase performance. That
way, you reduce actual calls to your API and just send the response.
How long do API responses stay cached when you enable API caching?
A TTL in seconds
What should you do if you see an error that says "Origin policy cannot be read at the
remote resource"
Enable CORS on API Gateway
Can you publish more than one version of a lambda function?
You know you can! And they all have a unique ARN
What are the types of ARNS you can refer to your lambda function with?
Qualified ARN: has a version suffix
Unqualified ARN: no version suffix
Can you edit lambda versions after you publish them?
No, you can only edit the latest version, called $latest
What are Lambda Aliases?
A name that points to a particular version of your function -- Prod can point to version
one, Test to version 2, etc.
How can you split traffic?
Using aliases into different versions
Can you split traffic with $latest?
Nope. Need to create an alias to latest instead.
What are step functions?
Allow you to visualize and test serverless applications that provide a graphic console
to arrange and visualize components of apps. It logs state of each step so you can
diagnose and debug quickly.
What is X-Ray?
A service that collects data about requests that your application serves and provides
tools you can use to view and gain insights about that data.
What kind of data can you see with X-Ray on traced requests to your app?
Info about rqwuest, response, calls your app makes to downstream AWS resources,
HTTP web apis, etc
How does X-ray work?
1. X-Ray SDK is installed in your app
2. Sends JSON-style docs to X-Ray Daemon
3. Which sends it to the X-Ray API
4. Where you can see a visualization on what's happening with your data
What does the X-Ray SDK provide?
1. Interceptors to add to your code to trace incoming HTTP requests
2. Client handlers to create sdk clients your app uses to call other AWS services
3. A http client to create calls to other internal and external http web services
What does X-Ray integrate with?
Elastic Load Balancing, Lambda, API Gateway, EC2, elastic beanstalk
How can you import API Gateways?
Using the API gateway import that supports Swagger v2.0 definition files
What can you do with Import API?
1. create a new API by submitting a post request
2. Update an existing API by using a put request that contains a swagger definition in
the payload.
What is API Gateway's default limit for request rates/second?
10,000
What is the max concurrent request rate across all APIs?
5000
What do you get if you violate the max concurrent request rate or the default limit for
request rates/second?
A 429 (too many requests) error
What happens if a caller sends 10,000 rquests in the first millisecond?
API gateway serves 5,000 of those request and then throttles the rest within a one
second period.

You might also like