2.1 Deployment Strategy

Infrastructure as Code (IaC)

AWS CloudFormation

  • Template: JSON/YAML file defining resources.
  • Stack: The instantiation of a template.
  • ChangeSets: Previewing changes before applying them.
  • StackSets: Deploying stacks across multiple accounts and regions.

AWS CDK (Cloud Development Kit)

  • Concept: Write infrastructure in Python/TS/Java, compiles to CloudFormation.
  • Constructs: Reusable cloud components (L1 = Raw CFN, L2 = Curated/Best Practice, L3 = Patterns).

CI/CD Pipeline (Cheatsheet)

StageServiceFunction
SourceCodeCommit / GitHubVersion Control. Triggers pipeline on commit.
BuildCodeBuildCompiles code, runs tests, produces artifacts (Docker images, JARs). Ephemeral.
DeployCodeDeployAutomates deployment to EC2, Lambda, Fargate, or On-prem.
PipelineCodePipelineOrchestrates the workflow (Source Build Deploy).

Deployment Strategies (Deep Dive)

  • In-Place: Updates the existing instance. Downtime possible.
  • Blue/Green:
    • Blue: Current Prod.
    • Green: New Version.
    • Switch: DNS flip (Route 53) or Load Balancer weight change. Instant rollback.
    • Cost: Double the infra cost during deployment.
  • Canary: Traffic shifted in small increments (10% 50% 100%).
  • Rolling: Update a few instances at a time. Capacity reduces during update.

Configuration Management

AWS Systems Manager

  • Run Command: Execute scripts on instances without SSH.
  • State Manager: Enforce configuration (e.g., ensure antivirus is installed).
  • Patch Manager: Automate OS patching during maintenance windows.

WARNING

Exam Gotcha: OpsWorks is for Chef/Puppet. Beanstalk is for simple app deployment (Paas). Systems Manager is for general fleet management. If the Q asks about “Chef recipes”, think OpsWorks. If it asks about “Patching 1000 EC2s”, think Systems Manager.