devops-020-320-function to demonstrate versions, aliases, and how CodeDeploy automates safe traffic shifts.
A tiny snippet used in the demo environment:
Lambda versioning and $LATEST behavior
When you publish a Lambda version, AWS creates an immutable snapshot of the function code and configuration. A published version number (for example, 3) is fixed and cannot be changed. By contrast, the $LATEST qualifier is mutable — it updates whenever you change the function code or configuration. Invoking the function without a qualifier uses $LATEST.
Always publish and reference a specific version (or an alias that points to a version) for production traffic. Using
\$LATEST for production reduces predictability and complicates rollbacks.
Aliases: stable pointers to versions
Aliases are named pointers that map to a published version (for example,live -> 3). Use aliases for production references so you have stable ARNs and clear rollback points. You can update an alias at any time to repoint production traffic to another published version, which makes rollbacks trivial.

Weighted aliases for traffic shifting
Lambda aliases support weighted routing, which lets you split incoming requests between the alias’s primary version and up to five additional published versions. This is ideal for simple canary tests or gradual rollouts, for example:- 90% -> version 5, 10% -> version 6

Monitoring alias traffic
Monitor alias-specific metrics such as invocations, duration, and errors in the Lambda console Monitor tab or via AWS CloudWatch. If an alias has very little traffic, the console may display “No data available” for those metrics.
When to use CodeDeploy
For production-grade traffic shifting and automated rollouts, prefer AWS CodeDeploy over manual alias updates. CodeDeploy:- Automates traffic shift schedules
- Supports canary and linear strategies
- Integrates with AWS CodePipeline for CI/CD
- Offers lifecycle hooks for validation (e.g., smoke tests)
- Records deployment history and supports automatic rollback via CloudWatch alarms

Deployment history, rollbacks, and configuration
CodeDeploy groups deployments into a deployment group (which can be tagged and managed by IaC tools like Terraform). Each group lets you select:- Deployment type (All-at-once, Canary, Linear)
- Traffic shift timing and batch sizes
- CloudWatch alarms to trigger automatic rollback

Rollout strategies at a glance
Practical notes and console views
From the Lambda console you can inspect versions, aliases, memory, ephemeral storage, timeouts, environment variables, execution role, and more. Lambda integrates with API Gateway, supports deployment frameworks like AWS SAM, and can be optimized using SnapStart or provisioned concurrency to reduce cold starts.

SnapStart, provisioned concurrency, and other optimizations
- SnapStart: Creates a cached snapshot of an initialized execution environment for a published version (reduces cold-start times for supported runtimes).
- Provisioned concurrency: Keeps execution environments warm so latency is predictable for production traffic.

Key takeaways
- Use published versions and aliases for production stability —
\$LATESTis mutable and should be avoided for production invocations. - Aliases provide stable references and support simple weighted traffic shifting (route between the alias’s primary version and up to five additional versions).
- For automated, auditable traffic shifting (canary/linear), use AWS CodeDeploy with an AppSpec file and lifecycle hooks.
- Use AWS CloudWatch alarms to enable automatic rollback where applicable. Consider SnapStart or provisioned concurrency to reduce cold starts.
Further reading and references
- AWS CodeDeploy
- AWS Lambda Developer Guide - Versions and Aliases
- AWS CloudWatch
- AWS SAM
- SnapStart documentation
- Provisioned concurrency documentation