Study Guide925 words

AWS Certified Developer: Unit 3 - Deployment Strategies and CI/CD

Unit 3: Deployment

Unit 3: Deployment Strategies and CI/CD

This study guide covers the essential aspects of deploying application artifacts to AWS, including the management of CI/CD pipelines, implementation of various deployment strategies, and the use of Infrastructure as Code (IaC) to automate environment provisioning.

Learning Objectives

By the end of this chapter, you should be able to:

  • Prepare application artifacts, including dependencies and environment configurations, for AWS deployment.
  • Differentiate between deployment strategies such as Blue/Green, Canary, Rolling, and In-place.
  • Configure AWS CodeDeploy for EC2, Lambda, and ECS compute platforms.
  • Automate deployment testing using AWS SAM, API Gateway stages, and Amazon Q Developer.
  • Manage multiple environments (Dev, Test, Prod) using Lambda aliases, API Gateway stages, and AWS AppConfig.

Key Terms & Glossary

  • Artifact: A collection of software components (code, dependencies, configuration) packaged for deployment.
  • Blue/Green Deployment: A strategy where a new version (Green) is deployed alongside the old version (Blue). Traffic is shifted once the Green environment is verified.
  • Canary Deployment: A strategy where a small percentage of traffic is shifted to the new version to test performance before a full rollout.
  • Infrastructure as Code (IaC): The process of managing and provisioning computer data centers through machine-readable definition files (e.g., CloudFormation, SAM).
  • In-place Deployment: A method where the new application version is installed directly on the existing instances, often requiring downtime or reduced capacity.
  • Deployment Group: A set of individual instances or a serverless environment to which a CodeDeploy deployment is targeted.

The "Big Idea"

The core of modern cloud development is Automation and Reliability. In AWS, deployment is not just about moving code; it is about creating a repeatable, fail-safe pipeline where human error is minimized. By using CI/CD services and Infrastructure as Code, developers ensure that the environment in production is identical to the environment in testing, and that if a failure occurs, the system can automatically rollback to a known good state.

Formula / Concept Box

CodeDeploy Default Configurations (In-place)

ConfigurationLogicSuccess Threshold
AllAtOnceDeploys to all instances simultaneously.Successful if $\ge 1 instance succeeds.
HalfAtATimeDeploys to 50% of instances (rounded down).Successful if \ge 50%$ (rounded up) succeed.
OneAtATimeDeploys to one instance at a time.Successful if all instances (or all but the last) succeed.

Hierarchical Outline

  1. Preparation of Artifacts
    • Dependency Management: Packaging environment variables and container images.
    • Configuration: Using AWS AppConfig for dynamic application configuration.
  2. Testing in Environments
    • API Gateway Stages: Using dev, test, and prod endpoints for isolated testing.
    • AWS SAM: Local testing and mock event simulation using JSON payloads.
  3. Deployment Strategies
    • AWS Elastic Beanstalk: PaaS solution for rolling and blue/green updates.
    • AWS CodeDeploy: Automating updates across EC2, Lambda, and ECS.
  4. CI/CD Orchestration
    • AWS CodePipeline: Managing the workflow from source commit to production.
    • Rollbacks: Automatic restoration of previous versions upon health check failure.

Visual Anchors

CI/CD Pipeline Flow

Loading Diagram...

Blue/Green Traffic Shift

\begin{tikzpicture} \draw[thick, fill=blue!20] (0,0) circle (1.5cm) node {Blue (V1)}; \draw[thick, fill=green!20] (5,0) circle (1.5cm) node {Green (V2)}; \draw[->, ultra thick, red] (2.5,2) -- (0.5,1) node[midway, left] {Old Traffic}; \draw[->, ultra thick, blue] (2.5,2) -- (4.5,1) node[midway, right] {New Traffic}; \node at (2.5,2.5) {Load Balancer}; \end{tikzpicture}

Definition-Example Pairs

  • Lambda Alias: A pointer to a specific Lambda function version.
    • Example: Creating an alias named PROD that points to version 5, while DEV points to $LATEST.
  • Staging Variables: Key-value pairs in API Gateway stages used to change backend endpoints.
    • Example: Setting a variable lambdaAlias to v1 in the beta stage and v2 in the prod stage.
  • Infrastructure as Code (IaC): Using templates to define resources.
    • Example: An AWS SAM template defining a DynamoDB table and a Lambda function in 20 lines of YAML.

Worked Examples

Example 1: CodeDeploy HalfAtATime Calculation

Scenario: You have a deployment group with 9 EC2 instances. You use the CodeDeployDefault.HalfAtATime configuration.

  1. Deployment Step: The system rounds 9/2 down to 4. It will deploy to 4 instances in the first batch.
  2. Success Condition: The system rounds 9/2 up to 5. At least 5 instances must succeed for the entire deployment to be marked as a success.

Example 2: Lambda Canary Shifting

Scenario: You want to shift traffic to a new Lambda version gradually.

  • Step 1: Update the SAM template to include DeploymentPreference.
  • Step 2: Choose Canary10Percent5Minutes.
  • Result: 10% of traffic goes to the new version for 5 minutes. If no CloudWatch Alarms trigger, 100% of traffic is shifted.

Checkpoint Questions

  1. Which AWS service is best suited for managing environment-specific configurations without re-deploying code?
  2. In a Blue/Green deployment on ECS, how does CodeDeploy handle the transition?
  3. What is the main advantage of using an In-place deployment over Blue/Green?
  4. How does a Canary deployment differ from a Linear deployment in AWS Lambda?
Click to see answers
  1. AWS AppConfig or API Gateway Staging Variables.
  2. It creates a new task set, shifts traffic at the load balancer level, and terminates the old task set after a successful wait period.
  3. It does not require provisioning new infrastructure, which can be faster and cheaper, though it carries higher risk.
  4. Canary shifts a fixed percentage for a fixed interval once. Linear shifts a fixed percentage every N minutes until 100% is reached.

Ready to study AWS Certified Developer - Associate (DVA-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free