/ lambda

AWS Lambda Command Line Reference

Today I was setting up some CI infrastructure to facilitate faster lambda function updates by automating the build, packaging and deployment of the lambda function.

Configure AWS cli if you haven't done so already

aws configure

Follow the prompts to enter your credentials

For lambda interations as of this post, US-EAST-1 is the only valid region for Amazon Echo and Lambda integration.

Now you can get function details

aws lambda get-function --function-name movies

Output

{
    "Code": {
        "RepositoryType": "S3",
        "Location": "https://........."
    },
    "Configuration": {
        "Version": "$LATEST",
        "CodeSha256": "2UyNTr8N8Hf6sBOCduXE1dzI9aizqxpPD6vsB242Xr4=",
        "FunctionName": "movies",
        "MemorySize": 128,
        "CodeSize": 1742916,
        "FunctionArn": "arn:aws:lambda:us-east-1:230565932687:function:movies",
        "Handler": "index.handler",
        "Role": "arn:aws:iam::230565932687:role/lambda_basic_execution",
        "Timeout": 10,
        "LastModified": "2016-01-02T03:25:16.139+0000",
        "Runtime": "nodejs",
        "Description": "Local movie play times"
    }
}

Publishing code

I wanted to automate deployment of my node package. Past a certain point, editing things in the console works, but once your package starts to bring in dependencies, you will need to upload a zip of your package.

Few ways that the cli takes code updates

  1. base64 encoded zip file (blob)
  2. upload your zip file to an s3 bucket and have aws pull it over that way

Publishing via --zip-file

aws lambda update-function-code --function-name movies --zip-file fileb://export/alexa-movies.zip

Output

{
    "CodeSha256": "gVsVfqF0/uustVguwpsHyFfYLWMAUr5/FEx3B5y62NQ=",
    "FunctionName": "movies",
    "CodeSize": 2441975,
    "MemorySize": 128,
    "FunctionArn": "arn:aws:lambda:us-east-1:230565932687:function:movies",
    "Version": "$LATEST",
    "Role": "arn:aws:iam::230565932687:role/lambda_basic_execution",
    "Timeout": 10,
    "LastModified": "2016-01-02T17:56:40.535+0000",
    "Handler": "index.handler",
    "Runtime": "nodejs",
    "Description": "Local movie play times"
}
AWS Lambda Command Line Reference
Share this