update-function-code AWS CLI command updates all code files except the handler function file, lambda_function.py
Specifically, I made a bash script that
Everything works, except the main function file lambda_function.py
does not get updated.
Oddly, when I download the zip from a lambda, make a change, and then upload to the same lambda, it works (all files are updated).
FYI, here is my bash script to download code from one lambda, and upload to another:
#!/bin/sh
SRC_LAMBDA_FUNCTION_NAME="$1"
DEST_LAMBDA_FUNCTION_NAME="$2"
export PYTHONIOENCODING=utf8
# get lambda function config
LAMBDA_JSON=$(aws lambda get-function --function-name $SRC_LAMBDA_FUNCTION_NAME)
export LAMBDA_JSON
# parse the code zip file download URL (link expires 10 minutes after creation)
ZIP_FILE_URL=$(python -c 'import json,sys,os;obj=json.loads(os.environ["LAMBDA_JSON"]);print(obj["Code"]["Location"])')
# make temp dir
mkdir -p download
# download the code from src lambda
curl -o "download/$SRC_LAMBDA_FUNCTION_NAME.zip" $ZIP_FILE_URL
# upload the code to dest lambda
aws lambda update-function-code --function-name $DEST_LAMBDA_FUNCTION_NAME --zip-file "fileb://download/$SRC_LAMBDA_FUNCTION_NAME.zip"
Change settings such as the function handler name or Amazon Simple Storage Service (Amazon S3) source bucket – Right-click the function name, and then choose Update Function Code. Complete the Update Code dialog box, and then choose Update.
I was verifying the code changes by navigating to the lambda code editor on the AWS web portal, and it appears this was just a client side issue in the web UI.
It took about 5 minutes before the lambda_function.py
was updated in the UI (despite refreshing), whereas the other code files did get updated immediately.
It is very strange that other files got updated, but not lambda_function.py
. This makes me think it is not just a browser caching issue, but maybe a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With