Question 1
A developer deployed an Amazon API Gateway REST API that uses a Lambda proxy integration. The Lambda function runs successfully and CloudWatch Logs show no errors, but every client request receives an HTTP 502 Bad Gateway response. What is the MOST likely cause?
- The function returns a response object that does not match the proxy integration format, such as a body that is not a string or a missing statusCode. — Correct
- API Gateway does not have a resource-based permission on the function, so the Lambda service rejects the invocation request before the function code runs.
- The Lambda function takes longer than the API Gateway integration timeout, so API Gateway stops waiting for the function and returns an error to the client.
- The API stage has throttling limits that are lower than the client request rate, so excess requests are rejected by API Gateway.
Correct answer
The function returns a response object that does not match the proxy integration format, such as a body that is not a string or a missing statusCode.
Explanation
With proxy integration, API Gateway returns 502 when the function's output is malformed. A timeout returns 504. A missing invoke permission returns 500 and the function would not run at all. Throttling returns 429.
Question 2
A Lambda function is invoked synchronously by API Gateway. During a marketing event, clients receive HTTP 429 responses and the function's Throttles metric rises. The account has a concurrency quota of 1,000, and the function has no reserved concurrency. Other functions use little concurrency. What should the developer do?
- Reduce the function's memory setting so that Lambda can start more execution environments at the same time.
- Request a Lambda concurrent executions quota increase for the Region and confirm that the function has no reserved concurrency limit. — Correct
- Increase the function's timeout so that each invocation holds its execution environment for a longer time.
- Add provisioned concurrency of 1,000 to the function so that more execution environments are available on top of the account's Regional quota.
Correct answer
Request a Lambda concurrent executions quota increase for the Region and confirm that the function has no reserved concurrency limit.
Explanation
Throttles at the account level mean the Regional concurrency quota is reached, so the quota must be raised. Provisioned concurrency counts against the same quota. A longer timeout and smaller memory do not increase the concurrency available.
Question 3
An EventBridge rule matches order events and targets a Lambda function. The rule's metrics show matched events and FailedInvocations, and the function is never invoked. The rule was created with the AWS CLI. What is the MOST likely cause?
- The function's resource-based policy does not allow events.amazonaws.com to invoke it for the rule's ARN. — Correct
- The event pattern contains a field that does not appear in the events published to the bus.
- The function's execution role does not allow the events:PutEvents action on the event bus.
- The function's reserved concurrency is set to its default value, which blocks EventBridge targets.
Correct answer
The function's resource-based policy does not allow events.amazonaws.com to invoke it for the rule's ARN.
Explanation
When rules are created outside the console, the invoke permission must be added to the function. The execution role is for the function's own calls. The rule's metrics show matched events, so the pattern works. Default concurrency does not block invocations.
Question 4
A team wants a Lambda function to log in a structured JSON format with the request ID, cold start flag, and correlation ID on every line, so that logs can be queried easily. The team wants the LEAST custom code. What should the developer use?
- A Lambda layer that writes logs to a DynamoDB table.
- The Logger utility from Powertools for AWS Lambda. — Correct
- A CloudWatch Logs metric filter on the function's log group.
- Print statements with string concatenation for each field.
Correct answer
The Logger utility from Powertools for AWS Lambda.
Explanation
Powertools Logger emits structured JSON with Lambda context fields. Manual formatting is error-prone. Metric filters do not change log format. Writing logs to DynamoDB is costly and unusual.
Question 5
A team wants to find all traces for a specific customer ID in AWS X-Ray to investigate a complaint. How should the developer record the customer ID?
- Add the customer ID as a tag on the Lambda function resource.
- Write the customer ID to the function's CloudWatch Logs output.
- Add the customer ID as metadata on the segment or subsegment.
- Add the customer ID as an annotation on the segment or subsegment. — Correct
Correct answer
Add the customer ID as an annotation on the segment or subsegment.
Explanation
Annotations are indexed and can be used in trace filter expressions. Metadata is stored but not indexed, so it cannot be searched. Logs and resource tags are not part of trace searches.
Question 6
An application writes thousands of objects per second to an S3 bucket that uses SSE-KMS with a customer managed key. The application receives ThrottlingException errors from KMS. The company must keep using the same customer managed key. Which solution reduces KMS requests MOST cost-effectively?
- Enable S3 Bucket Keys for SSE-KMS on the bucket. — Correct
- Switch the application to SSE-C with keys it manages.
- Change the bucket's default encryption to SSE-S3.
- Create a second KMS key and alternate between the two.
Correct answer
Enable S3 Bucket Keys for SSE-KMS on the bucket.
Explanation
Bucket Keys create a short-lived bucket-level key, which greatly reduces calls to KMS while keeping the same customer managed key. SSE-S3 and SSE-C stop using the required key. A second key changes key management and doubles cost.
Question 7
A worker application on Amazon EC2 polls an SQS queue in a tight loop. Most ReceiveMessage calls return no messages, and SQS request costs are higher than expected. What is the MOST cost-effective way to reduce empty responses?
- Set ReceiveMessageWaitTimeSeconds on the queue to 20 seconds. — Correct
- Set the queue's VisibilityTimeout to 12 hours.
- Replace the queue with an SNS topic that the worker subscribes to.
- Set MaxNumberOfMessages to 10 and poll twice as often.
Correct answer
Set ReceiveMessageWaitTimeSeconds on the queue to 20 seconds.
Explanation
Long polling waits up to 20 seconds for messages, which removes most empty responses and reduces request count. Visibility timeout affects in-flight messages, not empty receives. Polling more often increases cost. SNS pushes to endpoints and would require redesign of the worker.
Question 8
A Lambda function's logs no longer appear in CloudWatch Logs after a security review changed its execution role. The function still runs successfully. What is the MOST likely cause?
- The execution role no longer allows logs:CreateLogStream and logs:PutLogEvents on the function's log group. — Correct
- The function's reserved concurrency is set too low, so Lambda drops log events during busy periods.
- The function was moved into a VPC that has no NAT gateway, so the logs cannot be sent to CloudWatch.
- The function's log group retention was set to 1 day, so CloudWatch deletes new log events immediately.
Correct answer
The execution role no longer allows logs:CreateLogStream and logs:PutLogEvents on the function's log group.
Explanation
Lambda writes logs by using the execution role's permissions. Lambda sends logs through the Lambda service, so VPC routing does not affect them. Retention of 1 day still keeps events for a day. Concurrency does not drop logs.
Question 9
A team needs to know within minutes when a public API endpoint stops responding or a login flow breaks, even when no users are active. Which solution meets this requirement?
- Enable X-Ray tracing on the API and alert when the service map shows errors on the endpoint.
- Enable CloudWatch RUM on the web application and alert on JavaScript errors from user sessions.
- Create a CloudWatch alarm on the API Gateway 5XXError metric for the stage with a 1-minute period and an SNS action.
- Create CloudWatch Synthetics canaries that run scripts against the endpoint and the login flow on a schedule. — Correct
Correct answer
Create CloudWatch Synthetics canaries that run scripts against the endpoint and the login flow on a schedule.
Explanation
Canaries test endpoints and user flows on a schedule even without real traffic. 5XX metrics, X-Ray traces, and RUM depend on real requests, so they show nothing when users are idle.
Question 10
A Lambda function uses Amazon SES to send order confirmations. In testing, emails to the team's addresses arrive, but emails to real customers fail with a message saying that the address is not verified. What should the developer do?
- Verify the customers' email domains in SES before sending each order confirmation.
- Add the ses:SendEmail permission for all recipient addresses to the function's execution role.
- Move the function into a VPC with an interface endpoint for SES so that emails can be delivered.
- Request production access for SES in the Region to move the account out of the SES sandbox. — Correct
Correct answer
Request production access for SES in the Region to move the account out of the SES sandbox.
Explanation
In the sandbox, SES sends only to verified addresses. Production access removes that restriction. IAM permissions do not control recipients. A VPC endpoint does not change sandbox rules. You cannot verify customers' domains.