1

I am getting started with writing an Alexa Skill. My skill requires uploading a .ZIP file as it includes the alexa-sdk dependency being stored in the node_modules folder.

Is there a more efficient way to upload a new version of my Lambda function and files from my local machine without zipping and manually uploading the same files over and over again? Some like git push or a different way to deploy via Terminal with a single command?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Bernd
  • 11,133
  • 11
  • 65
  • 98

3 Answers3

0

You can use the update-function-code CLI command.

Note that his operation must only be used on an existing Lambda function and cannot be used to update the function configuration.

Khalid T.
  • 10,039
  • 5
  • 45
  • 53
0

To add to Khalid's answer, I recently created this rudimentary batch script to ease a particular lambda function's deployment. This example is for a NodeJS Lambda function which has it's dependencies located in the node_modules folder.

Prerequisits:

Have 7zip installed. Found here

Have it available in CMD (have it on system PATH variable) as explained here

Have your local aws-cli set up with valid credentials that have access to uploading to AWS Lambda.

rm -rf target
mkdir -p target

cp -r index.js package.json node_modules/ target/

pushd target

7z a zip_file_name.zip -r
popd

aws lambda update-function-code \
    --function-name YOUR_FUNCTION_NAME \
    --zip-file fileb://target/zip_file_name.zip \
    --region us-east-1
Community
  • 1
  • 1
Tom Nijs
  • 3,835
  • 3
  • 22
  • 40
0

My one-liner for bash:

zip -u f.zip f.py; aws lambda update-function-code --zip-file fileb://f.zip --function-name f
Vitaly Zdanevich
  • 13,032
  • 8
  • 47
  • 81