AWS Lambda – querying and updating the Lambda runtime with the AWS CLI

In a previous post I used jq to parse the responses from the aws cli for Lambdas to search for or parse the results for specific property values. Querying Lambda properties can also be done via the aws cli itself without using jq (although using jq is significantly more powerful).

If you’ve received an email from AWS about runtimes that are reaching End of Life, the emails usually contain an example use of the cli showing how to query for specific runtimes, for example:

aws lambda list-functions --function-version ALL --region us-west-1 --output text --query "Functions[?Runtime=='nodejs14.x'].FunctionArn"

The long term solution for upgrading a runtime should be to redeploy and test with the latest runtime and then redeploy your production value after testing. It is possible for a quick fix to update the runtime of a deployed Lambda directly via the aws cli. Once you’ve identified which Lambdas need to update, use this command to update:

aws lambda update-function-configuration --function NAME --runtime RUNTIMENAME

Refresher: serverless framework local development workflow

It’s been a while since I’ve written any notes about the Serverless framework, so here’s a few notes as a refresher on typical steps I use for local development.

As a reminder to self, regions I typically deploy to are:

  • us-west-1 : SF
  • us-west-2: Oregon
  • eu-west-2: London

AWS regions are listed here.

To deploy:

serverless deploy --region eu-west-2

To invoke local:

serverless invoke local --function functionName

To invoke remotely:

serverless invoke --function functionName --region eu-west-2

To check logs from last invoke:

serverless logs --function functionName --region eu-west-2

AWS Lambda temp file storage

Lambdas by default do not have write access to the instance filestorage where they are running. They do my default have 512MB of ephemeral storage mounted at /tmp – this space is include in the Lambda runtime costs by default and can be increased (with additional cost) in 1MB increments upto 10GB.

More info here: https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage