SkillSprout
Chapter 2 · Lesson 5
Advanced
7 min read

Troubleshooting Failed Deployments and Application Storage Patterns

Overview

Deployments fail for predictable reasons: permissions, health checks, configuration, capacity and bad code. A DevOps engineer needs a method for finding the failing layer quickly and a design where storage choices do not make rollback or scaling hard.

Imagine a relay race. When the baton drops you ask which handoff failed: the pipeline stage, the build, the deploy agent, the stack update or the application health check. And you want runners who carry the baton (state) in a shared bag (S3, EFS, a database) rather than in their pockets (instance disks), so any runner can be swapped in.

The DOP-C02 guide lists troubleshooting deployment issues and application storage patterns (EFS, S3, EBS) together with mutable versus immutable deployment patterns as skills, so this lesson links them.

Key Concepts

  • CodePipeline shows the failed action and a link to details; the real error is in the provider's console (CodeBuild logs, CodeDeploy deployment events, CloudFormation stack events).
  • CloudFormation reports the first failing resource in stack events; failed creates roll back, failed updates enter UPDATE_ROLLBACK_COMPLETE, and UPDATE_ROLLBACK_FAILED needs ContinueUpdateRollback with skipped resources.
  • CodeDeploy failures come from agent problems, hook script exit codes, permissions or failed health checks; check the deployment's instance events and agent logs.
  • Immutable (replace) deployments leave the old fleet intact for rollback; mutable (in-place) deployments are faster but risk drift and partial failures.
  • EBS is block storage tied to one AZ and best for boot volumes and single-instance data; use snapshots and AMIs for portability.
  • EFS is a regional shared file system for fleets and containers (including Fargate and Lambda); S3 is object storage for assets, artifacts and logs with versioning and lifecycle.
  • Instance store is ephemeral; never keep deployment state or the only copy of data there.
  • A golden AMI bakes the application and dependencies for fast, consistent launches, versus bootstrapping at launch time with user data.

Detailed Notes

A repeatable troubleshooting path

  1. Locate the stage: CodePipeline execution history and the failed action's details.
  2. Read provider evidence: CodeBuild build log and phase details, CodeDeploy deployment lifecycle events, CloudFormation stack events (look at the oldest FAILED event), ECS service events and stopped task reason, Lambda deployment hook logs.
  3. Check identity and network: IAM roles (service role, pipeline role, instance profile), KMS key policies, VPC reachability, security groups, endpoints.
  4. Check health signals: ALB target health, CloudWatch alarms attached to the deployment, container health checks and readiness probes.
  5. Fix forward or roll back: redeploy the previous artifact or alias, or run ContinueUpdateRollback.
FailureTypical causeResolution
CodeBuild: AccessDenied downloading source or uploading artifactsService role missing S3 or KMS permissionAdd permissions; fix artifact bucket policy
CloudFormation: CREATE_FAILED with resource limitService quota or name conflictRequest quota; use generated names
CloudFormation: UPDATE_ROLLBACK_FAILEDA resource cannot return to the previous stateContinueUpdateRollback with --resources-to-skip
CodeDeploy: no instances foundTag or ASG filter mismatchCorrect the deployment group
ECS: tasks stop with CannotPullContainerErrorMissing ECR permission or no route to ECRExecution role, NAT or VPC endpoints
ECS: tasks killed by load balancerHealth check path wrong or grace period too shortTune health check and grace period
Lambda alias deployment rolled backPreTraffic hook failed or alarm triggeredReview hook logs and alarm history
Pipeline cross-account failureArtifact KMS key not sharedAdd target roles to key policy
bash
aws cloudformation describe-stack-events --stack-name web \
  --query "StackEvents[?contains(ResourceStatus,'FAILED')].[LogicalResourceId,ResourceStatusReason]" --output table
aws cloudformation continue-update-rollback --stack-name web --resources-to-skip LegacyBucket
aws deploy list-deployment-instances --deployment-id d-ABC123XYZ
aws ecs describe-tasks --cluster prod --tasks <task-arn> --query "tasks[].stoppedReason"

Mutable versus immutable deployment patterns

AspectMutable (in-place)Immutable (replace)
MechanismUpdate software on running instancesLaunch new instances/containers from a new image and swap
SpeedFast, no extra capacitySlower, needs temporary double capacity
RollbackRedeploy old revision; risk of leftoversRoute back to old fleet or alias
DriftLikely over timeMinimal
ExamplesCodeDeploy in-place, Beanstalk rollingBlue/green, Beanstalk immutable, ASG instance refresh with a new AMI

Instance refresh with a new launch template version, with MinHealthyPercentage and checkpoints, gives immutable-style rollouts for ASGs.

Storage patterns for deployable applications

