3.4.11 Configure Deployment Strategies

Configure Deployment Strategies

Strategy Comparison

StrategyDowntimeRollbackSpeedRisk
All-at-oncePossibleRedeployFastestHighest
RollingNoManualMediumMedium
ImmutableNoTerminate newSlowLow
Blue/GreenNoSwitch backMediumLow
CanaryNoAutomaticSlowLowest

Lambda (CodeDeploy)

TypeBehavior
Canary10Percent5Minutes10% → 5min → 100%
Linear10PercentEvery1Minute+10% every min
AllAtOnce100% immediately

appspec.yml

# Lambda
version: 0.0
Resources:
  - MyFunction:
      Type: AWS::Lambda::Function
      Properties:
        Name: my-function
        Alias: live
        CurrentVersion: 1
        TargetVersion: 2
Hooks:
  - BeforeAllowTraffic: PreTrafficHook
  - AfterAllowTraffic: PostTrafficHook

Hook Order

PlatformHooks
EC2BeforeInstall → AfterInstall → ApplicationStart → ValidateService
LambdaBeforeAllowTraffic → AfterAllowTraffic
ECSBeforeInstall → AfterInstall → AfterAllowTestTraffic → BeforeAllowTraffic → AfterAllowTraffic

Exam Tip: Canary = safest. AllAtOnce = fastest. appspec.yml format differs per platform. Hook order is a common exam question.