Despliegues seguros con canary y rollback
Publique cambios serverless sin tiempo de inactividad. Aprenda a usar alias de Lambda, desplazamiento ponderado del tráfico, despliegues canary con CodeDeploy y rollback automático ante alertas.
Despliegues seguros con canary y rollback es una lección gratuita de Serverless Backend with AWS Lambda & API Gateway en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Serverless Backend with AWS Lambda & API Gateway, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Serverless Backend with AWS Lambda & API Gateway incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
The Risk of Big-Bang Deploys
Switching all traffic to new code at once means a bug hits every user instantly. Progressive deployments shift traffic gradually so problems surface on a small slice first.
Lambda Versions and Aliases
Publishing a Lambda creates an immutable version. An alias is a pointer (like live) you can move between versions, enabling controlled cutovers.
Weighted Aliases
An alias can split traffic between two versions by weight, sending, say, 10% to the new version and 90% to the old.
aws lambda update-alias \
--function-name api --name live \
--function-version 12 \
--routing-config '{"AdditionalVersionWeights":{"11":0.9}}'Canary Deployments
A canary sends a small percentage of traffic to the new version, waits, then promotes the rest if healthy. CodeDeploy automates this for Lambda.
Deployment Preferences in SAM
SAM exposes this via DeploymentPreference, choosing a canary or linear pattern.
AutoPublishAlias: live
DeploymentPreference:
Type: Canary10Percent5Minutes
Alarms:
- !Ref ErrorAlarmLinear Deployments
A linear pattern shifts traffic in equal increments over time (e.g. 10% every minute), giving a slower, steadier rollout than a single canary step.
CloudWatch Alarms as Gates
Attach alarms (error rate, latency) to the deployment. If an alarm fires during the shift, the deployment is considered failed.
Automatic Rollback
When an alarm trips, CodeDeploy automatically moves the alias back to the previous version, restoring known-good code with no manual action.
Pre and Post Traffic Hooks
Lifecycle hook Lambdas run before and after traffic shifts, letting you run smoke tests and abort the deploy if they fail.
Blue/Green vs Canary
Blue/green stands up a full second environment and switches over; canary shifts a percentage within one environment. For Lambda, weighted aliases make canary the simpler, cheaper default.
Best Practices
Deploy safely:
- Always deploy behind an alias
- Start with a small canary percentage
- Gate on meaningful alarms
- Run smoke tests in pre-traffic hooks
Quick Check
Test your safe-deployment knowledge.
Recap
You learned progressive delivery:
- Versions are immutable; aliases point to them
- Weighted aliases and canaries shift traffic gradually
- SAM DeploymentPreference automates canary/linear patterns
- Alarms gate the rollout and trigger automatic rollback
Preguntas frecuentes
¿La lección «Despliegues seguros con canary y rollback» es gratis?
Sí — el texto completo de «Despliegues seguros con canary y rollback» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Serverless Backend with AWS Lambda & API Gateway, actualiza a CoddyKit PRO. El curso de Serverless Backend with AWS Lambda & API Gateway incluye 4 lecciones en total.
¿Qué aprenderé en «Despliegues seguros con canary y rollback»?
Publique cambios serverless sin tiempo de inactividad. Aprenda a usar alias de Lambda, desplazamiento ponderado del tráfico, despliegues canary con CodeDeploy y rollback automático ante alertas. Practicas Serverless Backend with AWS Lambda & API Gateway con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Serverless Backend with AWS Lambda & API Gateway?
No se requiere experiencia previa. Serverless Backend with AWS Lambda & API Gateway en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Despliegues seguros con canary y rollback»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Serverless Backend with AWS Lambda & API Gateway?
Sí. Cada lección de Serverless Backend with AWS Lambda & API Gateway incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- CodeCommit y CodeBuild
- CodePipeline para implementaciones
- Automatización de implementaciones serverless
- Despliegues seguros con canary y rollback