The AWS Lambda Preview is available now

Try AWS Lambda for Free

The AWS Free Tier includes 1 million free requests and up to 3.2 million seconds of compute time per month with AWS Lambda.

View AWS Free Tier Details »

Q: What is AWS Lambda?

AWS Lambda is a compute service that runs your code in response to events and automatically manages the compute resources for you, making it easy to build applications that respond quickly to new information. AWS Lambda starts running your code within milliseconds of an event such as an image upload, in-app activity, website click, or output from a connected device. You can also use AWS Lambda to create new back-end services where compute resources are automatically triggered based on custom requests. With AWS Lambda you pay only for the requests served and the compute time required to run your code. Billing is metered in increments of 100 milliseconds, making it cost-effective and easy to scale automatically from a few requests per day to thousands per second.

Lambda runs your code on high-availability compute infrastructure and performs all the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code and security patch deployment, and code monitoring and logging. All you need to do is supply the code.

Q: What events can trigger an AWS Lambda function?

You can use AWS Lambda to respond to table updates in Amazon DynamoDB, modifications to objects in Amazon S3 buckets, messages arriving in an Amazon Kinesis stream, AWS API call logs created by AWS CloudTrail, and custom events from mobile applications, web applications, or other web services. Here are some sample use cases for AWS Lambda.

Q: When should I use AWS Lambda versus Amazon EC2?

Amazon Web Services offers a set of compute services to meet a range of needs.

Amazon EC2 offers flexibility, with a wide range of instance types and the option to customize the operating system, network and security settings, and the entire software stack, allowing you to easily move existing applications to the cloud. With Amazon EC2 you are responsible for provisioning capacity, monitoring fleet health and performance, and designing for fault tolerance and scalability. AWS Elastic Beanstalk offers an easy-to-use service for deploying and scaling web applications in which you retain ownership and full control over the underlying EC2 instances.

AWS Lambda makes it easy to execute code in response to events, such as changes to Amazon S3 buckets, updates to an Amazon DynamoDB table, or custom events generated by your applications. With Lambda you do not have to provision your own instances; Lambda performs all the operational and administrative activities on your behalf, including capacity provisioning, monitoring fleet health, applying security patches to the underlying compute resources, deploying your code, running a web service front end, and monitoring and logging your code. AWS Lambda provides easy scaling and high availability to your code without additional effort on your part.

Q: What kind of code can run on AWS Lambda?

AWS Lambda offers an easy way to run code in the cloud, from simple activities like compressing files arriving in Amazon S3 to more complex tasks, such as performing facial recognition on uploaded images.

Q: What languages does AWS Lambda support?

At launch AWS Lambda supports code written in Node.js (JavaScript). Your code can include existing Node.js libraries, even native ones.

Q: Can I access the infrastructure that AWS Lambda runs on?

No. AWS Lambda operates the compute infrastructure on your behalf, allowing it to perform health checks, apply security patches, and do other routine maintenance.

Q: What is Lambda’s service availability?

AWS Lambda is designed to provide 99.99% availability for both the service itself and for the functions it operates. There are no maintenance windows or scheduled downtimes.

Q: How does Lambda isolate my code?

Each AWS Lambda function runs in its own isolated environment, with its own resources and file system view. AWS Lambda uses the same techniques as Amazon EC2 to provide security and separation at the infrastructure and execution levels.


Q: What is a Lambda function?

The code you run on AWS Lambda is uploaded as a “Lambda function”. Each function has associated configuration information, such as its name, description, entry point, and resource requirements. The code must be written in a “stateless” style i.e. it should assume there is no affinity to the underlying compute infrastructure. Local file system access, child processes, and similar artifacts may not extend beyond the lifetime of the request, and any persistent state should be stored in Amazon S3, Amazon DynamoDB, or another Internet-available storage service. Lambda functions can include libraries, even native ones.

Q: Will AWS Lambda reuse function instances?

To improve performance, AWS Lambda may choose to retain an instance of your function and reuse it to serve a subsequent request, rather than creating a new copy. Your code should not assume that this will always happen.

Q: What if I need scratch space on disk for my AWS Lambda function?

Each Lambda function receives 500MB of non-persistent disk space in its own /tmp directory.

Q: Why must Lambda functions be stateless?

Keeping functions stateless enables AWS Lambda to rapidly launch as many copies of the function as needed to scale to the rate of incoming events. While AWS Lambda’s programming model is stateless, your code can access stateful data by calling other web services, such as Amazon S3 or Amazon DynamoDB.

Q: Can I use threads and processes in my Lambda function code?

