Referencing Lambda version in other variables

aws

#1

I noticed Serverless will auto-increment the Lambda version, which is great for safely deploying updates. However, I’m wondering how to reference that version number in serverless.yml. For example, in a stepFunctions definition:

            Branches:
              - StartAt: Transcode
                States:
                  Transcode:
                    Type: Task
                    Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${self:custom.stage}-transcode
                    End: true

I’d instead like the source to end with :${currentVersion} for example. Is this possible? Or can I somehow just use the fully qualified Lambda ARN?


#2

A few thoughts:

In AWS, there’s a variable for Lambda version called $LATEST:
arn:aws:lambda:aws-region:acct-id:function:helloworld:$LATEST

but I wonder if you really want to do latest version - usually you’ll want to work with stage and/or version aliases.


#3

No, I definitely don’t want the $LATEST version. I’m looking to use the version of the function that was just auto-created by Serverless. I don’t think it’s possible, which is a bummer. It means I’ll have to have two separate YAML files/CloudFormation stacks, and one will use the outputs to get the Lambda ARNs (with version numbers).