01 / 10

How do you define and configure Lambda functions?

Difficulty: 4/10
function definition, runtime configuration, deployment

Defining and configuring AWS Lambda functions involves creating the function code, setting up triggers, allocating resources, and managing permissions. This can be done through the AWS Management Console, AWS CLI, AWS SDKs, or Infrastructure as Code tools like AWS CloudFormation or Terraform.

Key Configuration Options for Lambda Functions
  1. 1

    Function Name – Unique identifier for the function.

  2. 2

    Runtime – The language runtime (Node.js, Python, Java, etc.).

  3. 3

    Handler – Entry point to the function (e.g., index.handler).

  4. 4

    Execution Role – IAM role that grants the function permissions.

  5. 5

    Memory Size – Allocated memory (128 MB to 10 GB) which also affects CPU power.

  6. 6

    Timeout – Maximum execution time (up to 15 minutes).

  7. 7

    Environment Variables – Key-value pairs accessible within the code.

  8. 8

    VPC Settings – Specify VPC, subnets, and security groups for private network access.

  9. 9

    Layers – Reusable code components or libraries.

  10. 10

    Triggers – Services/events that invoke the Lambda function (e.g., S3, API Gateway, EventBridge).

Sample AWS CLI Command to Create a Lambda Function

Scenario Questions

0-2 years experience

  1. 1We need a simple Lambda that processes S3 upload events and writes a log entry. Walk me through the steps you'd take to define and configure that function using the AWS console.
  2. 2If you set the timeout to 30 seconds but your code sometimes takes 45 seconds, what will happen and how would you fix it?

2-5 years experience

  1. 1Your team added a new environment variable to a Lambda that reads from a secret in Parameter Store, but the function now fails with an AccessDenied error. How would you troubleshoot and resolve the configuration issue?
  2. 2We want to reduce cold start latency for a high‑traffic API Gateway integration. Which Lambda configuration settings would you adjust and why?
  3. 3During a deployment, the function's package size exceeded the limit and the deployment failed. Explain how you would restructure the function and its dependencies to stay within limits.

5-8 years experience

  1. 1Design a strategy for handling unpredictable traffic spikes to a Lambda that processes video transcoding jobs, considering concurrency limits, provisioned concurrency, and downstream service throttling.
  2. 2Explain the trade‑offs between using Lambda layers versus bundling dependencies directly in the deployment package, especially regarding versioning and cold start performance.
  3. 3Our monitoring shows occasional timeouts due to long initialization of a large library. How would you refactor the function configuration or code to mitigate this at scale?

8+ years experience

  1. 1We are migrating a legacy monolith to a serverless architecture across multiple AWS accounts. How would you standardize Lambda definition and configuration to ensure security, compliance, and consistent CI/CD pipelines?
  2. 2Discuss how you would implement organization‑wide policies for Lambda memory, timeout, and concurrency settings, balancing cost, performance, and developer autonomy.
  3. 3When integrating Lambda functions with multiple VPCs and private subnets, what architectural considerations and configuration patterns would you employ to minimize latency and manage cross‑account networking?

Follow-up Questions

  • What metrics would you monitor to know the function is healthy?
  • How would you handle a sudden traffic spike that exceeds your concurrency limits?
  • Can you walk me through rolling back a Lambda deployment that introduced a regression?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.