Skip to main content
In this lesson we cover Lambda versioning, aliases, and traffic-shifting techniques used for controlled serverless rollouts (blue/green, canary, linear). This material supports Domain 1, Task 1.4: deployment strategies for serverless environments. We’ll use a demo function named 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.
A screenshot of the AWS Lambda console for the function "devops-020-320-function," showing the Versions tab with a list of versions (3–6), their last-modified times and x86_64 architecture. The page also shows options to add a trigger or destination and displays the function ARN.

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.
A screenshot of the AWS Lambda console displaying "Version: 5" for the function named devops-020-320-function, with a diagram, function ARN, and configuration details visible. The page shows general settings like memory (256 MB), timeout (30 sec), and action buttons such as Copy ARN and Export to Infrastructure Composer.

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
The Lambda console exposes the calculated percentages when you configure weights.
A screenshot of the AWS Lambda console showing the function "devops-020-320-function" with a green banner confirming a "prod" alias was created. The Aliases tab lists "live" (version 3) and "prod" (versions 6 and 5 with weighted traffic).

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.
A screenshot of the AWS Lambda console on the Monitor tab showing CloudWatch metrics panels (Invocations, Duration, Error count and success rate) with "No data available" messages. A green banner at the top says "Alias test was successfully created and is now pointing to versions 5 and 6."

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
Lambda deployments with CodeDeploy require an AppSpec file describing current and target versions, the alias name, and lifecycle hooks. Example AppSpec (YAML):
If resources or hook functions are missing, CodeDeploy will fail the deployment and often trigger a rollback.
A screenshot of the AWS CodeDeploy console showing a failed deployment (d-94B4N5CEI) with a red error banner stating the target Lambda function "devops-demo-function" does not exist or the specified version/alias cannot be found. The page also displays deployment and revision details.

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
The console provides deployment history and shows rollback events when they occur.
A screenshot of the AWS CodeDeploy console showing Deployment group tags (e.g., Environment: learning, Purpose: devops-professional-exam-prep, ManagedBy: terraform) and the deployment group history. The history lists recent failed deployments with a "CodeDeploy rollback" event.

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.
A screenshot of the AWS Lambda console showing Version: 6 of a function named "devops-020-320-function" with a green banner confirming an alias was created and the function overview/diagram visible. The page also shows actions like Copy ARN, Export to Infrastructure Composer, and a section for environment variables.
A view of aliases showing weighted traffic between versions:
A screenshot of the AWS Lambda console on the Aliases tab for a function, showing aliases (live, prod, test) with version weights and a green banner saying an alias was successfully created. The right panel shows the function ARN and buttons to add triggers or destinations.

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.
Both apply to published versions and work well with aliases and CodeDeploy-based rollouts.
A screenshot of the AWS Lambda "Edit basic settings" page showing configuration fields like memory (256 MB), ephemeral storage (512 MB), SnapStart, timeout, and execution role. A green notification banner at the top reads "Alias test was successfully created and is now pointing to versions 5 and 6."

Key takeaways

  • Use published versions and aliases for production stability — \$LATEST is 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.
Understand the differences between canary and linear rollouts, know how aliases and versions interact, and be familiar with AWS CodeDeploy AppSpec syntax and hooks — these are common exam and real-world topics for serverless deployments.

Further reading and references

Watch Video