AWS Certified Developer Associate · Free Practice Question Medium
Question 30
Based on the following AWS CLI command the resulting output, what has happened here?
- $ aws lambda invoke --function-name MyFunction --invocation-type Event --payload ewogICJrZXkxIjogInZhbHVlMSIsCiAgImtleTIiOiAidmFsdWUyIiwKICAia2V5MyI6ICJ2YWx1ZTMiCn0= response.json
- {
- "StatusCode": 202
- }
-
A
An AWS Lambda function has been invoked synchronously and has completed successfully
-
B
An AWS Lambda function has been invoked asynchronously and has completed successfully
-
C
An AWS Lambda function has been invoked asynchronously and has not completed successfully
-
D
An AWS Lambda function has been invoked synchronously and has not completed successfully
Reveal correct answer
Correct answer: B
Explanation
Several AWS services, such as Amazon Simple Storage Service (Amazon S3) and Amazon Simple Notification Service (Amazon SNS), invoke functions asynchronously to process events.
When you invoke a function asynchronously, you don't wait for a response from the function code. You hand off the event to Lambda and Lambda handles the rest. You can configure how Lambda handles errors, and can send invocation records to a downstream resource to chain together components of your application.
The following diagram shows clients invoking a Lambda function asynchronously. Lambda queues the events before sending them to the function.

For asynchronous invocation, Lambda places the event in a queue and returns a success response without additional information. A separate process reads events from the queue and sends them to your function. To invoke a function asynchronously, set the invocation type parameter to Event.
In this scenario the Event parameter has been used so we know the function has been invoked asynchronously. For asynchronous invocation the status code 202 indicates a successful execution.
CORRECT: "An AWS Lambda function has been invoked asynchronously and has completed successfully" is the correct answer.
INCORRECT: "An AWS Lambda function has been invoked synchronously and has completed successfully" is incorrect as the Event parameter indicates an asynchronous invocation.
INCORRECT: "An AWS Lambda function has been invoked synchronously and has not completed successfully" is incorrect as the Event parameter indicates an asynchronous invocation (a status code 200 would be a successful execution for a synchronous invocation).
INCORRECT: "An AWS Lambda function has been invoked asynchronously and has not completed successfully" is incorrect as the status code 202 indicates a successful execution.
References:
https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html
Save time with our AWS cheat sheets:
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
