Automatically convert files in S3 buckets using AWS Lambda

AWS Lambda is an event-driven compute service which runs your code (Lambda functions) in response to events, such as changes to data in an Amazon S3 bucket. The CloudConvert API can be used to automatically convert all files, added to a specific S3 bucket. Typical use cases are converting all office documents to PDF, creating thumbnails or encoding videos.

We have created a GitHub repository with an example Lambda function. To get it running, follow these instructions:

Choose a name for your Lambda function and use Node.js 4.3 as Runtime. Upload your previously created ZIP file as Lambda function. The Handler name needs to be convert.handler. The lambda function does not need any specific permissions: you can create a new empty role.

A timeout value of 10 seconds should be sufficient. Please note that the lambda function only triggers the actual conversion and terminates as soon as the conversion was started. Therefore the timeout does not affect the time needed for the actual conversion.

Done! You can test your Lambda function by adding a new file to your S3 bucket.