Lesson 1 of 3 Troubleshooting Deployments and Operations

Analysing Failed Deployments

Deployment failures stop delivery and sometimes break production. Most can be diagnosed quickly by reading the right evidence in the right order. This lesson gives a method for analysing failures in CodePipeline, CodeBuild, CodeDeploy and CloudFormation, lists the most common error causes for each, and explains how synthetic monitoring shows the user impact of a faulty deployment.

Learning outcomes

After completing this lesson, you will be able to:

  • Apply a systematic method to locate the failing component and evidence for a deployment failure.
  • Diagnose common CodePipeline and CodeBuild failures from execution details and logs.
  • Diagnose CloudFormation stack failures from stack events, including rollback failures and hook failures.
  • Explain how CodeDeploy evidence and synthetic monitoring results identify faulty deployments.

A Method for Deployment Failures

Pipelines chain several services, and the error shown at the top level is often generic. Working from the outside in avoids guessing.

  1. Find the failed action in the CodePipeline execution: the stage, the action, its provider and the summary error message, with a link to the underlying service.
  2. Open the underlying execution: the CodeBuild build, CodeDeploy deployment or CloudFormation stack events.
  3. Find the first error: in build phases, in the earliest failed lifecycle event, or in the first FAILED stack event; later errors are often consequences.
  4. Classify the cause: permissions (AccessDenied, not authorised), configuration (missing file, wrong path, invalid parameter), capacity or quota (limits exceeded), dependency (network, external service) or code (tests, application errors).
  5. Check what changed: the commit, the template diff, a parameter change or an AWS Health event, using CloudTrail and Config timelines.

EventBridge events and notifications for failed executions, described in the event-driven module, start this process automatically by sending the failure details to the team.

CodePipeline and CodeBuild Failures

The most common pipeline-level failures and their causes are summarised below. Build-level details are covered in the AWS CodeBuild module.

SymptomLikely cause
Source action fails with a connection errorCodeConnections connection PENDING, app access removed in the Git provider, or missing UseConnection permission
Action fails with "not authorized"Pipeline service role or action role lacks permission, or iam:PassRole is missing
Cross-account action fails reading artifactsBucket policy or KMS key policy does not allow the target account; AWS managed key used
Build fails in DOWNLOAD_SOURCEInvalid buildspec or missing source
Build fails in INSTALL, PRE_BUILD or BUILDCommand errors, test failures, missing permissions of the CodeBuild service role, or no network access from a VPC build
Build fails in UPLOAD_ARTIFACTSArtifact paths do not match the output location
Deploy action cannot find imageDetail.json or imagedefinitions.jsonThe build produced the file for the other ECS deploy action type
Execution superseded or waitingSUPERSEDED mode replaced it, a disabled transition, or a stage condition blocked entry
Lambda invoke action times outThe function did not call PutJobSuccessResult or PutJobFailureResult
Manual approval failsRejected, or no response within seven days

CloudFormation Failures

CloudFormation reports each resource's status in stack events. The status reason of the first failed resource explains the failure; subsequent Resource creation cancelled events are consequences. For nested stacks, the failure must be traced into the child stack's events. The Detect root cause feature in the console highlights the likely originating event. Common causes are listed below.

Error or stateCause and resolution
Requires capabilities [CAPABILITY_NAMED_IAM]Acknowledge IAM or AUTO_EXPAND capabilities in the deploy action or command
API: ... is not authorized / AccessDeniedThe CloudFormation service role or caller lacks permission for the resource
Resource already existsA custom name collides with an existing resource; use generated names or import the resource
Limit exceededA service quota, such as VPCs or Elastic IPs, is reached; request an increase
Resource did not receive the required number of signalscfn-signal not sent: the instance failed configuration, has no route to the CloudFormation endpoint, or the timeout is too short
Custom resource failed to stabilise / timed outThe Lambda function did not respond to the ResponseURL
Hook failureA CloudFormation Hook in FAIL mode rejected the resource configuration; the hook's message names the rule
Export cannot be updated as it is in useAnother stack imports the value
ROLLBACK_COMPLETE after creationCreation failed; fix the cause, delete the stack and create it again
UPDATE_ROLLBACK_FAILEDFix the blocking resource and use ContinueUpdateRollback, skipping resources if necessary

Rollback triggers can also roll back an update that succeeded technically because an alarm fired; the stack events show the alarm as the reason, and the investigation then moves to the application's metrics and logs.

Scenario questions

Read the deployment failure

Exam skills 5.3.1

Practise finding the cause of failed deployments.

Log in to try this activity Interactive activities are free with an account.

CodeDeploy and Synthetic Monitoring Evidence

For CodeDeploy, the deployment's error code and the failed instance's lifecycle events point to the failing step, and the agent's script log on the instance shows the script output, as described in the CodeDeploy module. Typical causes are a stopped agent, missing instance profile permissions, script errors and timeouts, health check failures in AllowTraffic, and alarm-triggered rollbacks.

Some deployments succeed technically but break user journeys. CloudWatch Synthetics canaries detect this: a canary alarm that fires after a release, combined with its screenshots, HAR files and step logs, shows which step failed and what the application returned. Comparing the canary's failure time with the deployment time in CodeDeploy, ECS or CodePipeline history and with X-Ray traces links the regression to the release. Attaching canary alarms to rollback mechanisms turns this analysis into automatic protection.

Worked example

A Stack That Never Finishes

A CloudFormation stack that creates an Auto Scaling group with a creation policy requiring three signals remains CREATE_IN_PROGRESS for 15 minutes and then fails with "received 0 SUCCESS signals out of the 3 expected". The instances run, and the application works when tested manually.

Because the application works, cfn-init probably succeeded, so the signals were not delivered. The instances are in private subnets without a NAT gateway or a CloudFormation VPC endpoint, so cfn-signal could not reach the CloudFormation endpoint. Adding an interface endpoint for CloudFormation (or a NAT gateway) fixes the signals. The team also confirms that user data passes the cfn-init exit code to cfn-signal so that real configuration failures roll back immediately.

Check yourself

A pipeline's CloudFormation deploy action fails with "Requires capabilities: [CAPABILITY_AUTO_EXPAND]". What is the cause and fix?

Show answer

The template uses a macro or transform, such as the AWS SAM transform. Add CAPABILITY_AUTO_EXPAND (with the IAM capabilities if needed) to the action's Capabilities setting.

Exam Tips

Remember for the exam

  • Work from the failed pipeline action to the underlying service, find the first error, classify it (permissions, configuration, quota, dependency, code) and check what changed.
  • In CloudFormation, the first FAILED stack event is the cause; trace into nested stacks; use ContinueUpdateRollback for UPDATE_ROLLBACK_FAILED.
  • Missing cfn-signal often means instances cannot reach the CloudFormation endpoint from private subnets.
  • Canary screenshots, HAR files and logs identify which user step a faulty deployment broke.