NeedPatternNotes
Static assets, uploadsS3 (+CloudFront)Versioning, lifecycle, presigned URLs
Shared files across many instances or tasksEFSMount targets per AZ, access points, encryption; use throughput modes properly
Low-latency block for a single hostEBS gp3/io2AZ-bound; snapshot with Data Lifecycle Manager
Temporary scratchInstance store or Fargate ephemeral storageLost on stop or task replacement
Windows sharesFSx for WindowsSMB and AD
Session stateElastiCache or DynamoDBKeeps servers disposable
LogsCloudWatch Logs or S3 via agent/FirehoseNever rely on instance disks

Golden AMI versus bootstrap

Baking with EC2 Image Builder gives fast scale-out and reproducibility but needs a pipeline for patching and AMI rotation. User-data bootstrapping is flexible but slower and can fail at launch time (package repositories unavailable). A hybrid approach bakes the slow, stable layers and configures environment-specific values at launch from Parameter Store. Use ASG warm pools and lifecycle hooks to hide startup time.

Pitfalls

  • Deploying schema changes with the application: use expand/contract migrations so both versions run against the same database during rollout.
  • Writing to the local filesystem in containers: data vanishes on replacement; use EFS or S3.
  • Rolling back application code while the database moved on: keep changes backward compatible.

Real World Example

Scenario: a nightly release of a PHP application intermittently fails in production. Pipeline logs show the CodeDeploy action failing, but the pipeline page only says "deployment failed". The engineer opens the CodeDeploy deployment, finds the failing instance event, and reads scripts.log: the ApplicationStart hook times out because user-uploaded files live on each instance's EBS disk and the new instances are missing them.

They move uploads to S3 behind CloudFront, mount EFS for shared cache, bake an AMI with Image Builder and switch to blue/green. Rollbacks become a traffic switch back to the previous fleet.

Architecture Diagram

Failure triage path and shared storage
Architecture
AWS Cloud
CodePipelineFailed action
Logs and eventsProvider detail
Immutable fleetNew AMI

Shared state

S3
EFS

Find the failing layer, then keep state out of disposable compute.

  1. 1A pipeline action fails and the engineer opens the provider-specific details.
  2. 2Logs, stack events and health checks identify the failing layer.
  3. 3Permissions, network and configuration causes are corrected.
  4. 4A new immutable fleet is built and validated while the old fleet serves traffic.
  5. 5State stays in S3, EFS or databases so the fleet can be replaced or rolled back safely.

Best Practices

  • ✓Use provider logs and events, not only the pipeline summary, to diagnose failures.
  • ✓Prefer immutable deployments and keep the previous version available for fast rollback.
  • ✓Keep instances stateless: S3 for objects, EFS for shared files, databases or caches for state.
  • ✓Make database changes backward compatible so rollbacks do not require data restores.
  • ✓Alarm on deployment failures and stopped tasks so problems page before users notice.

Common Interview Questions

Exam Tips

DOP-C02 focus

  • "Stack stuck after a failed update rollback" = ContinueUpdateRollback.
  • "Shared file storage for a fleet or Fargate tasks" = EFS; "static content" = S3.
  • "Fastest and safest rollback" = immutable/blue-green with traffic switch, or Lambda alias.
  • "ECS task cannot pull image" = execution role permissions and network path to ECR.

Chapter quiz

Deployment Strategies · 10 questions

  1. 1.A CodePipeline execution fails in the Deploy stage with a generic message. The deployment targets Auto Scaling group instances through CodeDeploy. What is the best first step to find the root cause?

  2. 2.A web fleet stores user uploads on the root EBS volume of each instance. After switching to immutable deployments, users report missing files after every release. Which change fixes the design?

  3. 3.A CloudFormation update fails and the stack enters UPDATE_ROLLBACK_FAILED because a security group rule was deleted manually. The team wants to restore the stack to a stable state. What should they do?

  4. 4.ECS tasks in private subnets repeatedly stop with CannotPullContainerError for images in ECR. There is no NAT gateway. Which solution is the most appropriate?

  5. 5.An application needs a POSIX-compliant shared file system mounted by dozens of EC2 instances across three Availability Zones, with automatic capacity growth and no provisioning. Which storage fits?

  6. 6.A production EC2 fleet behind an ALB is deployed with CodeDeploy. The company needs the ability to roll back within seconds without reducing capacity, and to validate the new version before users reach it. Which strategy BEST fits?

  7. 7.An ECS Fargate service is updated using rolling deployments. Occasionally a new task definition references a bad image and the service keeps launching failing tasks. What should be enabled to automatically stop and revert the deployment?

  8. 8.A Lambda function behind an API must be released gradually: 10% of invocations for 10 minutes, then the rest, with automatic rollback if the error alarm fires. The team uses AWS SAM. Which configuration achieves this?

  9. 9.A team runs blue/green on Elastic Beanstalk by swapping environment URLs. After a swap, users report missing data because the new environment has an empty database. What is the root cause?

  10. 10.A company shifts traffic between two application stacks using Route 53 weighted records with a 300 second TTL. After setting the weight of the faulty stack to 0, some users still reach it for several minutes. Which change gives the MOST immediate control for future releases?

0 of 10 answered

Finished this lesson?

0 of 44 lessons done · 0% of the course