Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

AWS Lambda and Serverless Scenario Interview Questions: SAM, Aliases, Powertools and Real Designs (50 Questions)

This page has 50 serverless interview questions with full answers, focused on real projects: how you package, release, observe and design Lambda-based systems. Basic Lambda questions are in Set 1, and the deep-dive page in this set covers concurrency, cold starts and triggers. Here we focus on the work around them.

1. An everyday example: a cloud kitchen

Why do serverless scenario questions matter?

Teams love serverless because there are no servers to patch. But real systems still need safe releases, good logs, retries that do not double-charge customers, and designs that handle spikes. Interviewers test whether you can build that, not just write a handler function.

Think of a cloud kitchen that only cooks when an order comes in. Each order (event) goes to a cook (function). The kitchen hires more cooks when orders pile up and sends them home when it is quiet. The manager (Step Functions) handles orders that need several cooks in order, and the order board (SQS or EventBridge) keeps orders safe while cooks are busy.

How to use this page

  • Build a small app with AWS SAM: an API, a function, a queue and a table.
  • Deploy a new version with a canary release and watch it shift traffic.
  • All account IDs and names here are examples, such as 111122223333.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. What is AWS SAM, and what does a minimal SAM template look like? Fresher

AWS SAM (Serverless Application Model) is a short way to write CloudFormation for serverless apps. A transform line turns SAM resources into full CloudFormation.

cat template.yaml

Output:

Transform: AWS::Serverless-2016-10-31
Resources:
  HelloFn:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: python3.12
      Handler: app.handler
      CodeUri: src/
      Events:
        Api:
          Type: HttpApi
          Properties: {Path: /hello, Method: get}

One function with an HTTP API route. SAM creates the function, role, API and permissions for you.

Q2. What do sam build and sam deploy --guided do? Fresher
  • sam build prepares the code: installs dependencies for the right runtime and puts everything in .aws-sam/build.
  • sam deploy --guided asks for a stack name, Region and options the first time, saves them in samconfig.toml, packages the code to S3, and deploys the CloudFormation stack.
sam deploy --guided

Output:

Stack name [sam-app]: orders-api
AWS Region [ap-south-1]:
Successfully created/updated stack - orders-api in ap-south-1

The app is deployed as a normal CloudFormation stack, so you can see every resource and event in CloudFormation.

Q3. How do you delete old Lambda versions safely when a function has hundreds of them? Fresher

Each published version keeps its code, and all versions count toward the Regional code storage quota. Old versions pile up with every deploy.

List versions:

aws lambda list-versions-by-function --function-name orders --query "Versions[].Version" --output text

Output:

$LATEST  1  2  3  ...  41  42

Safe clean-up:

  • Find versions that any alias points to (list-aliases) and never delete those.
  • Keep the last few versions for quick rollback.
  • Delete the rest with aws lambda delete-function --function-name orders --qualifier 12.

Automate this in the pipeline or with a scheduled job.

Q4. How do you publish a version and point the prod alias to it from the CLI? Fresher
aws lambda publish-version --function-name orders --description "fix tax rounding"

Output:

{"Version": "8", "FunctionArn": "arn:aws:lambda:ap-south-1:111122223333:function:orders:8"}
aws lambda update-alias --function-name orders --name prod --function-version 8

version 8 is now frozen, and the prod alias sends all traffic to it. To roll back, point prod to version 7 again.

Q5. What is a Lambda function URL? Fresher

A function URL is a built-in HTTPS endpoint for one function, like https://abc123.lambda-url.ap-south-1.on.aws/.

  • Auth type can be AWS_IAM (callers sign requests) or NONE (public; your code must check access).
  • Good for simple webhooks or internal tools.
  • It does not have API Gateway features such as usage plans, request validation, custom authorizers or caching.
aws lambda create-function-url-config --function-name webhook --auth-type AWS_IAM

Use API Gateway when you need those features or a full API with many routes.

Q6. Can Lambda run a container image, and why would you use one? Fresher

Yes. You can package a function as a container image (stored in Amazon ECR) instead of a zip file.

Why:

  • Large dependencies: images can be much bigger than zip packages (up to 10 GB).
  • Teams already using Docker tools and scanning.
  • Custom runtimes or system libraries.

The image must implement the Lambda Runtime API; AWS base images do this for you. It still runs as a normal Lambda function with the same limits on time and memory.

