1

My CI pipeline will do two things

  • generate new lambda version and publish
  • Update an alias to point at that new version

This will be done via cli commands. My question is, how do I access the version number that been generated from the first command. It is returned and posted to the CLI. Can this be access easily via some nifty was command or will I have to parse it myself?

e.g.

enter image description here

3 Answers 3

2
version=$(aws lambda publish-version \
  --function-name test_lambda --description "updated via cli" --region eu-west-1 \
  --query Version \
  --output text)

See Controlling Command Output from the AWS Command Line Interface page of AWS CLI User Guide, specifically How to Filter the Output with the --query Option and Text Output Format

Sign up to request clarification or add additional context in comments.

1 Comment

Might need to add the double quotes to the --query param
1

This works but still curious if there is a better way.

version=$(aws lambda publish-version --function-name test_lambda --description "updated via cli" --region eu-west-1| jq '.Version')

1 Comment

version=$(aws lambda publish-version --function-name test_lambda --description "updated via cli" --region eu-west-1 | jq '.Version | tonumber') Needs to be an int to use in the update-alias command
0
NEW_LAMBDA_VERSION=$(aws lambda list-versions-by-function --function-name $LAMBDA_NAME_FOR_DEPLOY --no-paginate --query "max_by(Versions, &to_number(to_number(Version) || '0'))")
NEW_LAMBDA_VERSION=$(echo $NEW_LAMBDA_VERSION | jq -r .Version)
echo $NEW_LAMBDA_VERSION

In this case, I use on .gitlab-ci.yml.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.