カナリアとロールバックによる安全なデプロイ
ダウンタイムなしでサーバーレスの変更をリリースします。Lambdaエイリアス、重み付きトラフィックシフト、CodeDeployのカナリアデプロイ、アラーム発生時の自動ロールバックを学びます。
「カナリアとロールバックによる安全なデプロイ」はCoddyKit上の無料Serverless Backend with AWS Lambda & API Gatewayレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはServerless Backend with AWS Lambda & API Gateway学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Serverless Backend with AWS Lambda & API Gatewayコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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
よくある質問
「カナリアとロールバックによる安全なデプロイ」レッスンは無料ですか?
はい。「カナリアとロールバックによる安全なデプロイ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Serverless Backend with AWS Lambda & API Gatewayコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Serverless Backend with AWS Lambda & API Gatewayコースには全4レッスンが含まれています。
「カナリアとロールバックによる安全なデプロイ」で何を学びますか?
ダウンタイムなしでサーバーレスの変更をリリースします。Lambdaエイリアス、重み付きトラフィックシフト、CodeDeployのカナリアデプロイ、アラーム発生時の自動ロールバックを学びます。 ブラウザで直接実行するハンズオンコードでServerless Backend with AWS Lambda & API Gatewayを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Serverless Backend with AWS Lambda & API Gatewayを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのServerless Backend with AWS Lambda & API Gatewayは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「カナリアとロールバックによる安全なデプロイ」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このServerless Backend with AWS Lambda & API Gatewayレッスンでコードを書いて実行できますか?
はい。すべてのServerless Backend with AWS Lambda & API Gatewayレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- CodeCommitとCodeBuild
- デプロイに使うCodePipeline
- サーバーレスデプロイの自動化
- カナリアとロールバックによる安全なデプロイ