Q7. Where should you store configuration such as a table name for a Lambda function? Fresher
  • Environment variables for non-secret settings, such as TABLE_NAME=orders. Set them in SAM or CloudFormation so each stage has its own values.
  • Systems Manager Parameter Store for shared settings that several functions use.
  • Secrets Manager for passwords and API keys.

Read secrets at runtime and cache them, for example with the AWS Parameters and Secrets Lambda Extension or Powertools parameters utility. Do not put secrets in plain environment variables, code or Git.

Q8. What is AWS Lambda Powertools? Fresher

Powertools for AWS Lambda is an open-source library from AWS (for Python, TypeScript, Java and .NET) that adds best practices to functions:

  • Logger: structured JSON logs with request IDs.
  • Metrics: custom CloudWatch metrics with the Embedded Metric Format, without extra API calls.
  • Tracer: X-Ray tracing helpers.
  • Idempotency: stops duplicate processing using a DynamoDB table.
  • Batch processing, parameters, event parsing and validation.

It saves time and makes all functions in a team behave the same way.

Q9. How do you allow another AWS account to invoke your Lambda function? Fresher

Add a statement to the function's resource-based policy:

aws lambda add-permission --function-name orders --statement-id partner-invoke --action lambda:InvokeFunction --principal 444455556666

Check:

aws lambda get-policy --function-name orders --query Policy --output text

Output:

{"Statement":[{"Sid":"partner-invoke","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::444455556666:root"},"Action":"lambda:InvokeFunction",...}]}

account 444455556666 may invoke the function, but its users also need an IAM policy in their own account that allows lambda:InvokeFunction on your function ARN. Grant on an alias ARN to control which version they call.

Q10. What is the /tmp folder in Lambda, and is it safe to keep data there? Fresher

/tmp is ephemeral storage inside the execution environment. It is 512 MB by default, and you can set it higher (up to 10 GB).

  • Data in /tmp can survive between invocations on the same warm environment, so it is useful as a cache.
  • It is not shared between environments and disappears when the environment is recycled.
  • Never rely on it for important data. Store results in S3, DynamoDB or EFS.

Clean up large temporary files at the end of each run so later invocations do not run out of space.

Q11. How do you see the logs of a Lambda function from the terminal? Fresher
aws logs tail /aws/lambda/orders --follow --since 10m

Output:

2026-11-20T10:15:02 START RequestId: 1a2b3c4d Version: 8
2026-11-20T10:15:02 {"level":"ERROR","message":"tax service timeout","order_id":"ord-1001"}
2026-11-20T10:15:03 REPORT RequestId: 1a2b3c4d Duration: 1503.2 ms Billed Duration: 1504 ms Memory Size: 512 MB Max Memory Used: 141 MB

version 8 handled the request, the tax call timed out, and the function used 141 MB of its 512 MB.

With SAM you can also run sam logs -n OrdersFunction --stack-name orders-api --tail.

Q12. What does the REPORT line in Lambda logs tell you? Fresher

Every invocation ends with a REPORT line that shows:

  • Duration and Billed Duration (time the code ran).
  • Memory Size (configured) and Max Memory Used (peak).
  • Init Duration, only when a new environment was created (a cold start).

Use it to right-size memory: if Max Memory Used is always far below the setting and duration is fine, you may lower memory; if duration is long and CPU bound, more memory also gives more CPU.

Q13. What is EventBridge Scheduler, and how is it different from a cron rule on EC2? Fresher

EventBridge Scheduler is a managed service that runs one-time or recurring schedules and calls a target, such as a Lambda function, Step Functions or many AWS APIs directly.

Compared with cron on an EC2 server:

  • No server to keep alive or patch.
  • Time zone support and flexible time windows.
  • Built-in retries and a dead-letter queue.
  • Can handle very many schedules, such as one per customer reminder.
aws scheduler create-schedule --name nightly-report --schedule-expression "cron(0 2 * * ? *)" --schedule-expression-timezone Asia/Kolkata --flexible-time-window Mode=OFF --target '{"Arn":"arn:aws:lambda:ap-south-1:111122223333:function:report","RoleArn":"arn:aws:iam::111122223333:role/scheduler-invoke"}'
Q14. Which runtimes can Lambda use, and what happens when a runtime is deprecated? Fresher

Lambda supports managed runtimes for Node.js, Python, Java, .NET and Ruby, and OS-only runtimes (for Go, Rust and custom code) on Amazon Linux.

