I'm working on setting up a build+release pipeline for my lambda functions. My build works fine and publishes a new lambda version when it runs. I have 2 aliases:
- staging
- production
When the codepipeline runs, I want the new version to be released to the staging alias. This is my appspec.yml which works fine hard-coded:
version: 0.0 resources: - myLambdaFunction: type: "AWS::Lambda::Function" properties: name: myLambdaFunction alias: staging targetversion: "3" # current version is required or it will error currentversion: "2" currentversion is supposed to be the version that staging alias points to, but the problem is I don't know that at deploy time, and AWS definitely does - in fact it will throw an error and kill deployment if I get that wrong. When deployment is initiated, I would ideally like to get the version that it currently points to with the aws cli, but AWS seems to prevent hooks from running for lambda functions in code deploy.
My question is - is there a way for me to get the current version of a given alias in the deployment script (appspec.yml).
I can substitute in targetversion during the build process, but since the release pipeline need not run immediately after the build, its possible currentversion could change before it runs, so I need to actually set it while deploying.