DVA-C02 · Question #245
A developer registered an AWS Lambda function as a target for an Application Load Balancer (ALB) using a CLI command. However, the Lambda function is not being invoked when the client sends requests…
The correct answer is C. The permissions to invoke the Lambda function are missing. When a Lambda function is registered as an ALB target via CLI, the ALB must be explicitly granted permission to invoke it via a resource-based policy. Without this permission, requests through the ALB will fail silently.
Question
A developer registered an AWS Lambda function as a target for an Application Load Balancer (ALB) using a CLI command. However, the Lambda function is not being invoked when the client sends requests through the ALB. Why is the Lambda function not being invoked?
Options
- AA Lambda function cannot be registered as a target for an ALB.
- BA Lambda function can be registered with an ALB using AWS Management Console only.
- CThe permissions to invoke the Lambda function are missing.
- DCross-zone is not enabled on the ALB.
How the community answered
(53 responses)- A2% (1)
- B6% (3)
- C89% (47)
- D4% (2)
Why each option
When a Lambda function is registered as an ALB target via CLI, the ALB must be explicitly granted permission to invoke it via a resource-based policy. Without this permission, requests through the ALB will fail silently.
Lambda functions can be registered as ALB targets; this is a supported integration since 2018.
Lambda targets can be registered with an ALB using the CLI, SDKs, or CloudFormation, not just the console.
Registering a Lambda function as an ALB target does not automatically grant the ALB invoke permissions. A resource-based policy must be added to the Lambda function using `lambda:AddPermission` with the ALB as the principal. Without this explicit permission, the ALB cannot invoke the function, even if it is correctly registered as a target.
Cross-zone load balancing distributes traffic across Availability Zones and has no bearing on whether a Lambda function can be invoked.
Concept tested: Lambda resource-based policy for ALB invocation
Source: https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html
Community Discussion
No community discussion yet for this question.