Yes. AWS Lambda allows you to use normal language and operating system features, such as creating additional threads and processes. Resources allocated to the Lambda function, including memory, execution time, disk, and network use, must be shared among all the threads/processes it uses.

Q: What restrictions apply to Lambda function code?

Lambda attempts to impose few restrictions on normal language and operating system activities, but there are a few activities that are disabled: Inbound network connections are managed by AWS Lambda, only TCP/IP sockets are supported, and ptrace (debugging) system calls are restricted.

Q: How do I create a Lambda function using the Lambda console?

You can author the code for your function using the inline editor in the AWS Lambda console, or package the code (and any dependent libraries) as a ZIP and upload it. Uploads must be no larger than 20MB (compressed). Go to the console to get started.

Q: How do I create a Lambda function using the Lambda CLI?

You can package the code (and any dependent libraries) as a ZIP and upload it using the AWS CLI. Uploads must be no larger than 20MB (compressed). Visit the Lambda Getting Started guide to get started.

Q: How can I manage my Lambda functions?

You can easily list, delete, update, and monitor your Lambda functions using the dashboard in the AWS Lambda console. You can also use the AWS CLI and AWS SDK to manage your Lambda functions. Visit the Lambda developers guide to learn more.

Q: How do I monitor a Lambda function?

AWS Lambda automatically monitors Lambda functions on your behalf, reporting real-time metrics through Amazon CloudWatch, including total requests, latency, and error rates. You can view request rates and error rates for each of your Lambda functions via the Amazon CloudWatch console or through the AWS Lambda console’s dashboard. You can also call third-party monitoring APIs in your Lambda function. Visit Troubleshooting CloudWatch metrics to learn more.

Q: How do I troubleshoot failures in a Lambda function?

AWS Lambda automatically integrates with Amazon CloudWatch logs, creating a log group for each of your Lambda functions and providing basic application lifecycle event log entries, including resources consumed. To help validate if your code is executing as expected, you can easily insert logging statements into your code. You can also call third-party logging APIs in your Lambda function. Visit Troubleshooting Lambda functions to learn more.

Q: How do I scale a Lambda function?

You do not have to scale your Lambda functions – AWS Lambda scales them automatically on your behalf. Every time an event notification is received for your function, AWS Lambda quickly locates free capacity within its compute fleet and runs your code. Since your code is stateless, AWS Lambda can start as many copies of your function as needed without lengthy deployment and configuration delays. There are no fundamental limits to scaling a function. AWS Lambda will dynamically allocate capacity to match the rate of incoming events.

Q: How are compute resources assigned to an AWS Lambda function?

In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources. For example, choosing 256MB of memory allocates approximately twice as much CPU power to your Lambda function as requesting 128MB of memory and half as much CPU power as choosing 512MB of memory. You can set your memory in 64MB increments from 128MB to 1GB.

Q: How long can a Lambda function execute?

At launch, AWS Lambda limits function execution to 60 seconds. The default timeout is 3 seconds, but you can set the timeout to any value between 1 and 60 seconds.

Q: How will I be charged for using Lambda functions?

AWS Lambda is priced on a pay per use basis. Please see the AWS Lambda pricing page for details.

Q: How do I allow my Lambda function access to other AWS resources?

You grant permissions to your Lambda function to access other resources using an IAM role, referred to as an “execution role”. AWS Lambda assumes the execution role while executing your Lambda function, so you always retain full, secure control of exactly which AWS resources it can use. Visit Setting up AWS Lambda to learn more about roles.


Q: What is an event source?

An event source is an AWS service or developer-created application that produces events that trigger a Lambda function to run. Some services publish these events to Lambda by invoking the cloud function directly (for example, Amazon S3). Lambda can also poll resources in other services that do not publish events to Lambda. For example, Lambda can pull records from a Kinesis stream and execute a Lambda function for each message in the stream.

Many other services, such as AWS CloudTrail, can act as event sources simply by logging to Amazon S3 and using S3 bucket notifications to trigger AWS Lambda functions.

Q: What event sources can be used with AWS Lambda?

At launch, AWS Lambda can respond to events from Amazon S3 bucket notifications, Amazon DynamoDB Streams and Kinesis streams as event sources.

Q: How are events represented in AWS Lambda?

Events are passed to a Lambda function as an event input parameter. For event sources where events arrive in batches, such as Amazon Kinesis and Amazon DynamoDB Streams, the event parameter may contain multiple events in a single call, based on the batch size you request.

Q: How do I make a Lambda function respond to changes in an Amazon S3 bucket?

