AWS Lambda Interview Questions
Basic AWS Lambda Questions
- What is AWS Lambda?
AWS Lambda is a serverless compute service that automatically runs code in response to events and scales as needed. - What are the main features of AWS Lambda?
- Event-driven execution
- Automatic scaling
- Supports multiple programming languages
- Integrated with AWS services
- Pay-per-use pricing
- Which programming languages does AWS Lambda support?
- Python
- Node.js
- Java
- Go
- C# (.NET Core)
- Ruby
- PowerShell
- How does AWS Lambda work?
It listens for triggers (S3, API Gateway, DynamoDB, etc.), executes code in a stateless container, and scales automatically. - What is the maximum execution time for a Lambda function?
15 minutes. - How does Lambda pricing work?
- Free tier: 1 million requests & 400,000 GB-seconds/month
- Pricing is based on: Execution time (per millisecond) and memory usage
- How do you deploy a Lambda function?
- Using the AWS Management Console
- AWS CLI
- AWS SDKs
- Infrastructure as Code (IaC) tools like CloudFormation, Terraform, or AWS SAM
- What are the benefits of using AWS Lambda?
- No server management
- Automatic scaling
- Cost efficiency (pay per execution)
- Seamless integration with AWS services
- Can AWS Lambda run continuously?
No, it is designed for short-lived executions. However, you can chain executions using Step Functions. - What are cold starts in AWS Lambda?
A delay when an idle Lambda function is invoked for the first time due to container initialization.
Event Sources & Triggers
- What are the different event sources for AWS Lambda?
- AWS Services (S3, DynamoDB, API Gateway, SNS, SQS, Kinesis, CloudWatch)
- Custom events (invoked from other AWS services or external APIs)
- How do you trigger a Lambda function?
- Manually using AWS CLI, SDKs, or Console
- Automatically via AWS event sources (S3, DynamoDB, API Gateway, etc.)
- How does AWS Lambda integrate with Amazon S3?
A Lambda function can be triggered when an object is added, modified, or deleted in an S3 bucket. - What is an event in AWS Lambda?
A JSON object that contains data about the trigger that invoked the function. - How does AWS Lambda work with API Gateway?
API Gateway acts as an HTTP endpoint, triggering Lambda functions to handle API requests. - What is an asynchronous invocation in AWS Lambda?
Lambda queues the event and processes it later (e.g., SNS, S3, EventBridge). - What happens if an asynchronous invocation fails?
AWS Lambda automatically retries twice. You can also configure Dead Letter Queues (DLQs) for error handling. - How does AWS Lambda process messages from SQS?
Lambda polls the SQS queue and processes messages in batches. - Can AWS Lambda subscribe to SNS topics?
Yes, SNS can trigger Lambda functions asynchronously. - How does AWS Lambda work with DynamoDB Streams?
Lambda processes real-time changes in DynamoDB tables.
Lambda Execution & Performance
- What is the default memory allocation for a Lambda function?
Between 128 MB and 10,240 MB (10 GB). - How does AWS Lambda scale?
- Scales automatically by running multiple instances in parallel
- No pre-provisioning required
- What is AWS Lambda concurrency?
The number of function instances that can run simultaneously. - What is the maximum Lambda concurrency limit?
- Default: 1,000 concurrent executions per AWS account
- Can be increased by request
- What is provisioned concurrency in AWS Lambda?
Keeps functions warm to reduce cold starts. - How can you optimize AWS Lambda performance?
- Use provisioned concurrency
- Reduce function size
- Choose the right memory allocation
- Optimize dependencies
- What is Lambda execution context?
The environment where the function runs, including dependencies and temporary storage. - What is the maximum package size for a Lambda function?
- 50 MB for direct upload
- 250 MB if deployed using S3
- Can Lambda functions use temporary storage?
Yes,/tmpprovides 512 MB of temporary disk storage. - How do you monitor AWS Lambda performance?
Using AWS CloudWatch Logs & Metrics.
Security & Access Control
- How do you secure AWS Lambda?
- Use IAM roles and policies
- Enable VPC for private network access
- Use environment variables encryption
- What is an IAM role in AWS Lambda?
It grants permissions for the function to access AWS resources. - Can AWS Lambda run inside a VPC?
Yes, but you need to configure subnets and security groups. - How do you encrypt environment variables in Lambda?
Using AWS KMS (Key Management Service). - How can you restrict access to Lambda functions?
- Use IAM permissions
- Restrict API Gateway access with CORS or authentication
- What is the AWS Lambda execution role?
The IAM role that grants Lambda permissions to execute actions. - What is AWS Lambda function URL?
A dedicated HTTPS endpoint to invoke a Lambda function. - How can you prevent unauthorized access to AWS Lambda?
- Use IAM roles & permissions
- Implement API Gateway authentication
- Enable VPC security
- How does Lambda handle failures?
- Sync calls: Returns errors to the caller
- Async calls: Retries automatically
- DLQ (Dead Letter Queue) stores failed events
- What is Dead Letter Queue (DLQ) in AWS Lambda?
A queue (SQS or SNS) that stores failed events for later processing.
Advanced AWS Lambda Concepts
- What is AWS Lambda Layers?
A way to share dependencies across multiple functions. - How can you reduce the size of a Lambda package?
- Use Lambda Layers
- Remove unused dependencies
- Use compiled dependencies
- What is AWS Step Functions?
A workflow orchestration service that manages multiple Lambda executions. - How does AWS Lambda integrate with AWS X-Ray?
AWS X-Ray provides distributed tracing for Lambda functions. - Can AWS Lambda call another Lambda function?
Yes, using AWS SDK, Step Functions, or API Gateway. - How do you set up logging for AWS Lambda?
Logs are automatically sent to CloudWatch. - What is Amazon EventBridge?
A serverless event bus that triggers Lambda functions. - How does AWS Lambda integrate with CloudFormation?
CloudFormation can define, deploy, and manage Lambda functions. - What is AWS SAM (Serverless Application Model)?
A framework for deploying serverless applications using YAML. - Can AWS Lambda access on-premise resources?
Yes, by connecting through AWS VPN or Direct Connect.
These 50 AWS Lambda interview questions and answers cover basics, event triggers, execution, security, and advanced concepts. Let me know if you need detailed explanations for any topic! 🚀
