Lambda Functions Part 3

Allegedly we’ve laid the groundwork, let’s dive in and see if we can create the Lambda function that will work with S3 containers, as described in the last post. From the CLI, this is a simple matter of executing the following:

$ aws lambda create-function --region us-east-1 --function-name CreateThumbnail --zip-file fileb:// --role arn:aws:iam::485603662400:role/lambda_s3_exec_role --handler CreateThumbnail.handler --runtime nodejs --timeout 10 --memory-size 1024

I’ve left out the fact that the initial ARN was unsuccessful, as alluded to last time. I’ve also left out the implied step of zipping up the *js code we edited to suit our bucket names, along with the dependencies. Here, this is the file on my local filesystem. At the time of writing, these steps are detailed here.

A successful execution will return output that should look something like:

"FunctionName": "CreateThumbnail",
"CodeSize": 120360,
"MemorySize": 1024,
"FunctionArn": "arn:aws:lambda:us-east-1:48560xxxxxxx:function:CreateThumbnail",
"Handler": "CreateThumbnail.handler",

Indeed a look at the AWS Lambda console confirms the creation of the new function. Eventually I’ll hook up real event data from S3 in order to trigger the execution, for now I’ll used some canned input. In preparation, I upload an input image HappyFace.png to the input bucket, and create/edit and input.txt file thusly:


Pay particular attention to the input bucket name, as well as the key for the object you want to operate on. Next time; test!