When a runtime version reaches deprecation, AWS stops applying security patches. After later dates you can no longer create, and then update, functions on it. Existing functions keep running, but you should upgrade.

Find functions on old runtimes:

aws lambda list-functions --query "Functions[?Runtime=='python3.8'].FunctionName" --output text

Output:

legacy-export  old-report

Two functions need an upgrade. Check the current runtime deprecation dates in the Lambda documentation.

Q15. What does "serverless" really mean if there are still servers? Fresher

There are servers, but AWS runs them. Serverless means:

  • No servers for you to provision, patch or size.
  • It scales automatically with demand, including to zero for many services.
  • You pay for use (requests, duration, data), not for idle machines, in most serverless services.
  • High availability is built in across Availability Zones.

Examples: Lambda, API Gateway, DynamoDB, SQS, SNS, EventBridge, Step Functions, S3 and Fargate (serverless containers).

Q16. How do you update a function's code from a CI pipeline with the CLI and wait until it is ready? Fresher
aws lambda update-function-code --function-name orders --zip-file fileb://build/orders.zip --publish

Output:

{"Version": "9", "LastUpdateStatus": "InProgress"}
aws lambda wait function-updated-v2 --function-name orders
aws lambda get-function-configuration --function-name orders --query "[LastUpdateStatus,State]"

Output:

["Successful", "Active"]

The update finished and the function is active.

Wait before calling another update, because a second change while the first is in progress fails with ResourceConflictException.

Q17. What is a Lambda extension? Fresher

An extension is a companion process that runs inside the Lambda execution environment, next to your function. It is usually added as a layer.

Uses:

  • Monitoring and observability agents (sending telemetry to a monitoring tool).
  • Caching secrets and parameters (the AWS Parameters and Secrets Lambda Extension).
  • Security agents.

Extensions can run code at start, on each invoke, and at shutdown. They share the function's memory and CPU, and they can add to cold start time, so measure their impact.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q18. How do you do a canary release of a Lambda function with SAM? Mid level

Use AutoPublishAlias and DeploymentPreference. SAM uses CodeDeploy to shift traffic.

cat template.yaml (part)

Output:

OrdersFn:
  Type: AWS::Serverless::Function
  Properties:
    AutoPublishAlias: live
    DeploymentPreference:
      Type: Canary10Percent5Minutes
      Alarms: [!Ref OrdersErrorsAlarm]

Each deploy publishes a new version. 10% of traffic goes to it for 5 minutes. If the alarm fires, CodeDeploy rolls back automatically; otherwise all traffic moves.

You can also add PreTraffic and PostTraffic hook functions to run tests.

Q19. How do weighted aliases work, and how would you check the current split? Mid level

An alias can send a percentage of traffic to a second version.

aws lambda update-alias --function-name orders --name live --function-version 8 --routing-config 'AdditionalVersionWeights={"9"=0.1}'
aws lambda get-alias --function-name orders --name live --query "[FunctionVersion,RoutingConfig]"

Output:

["8", {"AdditionalVersionWeights": {"9": 0.1}}]

90% of calls run version 8 and 10% run version 9.

In logs, the START line shows which version handled each request, so you can compare errors per version.

Q20. What is code signing for Lambda, and why would a bank turn it on? Mid level

Code signing makes sure only trusted, unchanged code is deployed to a function.

  • Developers sign the deployment package with AWS Signer.
  • A code signing configuration on the function lists the allowed signing profiles.
  • Lambda checks the signature at deploy time and can block (Enforce) or only warn (Warn) for unsigned or changed code.

Why a bank wants it: it proves that code came from the approved pipeline and was not changed on the way, which helps with audits and supply-chain security.

Q21. How does the Powertools idempotency utility prevent double processing? Mid level
  • You choose an idempotency key from the event, such as order_id or a payment request ID.
  • Before running the handler, Powertools writes the key to a DynamoDB table with the status "in progress".
  • If the same key arrives again, it returns the saved result instead of running the logic again.
  • Records expire after a set time (TTL).

This protects against retries from SQS, EventBridge, async invokes and client retries, which are all "at least once". Use it for payments, emails and anything with side effects.

Q22. What is Lambda response streaming, and when do you use it? Mid level

Response streaming lets a function send the response in parts as soon as data is ready, instead of waiting for the full response.

Benefits:

  • Lower time to first byte for users, for example for server-side rendered pages or AI text generation.
  • Larger responses than the normal synchronous payload limit.

