First, zip up your function:
rm lambda.zip; zip -r lambda.zip lambda-function/*
Then, update the current working function:
aws lambda update-function-code --zip-file fileb://lambda.zip --function-name LambdaFunctionName
Next, publish the current working function, and capture the response:
aws lambda publish-version --function-name LambdaFunctionName > lambda_publish_response.json
Finally, run deploy-to-edge.js
. It will take the response found in lambda_publish_response.json
, and update the CloudFront Distribution specified to use the new version of the Lambda function.
I just stumbled upon this via a Google search that led me to this StackOverflow comment… you just saved my day!
I was gonna spend hours building this script when I ended up just copying and adapting it a bit (mostly to use
process.env
to get some variables like the CloudFront Distribution ID and the lambda function's name and add someprocess.exitCode = 1
to show the pipeline has failed).THANK YOU SO MUCH!