As 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:
- A Lambda function is a pretty simple thing to write.
- There are tons of examples to reference
- You can write your functions in 3 languages – javascript (node.js), Java, and Python
- Lambda plays nicely with most AWS services
- I’m interacting with CloudWatch, SNS and S3… no problems, except for…
- IAM/Security can trip you up if you’re not careful
- 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:
- One to convert the m4a file
- This is triggered after a m4a file is uploaded to a specific S3 folder.
- The function uses an ET pipeline to create a job to convert the file
- SNS is used to notify me when the job is kicked off (note, I removed this after testing)
- Delete old m4a file
- This function deletes the old m4a file after the mp3 file is created
- 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.