It works through function URLs (and supported integrations), and is available for certain runtimes, such as Node.js, natively. Check the current documentation for supported runtimes and integrations.

Q23. What are Lambda runtime management controls, and when would you change them? Mid level

Lambda patches managed runtimes (for example the Python 3.12 runtime) with new minor versions and security fixes. Runtime management controls decide when your function picks up these updates:

  • Auto (default): the function moves to new runtime versions automatically.
  • Function update: the runtime updates only when you deploy or update the function.
  • Manual: you pin a specific runtime version ARN, for example to roll back if a runtime update breaks something.

Use Manual only as a short-term fix, because pinned runtimes miss security patches.

Q24. What is EventBridge Pipes, and how is it different from writing a Lambda function to move events? Mid level

EventBridge Pipes connects one source (such as SQS, DynamoDB Streams, Kinesis or Amazon MQ) to one target (such as Step Functions, EventBridge bus, API destinations or Lambda), with optional filtering and enrichment in between.

Instead of writing "glue" Lambda code that reads, filters and forwards events, you configure it:

  • Source: an orders queue.
  • Filter: only status = PAID.
  • Enrichment: call an API or Lambda to add customer data.
  • Target: start a Step Functions workflow.

Less code means fewer bugs and less to maintain.

Q25. How do you redrive a failed Step Functions execution instead of starting again from the beginning? Mid level

For Standard workflows, you can redrive a failed, aborted or timed-out execution. It continues from the failed state and reuses the results of the steps that already succeeded.

aws stepfunctions redrive-execution --execution-arn arn:aws:states:ap-south-1:111122223333:execution:order-flow:ord-1001

Output:

{"redriveDate": "2026-11-20T10:30:00+05:30"}

The same execution resumes from the failed step, so a payment that already succeeded is not charged again.

Fix the root cause first (for example a permission or a bad downstream service), then redrive. Redrive is only possible within a limited time after the execution ended.

Q26. How do you call an AWS service from Step Functions without writing a Lambda function? Mid level

Use service integrations. Step Functions can call many AWS APIs directly, such as DynamoDB PutItem, SNS Publish, SQS SendMessage, ECS RunTask and Glue StartJobRun, through optimized integrations and AWS SDK integrations.

Example task state (part):

Output:

"SaveOrder": {"Type": "Task", "Resource": "arn:aws:states:::dynamodb:putItem",
  "Parameters": {"TableName": "orders", "Item": {"pk": {"S.$": "$.orderId"}}}, "Next": "Notify"}

The workflow writes to DynamoDB itself. Fewer Lambda functions means less code, fewer cold starts and lower cost.

Q27. How do you test a single Step Functions state without running the whole workflow? Mid level

Use the TestState API (also in the console as "Test state"). You give it one state definition, an input and a role, and it runs only that state.

aws stepfunctions test-state --definition '{"Type":"Pass","Parameters":{"total.$":"$.price"},"End":true}' --role-arn arn:aws:iam::111122223333:role/sfn-test --input '{"price": 499}'

Output:

{"output": "{\"total\":499}", "status": "SUCCEEDED"}

The state transformed the input as expected.

This is very useful for checking input and output paths, data transformations and error handling, without creating executions.

Q28. How do you process millions of S3 objects with Step Functions Distributed Map? Mid level

Distributed Map reads a large list of items, such as all objects under an S3 prefix or rows in a CSV file, and runs a child workflow for each item or batch, with high parallelism.

Design:

  • Item source: S3 inventory, a prefix listing or a CSV/JSON file.
  • Batching: group items so each child handles many objects.
  • MaxConcurrency: limit parallel runs so downstream services are not overloaded.
  • Tolerated failure percentage, so a few bad files do not fail the whole job.
  • Results written to S3.

This replaces custom fan-out code and gives a clear view of progress and failures.

Q29. What is recursive loop detection in Lambda? Mid level

A recursive loop happens when a function's output triggers the same function again, for example a function that writes to the same SQS queue, SNS topic or S3 bucket that invokes it.

Lambda can detect some of these loops (for supported services such as SQS, SNS and S3) and stop the invocation after a number of repeats, then notify you. You can change this setting per function if a loop is intentional.

Prevention is still your job: use separate input and output buckets or prefixes, and add a guard field to events.

Q30. How do you set log levels and JSON logs for Lambda without changing code everywhere? Mid level

