I have a lex bot and intent, and a lambda function handling the fulfillment and verification for the bot. I'm working on building an effective development workflow for development.
What is the most effective way to make sure that the Lambda function I'm hitting is on the latest version?
Currently I'm updating the function code in my IDE, and updating it with this script:
#!/bin/bash -e
rm lambda.zip || echo "Cleaning zip"
zip lambda.zip *.js -r node_modules/
aws lambda update-function-code \
--profile myprofile \
--function-name my-lambda-function \
--zip-file fileb://lambda.zip
I then use the test interface in the lex console to update it, and read the log output with this script:
#!/bin/bash
LOGSTREAM=$(aws logs describe-log-streams --profile myprofile --log-group-name /aws/lambda/my-lambda-function | jq -r '.logStreams | .[-1].logStreamName')
aws logs get-log-events --profile myprofile --log-group-name /aws/lambda/my-lambda-function --log-stream-name "$LOGSTREAM" --limit 5
Does this use of the AWS cli produce any major synchronization issues? Is there a better way to have a quick development cycle?
Edit:
Thanks to Marcin, I've updated this to use aliases, and here's the resulting deployment code:
#!/bin/bash -e
rm lambda.zip || echo "Cleaning zip"
zip lambda.zip *.js node_modules/
VERSION=$(aws lambda update-function-code \
--profile myprofile \
--publish \
--function-name my-lambda-function \
--zip-file fileb://lambda.zip \
| jq -r .Version)
aws lambda update-alias \
--profile myprofile \
--function-name my-lambda-function \
--name dev \
--function-version $VERSION