Using Amazon Lambda

AWS LambdaAs I mentioned last week, I’m in the process of using Lambda with Elastic Transcoder to automate conversion of m4a files into mp3 files. I spent the weekend writing a few scripts in node.js; here’s what I’ve learned so far:

  1. A Lambda function is a pretty simple thing to write.
    1. There are tons of examples to reference
    2. You can write your functions in 3 languages – javascript (node.js), Java, and Python
  2. Lambda plays nicely with most AWS services
    1. I’m interacting with CloudWatch, SNS and S3… no problems, except for…
  3. IAM/Security can trip you up if you’re not careful
    1. 25% of my debgging time was spent figuring out what permissions I needed to add (without given “wide-open” permissions to my IAM role).

Overall, I ended up writing two functions:

  1. One to convert the m4a file
    1. This is triggered after a m4a file is uploaded to a specific S3 folder.
    2. The function uses an ET pipeline to create a job to convert the file
    3. SNS is used to notify me when the job is kicked off (note, I removed this after testing)
  2. Delete old m4a file
    1. This function deletes the old m4a file after the mp3 file is created
    2. I separated the functions because I wanted to make sure the ET job completed before the source file was deleted.

Toss a request in the comment section if you want to see examples of either function.

Leave a Reply