Lambda supports advanced logging controls:

  • Log format: Text or JSON.
  • Application log level (such as DEBUG, INFO, WARN, ERROR) and system log level, set in the function configuration.
  • A custom log group, so several functions can share one or so you can set retention centrally.
aws lambda update-function-configuration --function-name orders --logging-config LogFormat=JSON,ApplicationLogLevel=WARN

In production only warnings and errors are kept, which reduces noise and CloudWatch Logs cost. Turn on DEBUG temporarily while investigating.

Q31. How do you test a Lambda change before production in a team pipeline? Mid level
  • Unit tests for business logic, with AWS calls mocked.
  • Integration tests in a real dev or test stack deployed by SAM or CDK, calling the real API and checking the database or queue.
  • Contract tests for event shapes, using sample events (SAM can generate them with sam local generate-event).
  • Canary release in production with alarms and automatic rollback.

Keep each developer's or each branch's stack separate (for example with a stack name per branch) and delete it after testing.

Q32. An API Gateway + Lambda endpoint returns 502 "Malformed Lambda proxy response". What is wrong? Mid level

With Lambda proxy integration, the function must return a specific JSON shape:

Output:

{"statusCode": 200, "headers": {"Content-Type": "application/json"}, "body": "{\"ok\": true}"}

Common mistakes:

  • Returning a plain object or string instead of this shape.
  • body is an object, not a string (it must be a JSON string).
  • An unhandled exception, so nothing valid is returned.

Fix the return value, and add error handling that always returns a valid response with a proper status code. Check the function logs for the real error.

Q33. How would you structure a serverless project with many functions so it stays maintainable? Mid level
  • Group functions by business domain (orders, payments, users), each with its own stack or service.
  • Keep handlers thin; put business logic in shared, tested modules.
  • Share common code through internal packages or layers, but avoid one huge shared layer that couples everything.
  • One IAM role per function with least privilege.
  • Standard Powertools logging and metrics in all functions.
  • Communicate between domains through events (EventBridge) rather than direct function calls.
  • Infrastructure as code for everything, with one pipeline per service.
Q46. How do you keep separate dev, test and prod settings for a SAM application? Mid level
  • Use template Parameters (such as Stage, LogLevel, TableName) and reference them in resources.
  • Store per-environment values in samconfig.toml sections.
cat samconfig.toml (part)

Output:

[prod.deploy.parameters]
stack_name = "orders-prod"
parameter_overrides = "Stage=prod LogLevel=WARN"
sam deploy --config-env prod

The same template deploys a separate prod stack with prod values.

Best practice: deploy each environment into its own AWS account, and let the pipeline, not people, run the prod deploy.

Q47. A Lambda zip package is 180 MB unzipped and deployments fail. How do you shrink it? Mid level
  • Remove dev dependencies, tests and docs from the package; build with production flags (npm ci --omit=dev, pip without test extras).
  • Do not bundle the AWS SDK if the runtime already includes a suitable version (check your runtime; pin your own when you need a specific version).
  • Use a bundler (esbuild for Node.js) with tree shaking.
  • Move big shared libraries to a layer, or switch to a container image when dependencies are very large.
  • Split one huge function into smaller functions by job.

Smaller packages also start faster.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q34. Design a serverless image thumbnail pipeline for user uploads. What do you watch out for? Senior

Design:

  • Users upload to an uploads bucket with presigned URLs.
  • An S3 event notification (or EventBridge) sends the event to an SQS queue.
  • A Lambda function reads the queue, creates thumbnails and writes them to a separate thumbnails bucket.
  • A record in DynamoDB tracks status.

Watch out for:

  • Infinite loops: never write output to the same bucket and prefix that triggers the function.
  • Large or bad files: limit size at upload, handle errors, use a DLQ.
  • Memory and /tmp size for image processing.
  • Idempotency, because events can be delivered more than once.
  • Serve thumbnails through CloudFront.
Q35. A user uploads a 1 GB CSV file that must be imported into a database. Design it serverless. Senior
  • The browser uploads directly to S3 with multipart presigned URLs, so the API never handles the big file.
  • The S3 upload event starts a Step Functions workflow.
  • A Distributed Map reads the CSV in batches of rows and runs child workflows or Lambda functions in parallel, with MaxConcurrency matched to what the database can handle.
  • Bad rows go to an errors file in S3; a tolerated failure percentage stops the job only if too many rows fail.
  • The workflow updates the import status in DynamoDB, and the user sees progress.
  • At the end, send a notification with a summary and the errors file link.
