Function Versions and Aliases
You'll learn how to manage multiple versions of your serverless functions and use aliases to route traffic safely between them.
What Are Function Versions?
Every time you deploy changes to your serverless function, you can publish a version — an immutable snapshot of your function's code, configuration, and environment variables. Think of versions like published book editions: once printed, they can't be changed. The function you're actively working on is called $LATEST (the unpublished draft), while each version gets a number like 1, 2, 3, etc.
What Are Aliases?
An alias is a friendly pointer or label that references a specific function version. Instead of invoking myFunction:3, you might invoke myFunction:prod. Aliases are mutable — you can change which version they point to without changing the code that calls your function.
Think of an alias like a bookmark: the bookmark (alias) stays the same, but you can move it to point at different pages (versions) in your book.
Why Use Them Together?
This combination enables safe deployments:
- Deploy new code as version
4 - Keep your
prodalias pointing at version3 - Test version
4thoroughly using atestalias - When ready, update
prodto point at version4 - If problems arise, instantly roll back
prodto version3
Advanced aliases even support traffic shifting — splitting traffic between two versions (e.g., 90% to version 3, 10% to version 4) for gradual rollouts and A/B testing.
This versioning strategy prevents breaking production deployments and gives you precise control over which code runs in each environment.
Key Takeaway: Function versions create immutable snapshots of your code, while aliases provide stable names that can point to different versions, enabling safe deployments, instant rollbacks, and controlled traffic shifting.