Update AWS Lambda Function Code Using awscli

NOVEMBER 4, 2020

The Amazon Web Services (AWS) command-line interface — the awscli — lets you update the code of a Lambda function right from the cli. Here's how.

aws lambda update-function-code \
--function-name my-function-name \
--region us-west-2 \
--zip-file fileb://

Let's understand what you need to run this command.

  • aws lambda update-function-code - to execute this command you need the awscli installed on your machine and your authentication information has to be configured to your account
  • --function-name - this is the name of an existing Lambda function in your AWS account
  • --region - the region in which your Lambda lives (in this case, it's Oregon, whose code is us-west-2, you can see a list of regions and their codes here)
  • --zip-file - this is the path to your zipped Lambda code with the fileb:// prefix, in the example, there's a file in the current directory, alternatively you can use the --s3-bucket and --s3-key to use a zip file from an S3 bucket)

If you want to learn more about this command, here's the AWS CLI command reference guide, and here's the free Kindle version.