AWS 19 Flashcards Preview

AWS Developer > AWS 19 > Flashcards

Flashcards in AWS 19 Deck (58)
Loading flashcards...
1
Q

Docker can run on lambda, true or false?

A

False

2
Q

When is Lambda synchronously invoked?

A
ELB;
API Gateway;
CloudFront;
Amazon S3 Batch;
Amazon Cognito;
AWS Step Functions
3
Q

How do we register Lambda with an ALB?

A

Make sure Lambda is registered in a target group

4
Q

What are multi-value headers in an ALB and Lambda?

A

When you have HTTP headers or query string paramaters that are sent with multiple values, they are shown as arrays within the AWS Lambda event and response objects;
*It is a setting on the ALB

5
Q

What allows the ALB to invoke the lambda?

A

A resource based policy. Remember, we set a resource based policy when other services want to communicate with lambda

6
Q

What is Lambda@Edge?

A

We can deploy Lambda functions alongside your CloudFront CDN to build more responsive applications;
You can use Lambda to change CloudFront request and responses

7
Q

What triggers Lambda asynchronously?

A

S3, SNS, CloudWatch Events/EventBridge

8
Q

How does Asynchronous Lambda work? What is it good for?

A

The events are placed in an Event Queue;

It is good for speeding up processes you don’t need to wait for

9
Q

How do we make sure an event is sent from S3 to Lambda for every successful write?

A

Make sure versioning is enabled. It is possible that two writes can be made to the same bucket and only one notification is sent if non-versioning is enabled.

10
Q

What three services can Lambda event source map?

A

Kinesis streams, SQS & SQS FIFO queu, DynamoDB streams

11
Q

When Lambda does event source mapping, is this a syncronous operation or async?

A

Synchronous because Lambda needs to poll from the source and then triggers a Lambda function

12
Q

For Lambda and Streams, what happens if a function returns an error?

A

The entire batch is reprocessed until success or batch is expired

13
Q

Lambda ESM will poll SQS using what method?

A

Long Polling

14
Q

To set up a DLQ for Lambdas ESM with SQS, what do we do?

A

We must set it up on the SQS queue, not Lambda (DLQ for Lambda is only for async invocations)

15
Q

For Lambda and FIFO queue, scaling lambdas up to number of active message groups is permitted, true or false?

A

True

16
Q

How can we speed up processing with Lambda and Streams?

A

We can process multiple batches in parallel;

Up to 10 batches per shard;

17
Q

For streams and parallelization, in-order processing is not guaranteed for each partition key, true or false?

A

False. It is guaranteed

18
Q

For processing async invocations in Lambda, we should make sure the logic is?

A

Idempotent, in case of retries. The same invocation will produce the same result

19
Q

Before an async invocation hits the lambda, where does it go?

A

It goes through an internal event queue in Lambda

20
Q

What is the Event Source Mapping in Lambda used for?

A

Polling and receiving a batch from a stream source

21
Q

When an error occurs with Lambdas and queues, what happens?

A

Remember that this would be for Event Source Mapping;
Batches are returned to the queue as individual items and might be processed in different grouping than the original batch

22
Q

How can we handle errors in Lambda event source mapping with streams?

A

Restrict the number of retries;
Split the batch on error (to work around Lambda timeout issues);
Set a destination for failed events;

23
Q

What is the idea of destinations in Lambda?

A

To send the result of an async invocation or an event mapper to a specified location

24
Q

What are our Destinations for Lambda async invocations?

A

SQS, SNS, Lambda, EventBridge

25
Q

Lambda Destinations work for both success and failed processes, true or false?

A

False. Async operations can define destinations for both successful and failed events;
The event source mapper can only be for discarded events

26
Q

What are the destinations for Async operations for lambda? What about ESM?

A

SQS, SNS, Lambda, EventBridge Bus;

SQS, SNS

27
Q

We should create one Lambda Execution Role to cover all functions, true or false?

A

False. Create a Lambda execution role for each function

28
Q

When do we use Lambda Execution Role vs Resource Based Policies?

A

We use the Execution Role to invoke other services and we use resource based policy to grant other services access to our Lambda

29
Q

Lambda cannot write to CloudWatch for logging; what could be the issue?

A

We don’t have the proper execution role for the Lambda

30
Q

How do we enable Lambda tracing with X-Ray?

A

Enable in Lambda configuration (Active Tracing);
Use AWS X-Ray SDK in Code;
Ensure Lambda Function has a correct IAM Execution Role;
Environment Variables to communicate with X-Ray

31
Q

What are the three env variables for Lambda to run with X-Ray?

A

_X_AMZN_TRACE_ID
AWS_XRAY_CONTEXT_MISSING
AWS_XRAY_DAEMON_ADDRESS

32
Q

By default, your Lambda is launched in your own VPC, true or false?

A

False. It is launched in an AWS owned VPC

33
Q

How do we put a Lambda in our VPC?

A

Define the VPC ID, the Subnets and the Security Groups;

We also need the proper VPC Access Execution Role

34
Q

**A lambda function inside your VPC has internet access, true or false?

A

False. By default it does not have Internet Access. Deploying it to a public subnet does not give it internet access.

35
Q

How do we give AWS Lambda internet access?

A

We must route outbound traffic to a NAT gateway in a public subnet

36
Q

Multiple Lambda functions connected to the same subnets share network interfaces, true or false?

A

True

37
Q

How do we get more vCPU credits with Lambda?

A

Increase the RAM

38
Q

What is the default timeout for lambda? What is the maximum?

A

3 seconds, 15 minutes

39
Q

What is the Lambda execution environment?

A

The execution environment manages the resources needed to run your function

40
Q

We need to put DB connections in our handler for our Lambdas, true or false?

A

False. We put it in the execution context or in the code above the handler

41
Q

We want a limit for concurrent Lambda executions. What do we do?

A

Set a reserved concurrency;

For each invocation over the concurrency limit will trigger a “Throttle”;

42
Q

What is the throttle behavior for Lambda async vs sync?

A

Sync returns a ThrottleError;
Async will return the item to the event queue and then retry;
Async wont return an error because it automatically returns a 202

43
Q

What is provisioned concurrency?

A

We allocate concurrency before the function is invoked. This helps improve cold starts. Application Auto Scaling can manage provisioned concurrency based of metrics.

44
Q

What is reserved concurrency?

A

It allocates a specific amount of concurrency to a function so that no other function can use that concurrency. This however limits the maximum amount of concurrency for that function.

45
Q

If our lambda depends on external libraries, what do we do?

A

We install the packages alongside the code and zip it all together

46
Q

We updated Lambda code stored in S3, but CloudFormation doesn’t pick up the change? Why not?

A

We need to update the S3Bucket, S3Key or S3ObjectVersion in the Template or else CloudFormation won’t update the function

47
Q

What are Lambda Layers used for?

A
Custom Runtimes (Rust, C++);
Externalize Dependencies to re-use them;
48
Q

What are lambda aliases?

A

Aliases are “pointers” to Lambda function versions, we can send users/actions through aliases to versions, even weighted (PROD alias will send 90% to V1 and 10% to V2)

49
Q

Lambda aliases may point to lambda aliases, true or false?

A

False

50
Q

How can we use Lambda and CodeDeploy together?

A

CodeDeploy can help us automate traffic shift for Lambda aliases. We can have weighted traffic to Lambda versions.

51
Q

What is the memory allocation for Lambda?

A

128 MB - 3008 MB

52
Q

What is the maximum amount of environment variables for Lambda?

A

4 KB

53
Q

What is the max deployment size for Lambda for compressed and uncompressed?

A

50 MB;

250 MB;

54
Q

You have a Lambda function that will process data for 25 minutes before successfully completing it. The code is working fine on your machine, but in AWS Lambda it just fails with a “timeout” issue after 3 seconds. What should you do?

A

Run your code somewhere else - Lambda only supports 15 minute timeout

55
Q

Your lambda function is invoked asynchronously and some events fail from being processed after 3 retries. You’d like to collect and analyze these events later on. What should do you?

A

Add a DLQ to send messages to SQS

56
Q

You are looking to invoke an AWS Lambda function every hour (similar to a cron job) in a serverless way. Which event source should you use for your AWS Lambda function?

A

CloudWatch Events

57
Q

What is the best way to send the result of an asynchronous Lambda function to SQS?

A

Use a destination

58
Q

What two ways can we configure error handling for async invocations for Lambda?

A

Maximum age of an event;
Retry attempts;
When either of these are exceeded, lambda will discard the events. We can configure a failed-event destination;