LP13
LP13

Reputation: 34109

Publishing aws lambda version using jenkins and aws cli

I want to create a jenkins job that will publish a new AWS lambda version and update existing alias to new version just created.

I already have prod alias created in AWS Lambda.

Now i would i like to publish a new version and the update prod alias to point to new version.

There is walkthrough shows how to do it using AWS CLI. So here are the corresponding steps

1>Publish a new version of the Lambda function.
aws lambda publish-version --function-name helloworld

2>Update prod alias to latest version.
aws lambda update-alias --function-name helloworld function-version 2 --name prod

ISSUE
In Jenkins i will have to execute these commands as windows batch command But i am not able to understand how do i dynamically pass the version number that was created by publish-version command in step 1, to update-alias command in step 2?

Upvotes: 2

Views: 448

Answers (1)

user15376365
user15376365

Reputation: 11

You can use below aws CLI command in the execute shell.

VERSION=$(aws lambda publish-version --function-name helloworld | jq -r .Version)
aws lambda update-alias --function-name helloworld --name prod --function-version $VERSION

Upvotes: 1

Related Questions