Allow warmup of Unqualified Alias
See original GitHub issueThere is currently no way of warming up the Unqualified alias. From what I see in the code there is a way of setting a specific alias via an env variable, otherwise it will default to $LATEST. Which is fine in most of the cases. Up until API Gateway V2 showed up.
The problem arises in this scenario: Deploy a function and attach API Gateway V2. It will, by default, link the Unqualified alias of the function. There is currently no plugin that allows you to both create aliases and link the correct alias in API Gateway. There is some kind of CF template you can use to get very close (without having to create a custom plugin) where you can disable versioning from serverless, have a script that automatically generates a unique name for the versioning step, then create the alias and/or switch the version on the alias. The last bit I wasn’t able to work out is how to link a specific alias in API Gateway V2, I guess it’s so “new” that wasn’t really taken seriously, or API Gateway V1 is so deep in the serverless logic that will require some kind of refactoring. Anyway, that’s is a different story.
What happens, and I proved it myself (although the AWS support sent me a confused response), is that if you warm up the $LATEST version, the Unqualified alias won’t be warmed up, although by default is linked to $LATEST.
To validate what I am saying you can:
- create a new Lambda function
- start the warmer on $LATEST - you will see in the monitor of $LATEST the executions of the warmer function
- switch to the Unqualified alias - the monitor won’t show any sign of the warmer running
- the first execution in Unqualified will have a cold start
- now create a new alias and point it to $LATEST
- test the new alias, you will have a cold start
Now, if Lambda supported the setting of env variables as empty, this would be just a matter of creating an empty env variable in the lambda function via serverless, but you can’t create empty env variables in Lambda.
It would be great if there was a workaround to this issue and have the warmup (optionally) to run on the Unqualified alias.
I already tried setting Unqualified as SERVERLESS_ALIAS and didn’t work
Warm Up Invoke Error: function ResourceNotFoundException: Function not found: arn:aws:lambda:function:Unqualified
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
This took way to long but v5 is finally released.
@juanjoDiaz thanks for your reply, I already checked that plugin and it currently doesn’t support Api Gateway V2 (HTTP Gateway).
What I am really asking is that the Qualifier parameter gets removed when invoking the function, if specified by an env variable or some other way.
The AWS premium support has replied (it’s not the first time) with a copy&paste from their documentation.
Don’t worry if you don’t want to make any changes, we have solved it by removing this plugin from the serverless config file after having deployed once. Then we removed the “Qualifier” parameter from the lambda function code and the warmup is working as expected. I’m sure we’re not the only one facing this issue and it’s a bit annoying having to manually do the above every time we need warmup in a new function.
This plugin works perfectly with API Gateway V1 because the API Gateway link to the lambda ARN includes the alias/version (e.g. $LATEST), with API Gateway V2 the alias/version is not there, not even the UI in the AWS console allows you to pick an alias/version, but you can manually paste in the full ARN and it works.