Q36. How do you design a saga for an order that spans payment, stock and shipping services? Senior

Use Step Functions to orchestrate the steps:

  • Reserve stock, then charge payment, then create the shipment.
  • Each step has a compensating action: release stock, refund payment, cancel shipment.
  • On failure at any step, the workflow runs the compensations for the steps already done (using Catch).
  • Each step is idempotent and uses the order ID as the key.
  • Store the order status in DynamoDB and publish events for other systems.

This gives you consistency across services without a single distributed transaction, plus a visible history of each order.

Q37. A Lambda-based API has occasional duplicate charges after client timeouts. How do you fix it? Senior

What happens: the client times out and retries, but the first request actually completed, so the payment runs twice.

Fix:

  • Require an idempotency key from the client (for example a header with a unique request ID).
  • Store the key with the result in DynamoDB using a conditional write; on repeats, return the saved result.
  • Use the payment provider's own idempotency key feature too.
  • Make sure the API timeout, function timeout and client timeout are set in a sensible order (client longest).
  • Alert on duplicate key hits to see how often it happens.
Q38. How would you migrate 40 cron jobs from an old EC2 server to serverless? Senior
  • Inventory each job: schedule, run time, dependencies, data it touches and who owns it.
  • Scheduled event jobs that comfortably fit the Lambda timeout and resource budget: EventBridge Scheduler plus Lambda. An on-demand Event Function supports up to 30 minutes.
  • Long or heavy jobs: Scheduler plus ECS Fargate tasks or AWS Batch.
  • Multi-step jobs: Step Functions.
  • Move secrets to Secrets Manager and file outputs to S3.
  • Add alarms on failures and on missed runs, plus logs for every run.
  • Migrate a few jobs at a time, run old and new in parallel where safe, then turn off the old cron entries.

Finally, shut down the EC2 server.

Q39. How do you make a serverless application multi-Region active-active? Senior
  • Deploy the same stacks in two Regions with the pipeline.
  • Data: DynamoDB global tables for multi-Region writes, or S3 replication for objects.
  • Routing: Route 53 latency or failover routing to Regional API endpoints, with health checks.
  • Events: replicate important events across Regions (EventBridge global endpoints or cross-Region rules).
  • Design for conflicts: last writer wins in global tables, so avoid two Regions updating the same item at once, or partition users by home Region.
  • Test failover regularly.

Do it only when the business needs it, because cost and complexity go up a lot.

Q40. Your Step Functions workflow costs are high and executions are slow. How do you optimise them? Senior
  • Count state transitions: Standard workflows are billed per transition, so remove unneeded Pass states and combine small steps.
  • Use Express workflows for high-volume, short sub-workflows (nested inside a Standard parent if you need audit history at the top).
  • Replace Lambda "glue" functions with direct service integrations.
  • Run independent steps in Parallel or Map states.
  • Avoid polling loops with Wait states; use callbacks or .sync integrations.
  • Reduce payload size by storing big data in S3 and passing references.
Q41. How do you observe a request that flows through API Gateway, Lambda, SQS and another Lambda? Senior
  • Turn on X-Ray (or OpenTelemetry) tracing on API Gateway and the functions to see the end-to-end path and where time is spent.
  • Pass a correlation ID (such as the request ID) through every message and log it in every function with structured logs.
  • Use CloudWatch Logs Insights to search all log groups for that ID.
  • Publish business metrics (orders created, failed) with Powertools metrics.
  • Alarm on error rate, latency, queue age and DLQ depth.

This lets you answer "what happened to order ord-1001" in minutes.

Q42. How do you secure a public webhook receiver built with Lambda? Senior
  • Verify the sender: check the HMAC signature header with a shared secret stored in Secrets Manager, and reject old timestamps to stop replays.
  • Use API Gateway with WAF for rate limiting and IP rules if the sender publishes IP ranges.
  • Validate the payload schema and size.
  • Respond quickly (put the event on a queue and return 200), then process asynchronously.
  • Make processing idempotent using the sender's event ID.
  • Least-privilege role for the function and no secrets in logs.
Q43. A bug dropped order events for two hours. How can EventBridge archive and replay help? Senior
  • An archive stores events that pass through an event bus (all events or those matching a pattern) for a retention period you choose.
  • Replay sends archived events from a chosen time window back to the bus, so rules and targets process them again.