From the AWS Lambda console, you can select a function and associate it with notifications from an Amazon S3 bucket. Alternatively, you can use the Amazon S3 console and configure the bucket’s notifications to send to your AWS Lambda function. This same functionality is also available through the AWS SDK and CLI.

Q: How do I control which Amazon S3 buckets can call which AWS Lambda functions?

You grant Amazon S3 buckets permission to invoke your Lambda function using an IAM role, known as the “invocation role”. Visit the Lambda developers guide to learn more.

Q: How do I make a Lambda function respond to updates in an Amazon DynamoDB table?

You can associate a DynamoDB Stream with a Lambda function using the Amazon DynamoDB console or Lambda’s registerEventSource API.

Q: How do I control which Amazon DynamoDB table an AWS Lambda function can poll?

You grant AWS Lambda permission to access a DynamoDB Stream using an IAM role, known as the “invocation role”. Visit the Lambda developers guide to learn more.

Q: How do I make a Lambda function process messages in an Amazon Kinesis stream?

You can associate an Amazon Kinesis stream with a Lambda function using Lambda’s registerEventSource API. Access controls are handled similarly to Amazon DynamoDB events.

Q: How can my application use custom events to trigger an AWS Lambda function?

You can invoke a Lambda function using a custom event through Lambda’s invokeAsync API. Only the function’s owner or another AWS account that the owner has granted permission can invoke the function. Visit the Lambda developers guide to learn more.

Q: What is the latency of invoking a Lambda function in response to an event?

AWS Lambda is designed to process events within a few milliseconds. Latency will be higher immediately after a Lambda function is created, updated, or if it has not been used recently.

Q: What happens if my function fails while processing an event?

For Amazon S3 bucket notifications and custom events, AWS Lambda will attempt execution of your function three times in the event of an error condition in your code or if you exceed a service or resource limit. For ordered event sources that AWS Lambda polls on your behalf, such as Amazon DynamoDB Streams and Amazon Kinesis streams, Lambda will continue attempting execution in the event of a developer code error until the data expires. You can monitor progress through the Amazon Kinesis and Amazon DynamoDB consoles and through the Amazon CloudWatch metrics that AWS Lambda generates for your function. You can also set Amazon CloudWatch alarms based on error rates.


Q: Which versions of Amazon Linux, Node.js, and additional libraries does AWS Lambda support?

You can view the list of supported versions here.

Q: Can I change the version of Amazon Linux or Node.js?

No; AWS Lambda offers a single version of the operating system and language runtime to all users of the service.

Q: Can I change the version of a supported library?

Yes; you can include your own copy of a library in order to use a different version than the default.

Q: Can I use packages with Lambda?

Yes. You can use NPM packages as well as custom written packages. To get started with NPM packages create a folder for your Lambda function and do an npm install using the prefix = ~/lambdafunction PACKAGENAME. Make sure to include the node_modules folder in your ZIP before you upload your function.

Q: Can I execute binaries with Lambda?

Yes. You can use Node.js's child_process command to execute a binary that you've included in your function. Alternatively several NPM packages exist that wrap command line binaries such as node-ffmpeg. If you are using binaries, please ensure you include the following at the start of your function code:

process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']

Q: Is it possible to use native modules with Lambda?

Yes. Any statically linked native module can be included in the ZIP file you upload, as well as dynamically linked modules compiled with an rpath pointing to your Lambda function root directory (example: LDFLAGS="-Wl,-rpath,'/var/task/yourlib'" npm install PACKAGENAME).

Q: Does AWS Lambda support versioning?

Each AWS Lambda function has a single, current version of the code, but developers can upload multiple versions of their code as separate Lambda functions and employ a naming scheme to differentiate them.

Q: How do I deploy AWS Lambda function code?

At launch, Lambda supports uploading code as a ZIP file using the uploadFunction API.

Q: How long after uploading my code will my AWS Lambda function be ready to call?

Deployment times may vary with the size of your code, but AWS Lambda functions are typically ready to call within seconds of upload.

Q: How does AWS Lambda secure my code?

AWS Lambda stores code in Amazon S3 and encrypts it at rest. AWS Lambda performs additional integrity checks while your code is in use.

Q: Can I access resources behind Amazon VPC access with my Lambda function?

At launch, AWS Lambda functions cannot access resources behind a VPC.

Q: Can I execute other programs from within my Lambda function?

Yes. Lambda’s built-in sandbox lets you safely run batch (“shell”) scripts, other language runtimes, utility routines, and executables included in your Lambda function.