Need help with lambda alias and stage variables

Hello everyone,

I’m trying to create a unique scenario where I can use stage variables with some plugins to create a way to do a canary deployment but be able to test the new code before the traffic shift begins to happen. Basically right now i’m using the serverless-plugin-canary-deployments plugin which allows code deploy to handle the deployment of my lambda’s to an alias and then a weighted transition happens over the course of 10 minutes (how i have it configured in my stack) at 10% a minute. This is great and all but i wanted to build tests to use in a pre transfer hook the code deploy offers to test the new code before it begins the transition with a series of integration tests. I want to do this through api gateway. My plan was to find some way to create a stage variable and inject that variable into the FunctionName ref somehow for each lambda httpApiIntegration by adding extensions in my resource sections.

The problem is that it is referencing an which references the lambda by a version id with a really long GUID that i can’t seem to control. I thought if i just called latest that would work just fine because while the canary plugin sets everything to deploy to live (my alias name) latest also has the newest code that is deployed.

Can anyone assist me with somehow overriding the ApiGatewayV2 integration uri ref to include a stage variable but use live as a default if one is not passed in? Is this even possible?

FYI, i am not a cloudformation expert