Recovery steps:

  • Fix the bug and deploy.
  • Start a replay for the two-hour window to the affected rule.
  • Make consumers idempotent first, because some events may have been processed already.

Replayed events are marked with a replay name, so consumers can detect them if needed. Set up the archive before you need it.

Q44. How would you handle a sudden traffic spike of 50 times normal on a serverless order system? Senior
  • API layer: API Gateway throttling and WAF rate rules protect against abuse; set limits per client with usage plans.
  • Buffer writes: accept orders into SQS and return "received", so the backend processes at a safe rate.
  • Check account limits early: Lambda concurrency, API Gateway, DynamoDB capacity mode (on-demand handles spikes better than tight provisioned capacity).
  • Protect downstream databases with concurrency limits on consumers.
  • Load test at the expected spike beforehand.
  • Alarms on throttles, queue age and errors, with a runbook.
Q45. How do you roll back a bad serverless release that changed both code and a DynamoDB table? Senior
  • Code: move the Lambda alias back to the previous version (instant), or let CodeDeploy roll back on alarms.
  • Infrastructure: CloudFormation rolls back failed updates automatically; for a successful but bad update, redeploy the previous template version.
  • Data: table changes such as new attributes are usually backward compatible; avoid destructive changes. Make schema changes in two steps (expand, then contract) so old code still works.
  • If data was corrupted, use point-in-time recovery to restore to a new table and repair.

Design releases so code and data changes can be rolled back separately.

Q48. Design a reminder system that sends one message to each of 1 million users at their own chosen time. Senior
  • Use EventBridge Scheduler one-time schedules: create a schedule per reminder with the user's time and time zone, and a target such as an SQS queue or Lambda function. Set it to delete after completion.
  • The target puts the reminder into a queue; a worker sends it through SNS, SES or the push provider.
  • Use flexible time windows to spread load when many reminders share the same minute.
  • Scheduler retries with a DLQ cover temporary failures.
  • Check Scheduler quotas for the number of schedules and the creation rate, and request increases early.

This avoids running a big cron server that scans a table every minute.

Q49. In a multi-tenant SaaS on Lambda, one big tenant's spike causes errors for everyone. How do you isolate tenants? Senior
  • Measure per tenant: add tenant ID to logs and metrics.
  • Per-tenant throttling at the API with usage plans or a rate limit in the authorizer.
  • Separate queues or message groups per tenant tier, so one tenant's backlog does not block others (SQS fair queues can help reduce noisy-neighbour impact; check current features).
  • Reserved concurrency for critical shared functions, and separate functions or stacks for premium tenants.
  • DynamoDB keys designed so one tenant does not create a hot partition.
  • Clear limits in the contract and alerts when a tenant nears them.
Q50. How do you enforce standards such as tracing, log retention and supported runtimes across 300 functions in many accounts? Senior
  • Prevent at build time: shared SAM or CDK constructs that set tracing, log retention, JSON logs, alarms and tags by default.
  • Check at deploy time: policy-as-code in the pipeline (cfn-guard or cfn-lint rules).
  • Detect after deploy: AWS Config rules (for example for runtimes and tracing), Security Hub controls, and a daily report of functions on deprecated runtimes.
  • Auto-fix where safe: an EventBridge rule on CreateLogGroup that sets retention.
  • Guardrails: SCPs that block deploys outside the pipeline role.

Share a dashboard so teams see their own gaps.

5. Frequently asked questions

SAM, CDK, Serverless Framework or Terraform?

All can deploy Lambda. SAM is simple and close to CloudFormation. CDK suits teams who like real programming languages. Terraform suits companies that already use it for everything. Pick what your team uses and explain why.

When is serverless the wrong choice?

Very long jobs, steady high load where servers are cheaper, very low-latency needs that cannot tolerate occasional cold starts, or software that needs special OS access.

What is the best way to practise?

Build one real project end to end: an order API with validation, a queue, a worker, a table, alarms and a canary deployment.

6. Quick revision

  • Versions are fixed snapshots; aliases are pointers you can move and split traffic with.
  • SAM AutoPublishAlias plus DeploymentPreference gives canary or linear releases with alarms.
  • Return batchItemFailures for SQS so only failed messages are retried.
  • Use Powertools for structured logs, metrics, tracing and idempotency.
  • Step Functions Standard is for long, auditable workflows; Express is for high-volume, short ones.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.