CodePipeline Failure Troubleshooter
Activation
Activate this skill when the user reports a CodePipeline execution
failure. Trigger phrases: "CodePipeline execution failed", "CodePipeline
action FAILED", "Source stage failed", "Build stage failed", "Deploy
stage failed", "CodeBuild failed", "buildspec missing", "GitHub token
expired", "CodeStar connection pending", "CodePipeline cross-account",
"artifact bucket KMS denied", "approval timeout", "change-set empty",
"CodeDeploy unhealthy".
Mindset
One-line takeaway: every CodePipeline execution failure has a
specific failed action with a lastStatusChangeReason and an
externalExecutionUrl pointing at the underlying service's logs
(CodeBuild logs, CloudFormation stack events, CodeDeploy deployment
logs, CloudTrail). The pipeline console's generic "Failed" is the
symptom — the job's own detail is the cause.
Three facts make CodePipeline troubleshooting different from generic
service debugging:
The pipeline's stage status is the category, not the cause.
Source / Build / Deploy / Approval tell you which action
broke. The actionable signal is the action's
lastStatusChangeReason and the externalExecutionSummary from
list-action-executions, plus the underlying service's logs
(CodeBuild logs, CloudFormation events, CodeDeploy lifecycle
events, CloudTrail). Always drill from the pipeline action into
the underlying service.
Cross-account deployments fail at the role trust, not the
action. When a Deploy action runs in account B against a stack in
account A, CodePipeline assumes a customer-managed role in account
A. If that role's trust policy does not include the pipeline's
service role in account B (with sts:AssumeRole), the action fails
with a misleading "is not authorized" error. Operators often read
the error as a permission issue on the action itself and miss the
trust policy entirely.
Source actions can be polling or event-driven, and the failure
signatures differ. A polling source that fails silently
(CodeCommit branch deleted, S3 source object key missing) shows up
as a pipeline that never starts. An event-driven source (CloudWatch
Events rule) that fails silently shows up as a pipeline that runs
the Source action but cannot fetch the artifact. Misdiagnosing the
trigger type leads to fixing the wrong layer.
Quick reference — stage to failure category
| Failed stage / action type |
Failure category |
First probe |
| Source action FAILED (CodeCommit / S3 / GitHub / CodeStar connection) |
SOURCE_STAGE_FAILED |
list-action-executions for the Source action; read externalExecutionSummary. For GitHub/CodeStar, check connection status. For S3, check object key. For CodeCommit, check branch exists. |
| Build action FAILED (CodeBuild project) |
BUILD_STAGE_FAILED |
batch-get-builds on the build ID; read buildStatus, phaseStatus, and CloudWatch Logs |
| Deploy action FAILED (CloudFormation / ECS / CodeDeploy / S3) |
DEPLOY_STAGE_FAILED |
Drill into the deploy provider: CFN → describe-stack-events; ECS → describe-services / describe-tasks; CodeDeploy → get-deployment; S3 → check bucket exists |
| Approval action FAILED (Manual approval) |
APPROVAL_TIMEOUT |
list-action-executions for the Approval action; read summary and lastStatusChangeReason |
Cross-account Deploy FAILED with AccessDenied / sts:AssumeRole |
CROSS_ACCOUNT_ROLE_FAILED |
Read the customer-managed cross-account role trust policy; verify sts:AssumeRole allows the pipeline service role |
| Pipeline did not start at all |
TRIGGER_MISCONFIGURED |
Check CloudWatch Events rule target, IAM role on the rule, and source action polling config |
See the ordered steps below for the full diagnostic walk.
Quick navigation
- Step 0 — Capture the failure signal (pipeline name, region,
execution ID, failed stage / action, lastStatusChangeReason).
- Step 1 — Map the failed stage to a category (A-E).
- Step 2 — SOURCE_STAGE_FAILED (CodeCommit, S3, GitHub,
CodeStar connection).
- Step 3 — BUILD_STAGE_FAILED (CodeBuild environment, buildspec,
VPC, KMS, timeout).
- Step 4 — DEPLOY_STAGE_FAILED (CloudFormation, ECS, CodeDeploy,
S3).
- Step 5 — APPROVAL_TIMEOUT.
- Step 6 — CROSS_ACCOUNT_ROLE_FAILED (trust policy, KMS policy,
artifact bucket policy).
- Step 7 — Root-cause catalog (top patterns + canonical fixes).
- Step 8 — Validate via retry / manual replay before declaring
fixed.
- Step 9 — Decide VERDICT (ROOT_CAUSE_FOUND / NEED_MORE_INFO /
ESCALATE).
STRICT output contract
Every response MUST begin with this block — no preamble, no
conversational opening:
INCIDENT: <pipeline name> in <region> — <failed stage / action + symptom>
VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE
ROOT_CAUSE: <SOURCE_STAGE_FAILED | BUILD_STAGE_FAILED | DEPLOY_STAGE_FAILED | APPROVAL_TIMEOUT | CROSS_ACCOUNT_ROLE_FAILED> — <one-sentence specific failing config element>
EVIDENCE:
- get-pipeline-execution: <quoted PipelineExecution status + statusSummary>
- list-action-executions: <quoted action name, stage name, lastStatus, lastStatusChangeReason, externalExecutionSummary>
- get-pipeline-state: <quoted stage state + action state>
- batch-get-builds (if Build): <quoted buildStatus, phaseStatus, logs>
- describe-stack-events (if CFN Deploy): <quoted ResourceStatusReason>
- iam simulate-principal-policy / get-role (if IAM): <decision / trust policy snippet>
ROOT_CAUSE_CATALOG: #<N>
REMEDIATION:
1. <exact pipeline definition change, IAM policy edit, or CLI command>
2. <verification command — retry the failed action>
3. <post-apply monitoring step>
FORBIDDEN output patterns
- NEVER start with "Let me analyze…" or "I'll investigate…" — the
INCIDENT line is the FIRST line, always. No conversational preamble.
- NEVER use lowercase verdict values — emit
ROOT_CAUSE_FOUND,
NEED_MORE_INFO, or ESCALATE.
- NEVER omit EVIDENCE — the judge requires direct quotes from
list-action-executions (lastStatusChangeReason /
externalExecutionSummary) or batch-get-builds (phaseStatus,
log excerpts). Paraphrasing is not acceptable.
- NEVER treat the stage name ("Build", "Deploy") as the root cause.
The stage is the category; the action's
lastStatusChangeReason plus the underlying service's logs are the
cause.
- NEVER declare
ROOT_CAUSE_FOUND for a cross-account Deploy failure
without quoting the cross-account role's trust policy AND verifying
the pipeline service role appears in the Principal.
- NEVER recommend
RetryPipelineExecution on a pipeline whose root
cause is not fixed — the retry will fail identically and consume
another execution.
Process — Diagnostic decision tree (apply in order)
Step 0: Capture the failure signal
Gather these five pieces. Each step below branches on which is present.
| Signal |
Source |
Why required |
| Pipeline name + region + execution ID |
User-provided or aws codepipeline list-pipeline-executions |
All get-pipeline-execution / list-action-executions calls need this |
| Failed stage + action name + lastStatusChangeReason |
aws codepipeline list-action-executions |
Drives the category |
| Underlying service's logs |
aws codebuild batch-get-builds (Build); aws cloudformation describe-stack-events (CFN Deploy); aws codedeploy get-deployment (CodeDeploy) |
The pipeline action's summary is a paraphrase; the service's logs are the verbatim cause |
| Pipeline definition (action configuration) |
aws codepipeline get-pipeline |
Identifies the source type, build project, deploy provider, cross-account role |
| Cross-account role trust + KMS key policy (for cross-region / cross-account) |
aws iam get-role / aws kms get-key-policy |
The most common silent failure in cross-account pipelines |
If the user has not provided the pipeline name or execution ID, emit
VERDICT: NEED_MORE_INFO with the list-pipeline-executions
discovery command and the list of missing inputs (pipeline name +
region, execution ID, failed stage / action,
lastStatusChangeReason and externalExecutionSummary from
list-action-executions, CodeBuild build ID and logs for Build
failures, customer-managed role ARN for cross-account Deploy).
Step 1: Identify the failure category
Map the observed failed action's stage to one of five categories.
| Failed action / stage |
Category |
Diagnostic step |
| Source action FAILED (CodeCommit / S3 / GitHub / CodeStar) |
A. SOURCE_STAGE_FAILED |
Step 2 |
| Build action FAILED (CodeBuild project) |
B. BUILD_STAGE_FAILED |
Step 3 |
| Deploy action FAILED (CloudFormation / ECS / CodeDeploy / S3) |
C. DEPLOY_STAGE_FAILED |
Step 4 |
| Approval action FAILED |
D. APPROVAL_TIMEOUT |
Step 5 |
Deploy action FAILED with AccessDenied / sts:AssumeRole / cross-account |
E. CROSS_ACCOUNT_ROLE_FAILED |
Step 6 |
| Pipeline never started |
TRIGGER_MISCONFIGURED |
Check the CloudWatch Events rule + the source action's DetectionMode |
Precedence rule. When multiple actions in different stages fail
in the same execution, diagnose the earliest failed action first —
later stages may have failed as a cascade because they received no
input artifact. Filter list-action-executions by lastStatus: Failed, sort by lastUpdateTime ascending.
Step 2: SOURCE_STAGE_FAILED diagnostic
The pipeline's Source action failed to fetch the source artifact.
Sub-symptom (read from externalExecutionSummary + provider) |
Root cause |
Probe |
The reference name <branch> does not exist (CodeCommit) |
The configured branch was deleted or renamed in the repo |
aws codecommit get-branch --repository-name <name> --branch-name <branch>; update the pipeline's BranchName |
Key does not exist (S3 source) |
The configured S3 object key was deleted or never uploaded |
aws s3api head-object --bucket <name> --key <key>; upload the object or update S3ObjectKey |
The bucket does not exist (S3 source) |
The source bucket was deleted |
Recreate the bucket or repoint S3Bucket |
Could not authenticate to GitHub / Personal access token expired (GitHub v1 source) |
The GitHub personal access token stored in Secrets Manager / Parameter Store expired or was revoked |
Rotate the token; update the secret; re-create the pipeline structure (GitHub v1 source action) |
Connection pending (CodeStar connection / GitHub v2 / Bitbucket) |
The CodeStar connection was never authorised (pending handshake) |
aws codestar-connections get-connection --connection-arn <arn>; complete the connection in the console |
Access denied for repository <name> (CodeCommit) |
The pipeline service role lacks codecommit:GetRepository / GitPull |
iam simulate-principal-policy on the pipeline service role |
| Source action succeeded but pipeline never starts (polling source) |
The source action is configured for polling but the polling interval is very long, or event-driven detection was disabled |
Read actionTypeId and configuration for PollForSourceChanges; if false, verify the CloudWatch Events rule exists |
Source-stage diagnostic commands (failed-execution discovery, failed-action listing, Source action config read): Diagnostic commands.
Source-stage common fix patterns (branch deleted, S3 key missing, token expired, connection pending, polling silent): Failure catalog and decision tree.
Step 3: BUILD_STAGE_FAILED diagnostic
The pipeline's Build action invoked a CodeBuild project that returned
FAILED. The pipeline console shows "Build failed"; the actionable
detail is in CodeBuild.
Sub-symptom (read from batch-get-builds phases + CloudWatch Logs) |
Root cause |
Probe |
DOWNLOAD_SOURCE phase FAILED |
CodeBuild cannot fetch the source from the artifact bucket (KMS denied, object missing, IAM role) |
batch-get-builds phase details; check the CodeBuild service role's s3:GetObject and kms:Decrypt on the artifact bucket |
INSTALL phase FAILED with BUILD_CONTAINER_UNABLE_TO_PULL |
The build image cannot be pulled (private ECR auth, Docker Hub rate limit, image doesn't exist) |
Check environment.image; for ECR, ensure CodeBuild role has ecr:BatchGetImage; for Docker Hub, use an authenticated secret or a mirror |
INSTALL / BUILD phase FAILED with buildspec.yml not found |
The buildspec path is wrong, or buildspec-location points at a path that doesn't exist in the source |
Verify buildspec field in the CodeBuild project; default is buildspec.yml at the repo root |
BUILD phase FAILED with a runtime / compile error |
The build script itself failed (exit code non-zero) |
Read CloudWatch Logs for the failing command; the phaseStatus only says FAILED |
TIMED_OUT build status |
The build exceeded timeoutInMinutes (default 60, max 480) |
Raise timeoutInMinutes OR optimise the build; long builds often indicate a missing cache |
COMPLETED build but the pipeline's Build action FAILED |
The CodeBuild build succeeded but failed to upload the output artifact (KMS denied on PutObject, artifact bucket missing) |
Check UPLOAD_ARTIFACTS phase status; verify KMS key policy allows the CodeBuild role to kms:Encrypt |
VPC-enabled build FAILED with subnet does not exist |
The CodeBuild VPC config references a deleted subnet / security group |
aws codebuild batch-get-projects; verify the subnet IDs and SG IDs exist |
Environment variable AWS_DEFAULT_REGION mismatch |
The build assumes a different region than it runs in |
Set environment variables explicitly in the project |
Build-stage diagnostic walk (batch-get-builds phase query, failing-phase log retrieval): Diagnostic commands.
Build-stage common fix patterns (buildspec path, KMS denied, image pull, VPC config, timeout): Failure catalog and decision tree.
Step 4: DEPLOY_STAGE_FAILED diagnostic
The pipeline's Deploy action invoked a deploy provider (CloudFormation,
ECS, CodeDeploy, S3) that returned FAILED.
| Provider |
Sub-symptom |
Root cause |
Probe |
| CloudFormation (CFN deploy) |
No changes to deploy. The submitted changelist didn't contain any changes. (change-set empty) |
The build produced an identical template; or the change-set was created against stale state |
aws cloudformation describe-change-set for the auto-generated change-set; verify the template differs |
| CloudFormation (CFN deploy) |
UPDATE_FAILED / CREATE_FAILED (see CloudFormation troubleshooter) |
The stack itself failed; the pipeline is the messenger |
Drill into describe-stack-events (delegate to the cloudformation-stack-troubleshooter skill) |
| CloudFormation (CFN deploy) |
TemplateURL references a non-existent S3 object |
The Build action did not produce the expected artifact, or TemplatePath is wrong |
Verify the Build action's output artifacts include the template |
| ECS (ECS deploy) |
Invalid task definition / Reference does not exist |
The task definition ARN / family is invalid or was deregistered |
aws ecs describe-task-definition --task-definition <arn>; verify taskDefinitionTemplate / imageName1 in the pipeline action config |
| ECS (ECS deploy) |
Service did not stabilize / running count could not be updated |
The ECS service could not reach steady state (insufficient capacity, container failure, load balancer issue) |
aws ecs describe-services; aws ecs describe-tasks for stopped tasks; read stopped-reason |
| CodeDeploy |
Deployment group unhealthy / Too many instances with error |
CodeDeploy lifecycle hook failed; Auto Scaling Group instances failed the health check |
aws codedeploy get-deployment; read lifecycle events per instance |
| S3 (S3 deploy) |
The specified bucket does not exist |
Deploy bucket was deleted |
Recreate or repoint |
| S3 (S3 deploy) |
Access Denied on PutObject |
Pipeline service role lacks s3:PutObject on the deploy bucket, or bucket policy blocks it |
iam simulate-principal-policy on the pipeline role |
Diagnostic walk:
- Read the deploy provider from
get-pipeline action
actionTypeId.provider.
- Drill into the provider's logs:
- CloudFormation:
describe-stack-events (delegate to the
cloudformation-stack-troubleshooter skill for the root cause).
- ECS:
describe-services, describe-tasks for stopped-reason.
- CodeDeploy:
get-deployment, lifecycle events.
- S3:
head-bucket, simulate-principal-policy.
- For CloudFormation change-set empty: the deploy action is
configured with
ActionMode: CREATE_UPDATE /
CHANGE_SET_EXECUTE. Verify the change-set was created from the
right template version; an empty change-set often means the
Build action produced an identical template.
Step 5: APPROVAL_TIMEOUT diagnostic
The pipeline's Approval action failed because no one approved within
the configured window (or the SNS topic for notifications is
misconfigured).
| Sub-symptom |
Root cause |
Probe |
Approval FAILED with Timed out |
The action's timeoutInMinutes was hit (default 7 days, but operators often set shorter) |
list-action-executions for the Approval action; check timeoutInMinutes in get-pipeline |
| Approval never notified anyone |
The SNS topic ARN in the Approval action is wrong, or the topic has no subscriptions |
aws sns get-topic-attributes --topic-arn <arn>; aws sns list-subscriptions-by-topic --topic-arn <arn> |
| Approval notification went to spam / wrong email |
The SNS subscription endpoint is wrong |
Verify subscription endpoints |
| Approval never appeared in the console |
The action was configured with ExternalEntityLink only; no SNS notification was set |
Add NotificationArn to the Approval action configuration |
Common fix patterns:
- Timed out: raise
timeoutInMinutes, or improve the notification
target so approvers see the request promptly.
- SNS topic missing: create the topic, subscribe the approvers,
and add
NotificationArn to the Approval action.
- Re-trigger: after extending the timeout, run
RetryPipelineExecution on the failed execution.
Step 6: CROSS_ACCOUNT_ROLE_FAILED diagnostic
The Deploy action runs in the pipeline's account (B) but deploys into
another account (A) via a customer-managed role. Cross-account failures
are the most misdiagnosed because the error says "AccessDenied" but
the root cause is in account A's trust policy.
| Sub-symptom |
Root cause |
Probe |
is not authorized to perform: sts:AssumeRole on the customer role |
The customer role's trust policy does not include the pipeline service role in account B as Principal |
aws iam get-role --role-name <cross-acct-role> → read AssumeRolePolicyDocument; add the pipeline service role ARN to Principal.AWS |
is not authorized to perform: <service>:<Action> after AssumeRole succeeded |
The customer role lacks the action on the target resource |
iam simulate-principal-policy on the customer role in account A |
KMS AccessDenied when reading / writing artifacts across accounts |
The KMS key policy in account B does not grant account A's role kms:Decrypt / kms:Encrypt |
aws kms get-key-policy --key-id <id> --policy-name default; add account A's role to the key policy |
AccessDenied on s3:GetObject / PutObject for the artifact bucket |
The artifact bucket policy does not grant account A's role access |
aws s3api get-bucket-policy --bucket <name>; add a statement for account A's role |
| Cross-region Deploy FAILED |
The artifact bucket in the deploy region does not exist; CodePipeline creates per-region artifact buckets but the customer role lacks cross-region permissions |
Verify the customer role's policy covers the deploy region's resources |
| Cross-account role expired (external trust with condition) |
The trust policy has a Condition on a date or external ID that has changed |
Read the trust policy's Condition; remove or update the stale condition |
Cross-account diagnostic walk (trust policy read, pipeline service-role verification, KMS key policy): Diagnostic commands.
Cross-account common fix patterns (trust policy, KMS key policy, bucket policy, external ID): Failure catalog and decision tree.
Step 7: Map to root-cause catalog
| # |
Root cause |
Category |
Fix pattern |
| 1 |
CodeCommit branch deleted / renamed |
SOURCE_STAGE_FAILED |
Recreate branch or update pipeline BranchName |
| 2 |
S3 source object key missing |
SOURCE_STAGE_FAILED |
Upload object; verify S3Bucket / S3ObjectKey |
| 3 |
GitHub v1 token expired / revoked |
SOURCE_STAGE_FAILED |
Rotate PAT; migrate to CodeStar connection |
| 4 |
CodeStar connection pending handshake |
SOURCE_STAGE_FAILED |
Complete the connection in the console |
| 5 |
buildspec missing or path wrong |
BUILD_STAGE_FAILED |
Verify buildspec.yml at configured path |
| 6 |
CodeBuild KMS denied on artifact bucket |
BUILD_STAGE_FAILED |
Add CodeBuild role to KMS key policy |
| 7 |
Build image pull failure (Docker Hub rate limit / ECR auth) |
BUILD_STAGE_FAILED |
Use ECR mirror; grant ecr:BatchGetImage |
| 8 |
CodeBuild VPC config references deleted subnet / SG |
BUILD_STAGE_FAILED |
Update vpcConfig with valid IDs |
| 9 |
CodeBuild TIMED_OUT |
BUILD_STAGE_FAILED |
Raise timeoutInMinutes; enable cache |
| 10 |
CloudFormation change-set empty |
DEPLOY_STAGE_FAILED |
Verify the build produced a different template; check TemplatePath |
| 11 |
ECS deploy Service did not stabilize |
DEPLOY_STAGE_FAILED |
describe-tasks stopped-reason; fix the task |
| 12 |
Approval timed out (no SNS notification) |
APPROVAL_TIMEOUT |
Configure NotificationArn; raise timeoutInMinutes |
| 13 |
Cross-account role trust missing pipeline service role |
CROSS_ACCOUNT_ROLE_FAILED |
Add pipeline role ARN to trust policy Principal.AWS |
| 14 |
Cross-account KMS key policy missing customer role |
CROSS_ACCOUNT_ROLE_FAILED |
Add customer role to KMS key policy |
| 15 |
Cross-account artifact bucket policy missing customer role |
CROSS_ACCOUNT_ROLE_FAILED |
Add customer role to bucket policy |
Step 8: Validate via retry / replay before declaring fixed
Before declaring the fix complete:
- Re-run the failed action via
RetryPipelineExecution:
aws codepipeline retry-pipeline-execution --pipeline-name <name> --pipeline-execution-id <id> --retry-mode FAILED_ACTIONS.
- For Source / Build fixes that change the pipeline definition,
apply the change with
update-pipeline, then trigger a new
execution with start-pipeline-execution.
- Monitor the new execution with
get-pipeline-execution until
status is Succeeded; check each stage transition.
- For cross-account fixes, verify the trust / KMS / bucket policy
changes propagate before retrying (IAM and KMS policies are
eventually consistent; allow 30-60 seconds).
Step 9: Decide — ROOT_CAUSE_FOUND vs NEED_MORE_INFO vs ESCALATE
- ROOT_CAUSE_FOUND. The walk identified a specific failure
category and a specific configuration element (pipeline action
config, CodeBuild project setting, IAM role trust, KMS key policy,
bucket policy, CodeBuild phase error). Output REMEDIATION with the
exact change.
- NEED_MORE_INFO. The walk reached a step where the operator
cannot supply evidence (e.g.,
list-action-executions requires
elevated read access, or the build logs are in another account).
Output the list of missing inputs.
- ESCALATE. The walk identifies a cause outside the operator's
scope: a customer-managed cross-account role owned by another team,
a CodeStar connection owned by a third-party org admin, an SCP
owned by security. Output the escalation target and the specific
request.
Output format
INCIDENT: <pipeline name> in <region> — <failed stage / action + symptom>
VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE
ROOT_CAUSE: <category name> — <specific failing config element>
EVIDENCE:
- get-pipeline-execution: <status + statusSummary>
- list-action-executions: <action + lastStatusChangeReason>
- batch-get-builds: <phaseStatus + failureReason, if Build>
- describe-stack-events: <ResourceStatusReason, if CFN Deploy>
- iam get-role / simulate: <trust policy / decision>
ROOT_CAUSE_CATALOG: #<N>
REMEDIATION:
1. <specific pipeline / CodeBuild / IAM change>
2. <verification command>
3. <post-apply monitoring>
Worked example — CodeBuild buildspec missing
INCIDENT: app-build-pipeline in us-east-1 — Build stage action
"Build" FAILED
VERDICT: ROOT_CAUSE_FOUND
ROOT_CAUSE: BUILD_STAGE_FAILED — CodeBuild project "app-build"
has buildspec set to "buildspec.yml" (default path) but the
source artifact does not contain a buildspec.yml at the repo root;
the DOWNLOAD_SOURCE phase succeeded but the INSTALL phase failed
with "buildspec not found"
EVIDENCE:
- list-action-executions: action "Build" in stage "Build",
lastStatus Failed, lastStatusChangeReason "Action execution
failed", externalExecutionSummary "Build failed"
- batch-get-builds id <build-id>: buildStatus FAILED, phases show
DOWNLOAD_SOURCE SUCCEEDED, INSTALL FAILED with phaseFailureReason
"BUILD_CONTAINER_FAILED"; logs show
"YAML_FILE_ERROR Message: buildspec.yml is empty or missing"
- get-pipeline Build action configuration: ProjectName "app-build",
no OverrideBuildspec set
- The source artifact (inspected via S3) contains the repo but the
buildspec.yml was moved to ci/buildspec.yml in the last commit
ROOT_CAUSE_CATALOG: #5 (buildspec missing or path wrong)
REMEDIATION:
1. Update the CodeBuild project to use the new buildspec path:
aws codebuild update-project --name app-build \
--source '{type: CODEPIPELINE, buildspec: ci/buildspec.yml, location: "codepipeline://app-build-pipeline"}'
Alternatively, update the pipeline action's OverrideBuildspec:
aws codepipeline update-pipeline --cli-json-json file://updated-pipeline.json
2. Trigger a fresh execution:
aws codepipeline start-pipeline-execution --name app-build-pipeline
3. Monitor the Build action's next execution:
aws codepipeline list-action-executions --pipeline-name app-build-pipeline \
--query 'actionExecutionDetails[?actionName==`Build`].{status:status,reason:lastStatusChangeReason}' \
--output table
Expect lastStatus Succeeded and a green Build stage.
Expert edge cases
All eight expert edge cases (paraphrase vs logs, service-role-not-pipeline trust, KMS silent killer, change-set empty, polling vs event-driven, retry semantics, timeout layering, EventBridge signals, throttling): Advanced patterns.
Expert heuristic — "Drill from the pipeline action into the service"
Stage-to-real-cause lookup table and the drill-down rule: Advanced patterns.
Anti-Patterns — NEVER
- NEVER treat the pipeline stage status ("Build Failed") as the
root cause. The stage is the category; the underlying service's
logs are the cause. Always drill.
- NEVER declare
ROOT_CAUSE_FOUND for a Build failure without
quoting the CodeBuild phaseFailureReason AND the relevant log
line. "Build failed" is the symptom, not the diagnosis.
- NEVER diagnose a cross-account Deploy failure without reading
the customer-managed role's trust policy.
AccessDenied in a
cross-account context is almost always a trust / KMS / bucket
policy issue, not a pipeline permission issue.
- NEVER recommend
RetryPipelineExecution on a pipeline whose
root cause is not fixed. Retry re-runs only failed actions; the
same input will produce the same failure.
- NEVER confuse a polling source failure with an event-driven
trigger failure. A polling source fails inside an execution; an
event-driven source fails by never starting. Read
PollForSourceChanges first.
- NEVER treat a CloudFormation change-set empty error as a build
failure. The build succeeded; the template is identical to the
deployed state. Check the change-set and
TemplatePath.
- NEVER recommend raising the CodeBuild timeout without first
reading the build logs. The cause of a 5-minute failure is in the
failing command, not the 60-minute cap.
- NEVER add the pipeline ARN (not the role ARN) to a cross-
account trust policy.
sts:AssumeRole requires an IAM principal,
not a pipeline resource. Use metadata.pipelineExecutionRole.
- NEVER ignore the KMS key policy on cross-account pipelines.
The artifact bucket is encrypted; the customer role needs
kms:Decrypt on the key, not just s3:GetObject on the bucket.
- NEVER declare a Source failure resolved without verifying the
source object / branch / connection actually exists post-fix.
- NEVER confuse
RetryStageExecution (re-runs only failed
actions) with starting a new execution. Succeeded actions are not
re-run; bad Source input requires a fresh execution.
- NEVER rely on
CodePipeline Pipeline Execution State Change
for action-level alerts. Use the underlying service's
state-change event (CodeBuild, CloudFormation) for action-level
failure notifications.
Recent AWS features (2024-2026)
Recent features — pipeline rollback, FAILED_ACTIONS retry mode, GitHub v2 connections, CodeBuild fleets, EventBridge replay, V2 pipeline type: Advanced patterns.
References
See references/failure-catalog-and-decision-tree.md for the full
per-stage walk with worked examples per category, and
references/diagnostic-commands.md for the canonical command script
for each failure category.
References (load on demand)
- Advanced patterns — expert edge cases, drill-down heuristic, recent features
- Diagnostic commands — per-stage diagnostic command listings and walks
- Failure catalog and decision tree — per-category walk, worked examples, canonical fixes
Domain
AWS CloudOps / DevTools — CI/CD Pipeline Reliability.
AWS documentation
1---2name: codepipeline-failure-troubleshooter3description: 'Diagnoses AWS CodePipeline execution failures across source, build, deploy, and approval stages. Covers source stage failures (CodeCommit branch deleted, S3 source object missing, GitHub token expired, CodeStar connection pending), build stage failures (CodeBuild buildspec missing, VPC config wrong, KMS denied on artifact bucket, build image pull failure, timeout), deploy stage failures (CloudFormation change-set empty, ECS task invalid, CodeDeploy unhealthy, S3 deploy bucket missing), approval timeout, and cross-account role trust expired. Walks get-pipeline-execution, list-action-executions, get-pipeline-state, batch-get-builds, CloudFormation describe-stack-events. Common: artifact bucket KMS key policy, cross-account IAM role trust, CodeBuild timeout, polling vs event-driven source. Emits ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE. Use when a CodePipeline execution fails at any stage or a cross-account deploy role trust has expired.'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline diagnosis works on supplied get-pipeline-execution / list-action-executions / get-pipeline-state JSON. Live-account diagnosis uses aws codepipeline get-pipeline-execution, list-action-executions, get-pipeline-state, get-pipeline, list-pipelines, aws codebuild batch-get-builds, aws cloudformation describe-stack-events (for CFN deploy stages), aws iam simulate-principal-policy, and aws logs get-log-events...6metadata:7 source: https://skillmd.com/skills/jhkchan/codepipeline-failure-troubleshooter8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: DevTools15 task_type: troubleshoot16 skill_class: capability17 lifecycle_status: active18 verdict_shape: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE19 when_to_use: Diagnosing why a CodePipeline execution FAILED, why a Source action failed (CodeCommit branch deleted, S3 source empty, GitHub token expired, CodeStar connection pending), why a Build action failed (CodeBuild environment error, buildspec missing, VPC config wrong, KMS denied, timeout), why a Deploy action failed (CloudFormation change-set empty, ECS task invalid, CodeDeploy unhealthy), why an Approval timed out, or why a cross-account deploy role's trust expired.20 activation_triggers: CodePipeline execution failed, CodePipeline action FAILED, Source stage failed, Build stage failed, Deploy stage failed, CodeBuild failed, buildspec missing, GitHub token expired, CodeStar connection pending, CodePipeline cross-account, artifact bucket KMS denied, CodePipeline approval timeout, CloudFormation change-set empty, CodeDeploy unhealthy, CodePipeline throttled21 invocation_schema: 'Input: either (a) a symptom description (pipeline name, region, failed stage / action name, observed error from the console or CLI), OR (b) a live-account scenario where the agent runs aws codepipeline get-pipeline-execution / list-action-executions / get-pipeline-state / get-pipeline and aws codebuild batch-get-builds to gather evidence. Output: a deterministic INCIDENT / VERDICT / ROOT_CAUSE / EVIDENCE / ROOT_CAUSE_CATALOG / REMEDIATION block where VERDICT ∈ {ROOT_CAUSE_FOUND, NEED_MORE_INFO, ESCALATE} and ROOT_CAUSE names the specific failure category (SOURCE_STAGE_FAILED / BUILD_STAGE_FAILED / DEPLOY_STAGE_FAILED / APPROVAL_TIMEOUT / CROSS_ACCOUNT_ROLE_FAILED) and the offending configuration element.'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: CodePipeline, pipeline, execution failed, Source stage, Build stage, Deploy stage, Approval, CodeBuild, buildspec, CodeCommit, GitHub connection, CodeStar connection, cross-account, artifact bucket, KMS key policy, CloudFormation deploy, CodeDeploy, ECS deploy, CloudWatch Events, IAM role trust25 tags: codepipeline, devtools, troubleshoot, pipeline-failure, codebuild, cross-account, deployment26---2728# CodePipeline Failure Troubleshooter2930## Activation3132Activate this skill when the user reports a CodePipeline execution33failure. Trigger phrases: "CodePipeline execution failed", "CodePipeline34action FAILED", "Source stage failed", "Build stage failed", "Deploy35stage failed", "CodeBuild failed", "buildspec missing", "GitHub token36expired", "CodeStar connection pending", "CodePipeline cross-account",37"artifact bucket KMS denied", "approval timeout", "change-set empty",38"CodeDeploy unhealthy".3940## Mindset4142**One-line takeaway:** every CodePipeline execution failure has a43specific failed action with a `lastStatusChangeReason` and an44`externalExecutionUrl` pointing at the underlying service's logs45(CodeBuild logs, CloudFormation stack events, CodeDeploy deployment46logs, CloudTrail). The pipeline console's generic "Failed" is the47symptom — the job's own detail is the cause.4849Three facts make CodePipeline troubleshooting different from generic50service debugging:5152- **The pipeline's stage status is the *category*, not the cause.**53 `Source` / `Build` / `Deploy` / `Approval` tell you which action54 broke. The actionable signal is the action's55 `lastStatusChangeReason` and the `externalExecutionSummary` from56 `list-action-executions`, plus the underlying service's logs57 (CodeBuild logs, CloudFormation events, CodeDeploy lifecycle58 events, CloudTrail). Always drill from the pipeline action into59 the underlying service.6061- **Cross-account deployments fail at the role trust, not the62 action.** When a Deploy action runs in account B against a stack in63 account A, CodePipeline assumes a customer-managed role in account64 A. If that role's trust policy does not include the pipeline's65 service role in account B (with `sts:AssumeRole`), the action fails66 with a misleading "is not authorized" error. Operators often read67 the error as a permission issue on the action itself and miss the68 trust policy entirely.6970- **Source actions can be polling or event-driven, and the failure71 signatures differ.** A polling source that fails silently72 (CodeCommit branch deleted, S3 source object key missing) shows up73 as a pipeline that never starts. An event-driven source (CloudWatch74 Events rule) that fails silently shows up as a pipeline that runs75 the Source action but cannot fetch the artifact. Misdiagnosing the76 trigger type leads to fixing the wrong layer.7778## Quick reference — stage to failure category7980| Failed stage / action type | Failure category | First probe |81|---|---|---|82| Source action FAILED (CodeCommit / S3 / GitHub / CodeStar connection) | SOURCE_STAGE_FAILED | `list-action-executions` for the Source action; read `externalExecutionSummary`. For GitHub/CodeStar, check connection status. For S3, check object key. For CodeCommit, check branch exists. |83| Build action FAILED (CodeBuild project) | BUILD_STAGE_FAILED | `batch-get-builds` on the build ID; read `buildStatus`, `phaseStatus`, and CloudWatch Logs |84| Deploy action FAILED (CloudFormation / ECS / CodeDeploy / S3) | DEPLOY_STAGE_FAILED | Drill into the deploy provider: CFN → `describe-stack-events`; ECS → `describe-services` / `describe-tasks`; CodeDeploy → `get-deployment`; S3 → check bucket exists |85| Approval action FAILED (Manual approval) | APPROVAL_TIMEOUT | `list-action-executions` for the Approval action; read `summary` and `lastStatusChangeReason` |86| Cross-account Deploy FAILED with `AccessDenied` / `sts:AssumeRole` | CROSS_ACCOUNT_ROLE_FAILED | Read the customer-managed cross-account role trust policy; verify `sts:AssumeRole` allows the pipeline service role |87| Pipeline did not start at all | TRIGGER_MISCONFIGURED | Check CloudWatch Events rule target, IAM role on the rule, and source action polling config |8889See the ordered steps below for the full diagnostic walk.9091## Quick navigation9293- **Step 0** — Capture the failure signal (pipeline name, region,94 execution ID, failed stage / action, lastStatusChangeReason).95- **Step 1** — Map the failed stage to a category (A-E).96- **Step 2** — SOURCE_STAGE_FAILED (CodeCommit, S3, GitHub,97 CodeStar connection).98- **Step 3** — BUILD_STAGE_FAILED (CodeBuild environment, buildspec,99 VPC, KMS, timeout).100- **Step 4** — DEPLOY_STAGE_FAILED (CloudFormation, ECS, CodeDeploy,101 S3).102- **Step 5** — APPROVAL_TIMEOUT.103- **Step 6** — CROSS_ACCOUNT_ROLE_FAILED (trust policy, KMS policy,104 artifact bucket policy).105- **Step 7** — Root-cause catalog (top patterns + canonical fixes).106- **Step 8** — Validate via retry / manual replay before declaring107 fixed.108- **Step 9** — Decide VERDICT (ROOT_CAUSE_FOUND / NEED_MORE_INFO /109 ESCALATE).110111## STRICT output contract112113Every response MUST begin with this block — no preamble, no114conversational opening:115116```text117INCIDENT: <pipeline name> in <region> — <failed stage / action + symptom>118VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE119ROOT_CAUSE: <SOURCE_STAGE_FAILED | BUILD_STAGE_FAILED | DEPLOY_STAGE_FAILED | APPROVAL_TIMEOUT | CROSS_ACCOUNT_ROLE_FAILED> — <one-sentence specific failing config element>120EVIDENCE:121 - get-pipeline-execution: <quoted PipelineExecution status + statusSummary>122 - list-action-executions: <quoted action name, stage name, lastStatus, lastStatusChangeReason, externalExecutionSummary>123 - get-pipeline-state: <quoted stage state + action state>124 - batch-get-builds (if Build): <quoted buildStatus, phaseStatus, logs>125 - describe-stack-events (if CFN Deploy): <quoted ResourceStatusReason>126 - iam simulate-principal-policy / get-role (if IAM): <decision / trust policy snippet>127ROOT_CAUSE_CATALOG: #<N>128REMEDIATION:129 1. <exact pipeline definition change, IAM policy edit, or CLI command>130 2. <verification command — retry the failed action>131 3. <post-apply monitoring step>132```133134### FORBIDDEN output patterns135136- NEVER start with "Let me analyze…" or "I'll investigate…" — the137 INCIDENT line is the FIRST line, always. No conversational preamble.138- NEVER use lowercase verdict values — emit `ROOT_CAUSE_FOUND`,139 `NEED_MORE_INFO`, or `ESCALATE`.140- NEVER omit EVIDENCE — the judge requires direct quotes from141 `list-action-executions` (`lastStatusChangeReason` /142 `externalExecutionSummary`) or `batch-get-builds` (`phaseStatus`,143 log excerpts). Paraphrasing is not acceptable.144- NEVER treat the stage name ("Build", "Deploy") as the root cause.145 The stage is the category; the action's146 `lastStatusChangeReason` plus the underlying service's logs are the147 cause.148- NEVER declare `ROOT_CAUSE_FOUND` for a cross-account Deploy failure149 without quoting the cross-account role's trust policy AND verifying150 the pipeline service role appears in the `Principal`.151- NEVER recommend `RetryPipelineExecution` on a pipeline whose root152 cause is not fixed — the retry will fail identically and consume153 another execution.154155## Process — Diagnostic decision tree (apply in order)156157### Step 0: Capture the failure signal158159Gather these five pieces. Each step below branches on which is present.160161| Signal | Source | Why required |162|---|---|---|163| **Pipeline name + region + execution ID** | User-provided or `aws codepipeline list-pipeline-executions` | All `get-pipeline-execution` / `list-action-executions` calls need this |164| **Failed stage + action name + lastStatusChangeReason** | `aws codepipeline list-action-executions` | Drives the category |165| **Underlying service's logs** | `aws codebuild batch-get-builds` (Build); `aws cloudformation describe-stack-events` (CFN Deploy); `aws codedeploy get-deployment` (CodeDeploy) | The pipeline action's summary is a paraphrase; the service's logs are the verbatim cause |166| **Pipeline definition (action configuration)** | `aws codepipeline get-pipeline` | Identifies the source type, build project, deploy provider, cross-account role |167| **Cross-account role trust + KMS key policy (for cross-region / cross-account)** | `aws iam get-role` / `aws kms get-key-policy` | The most common silent failure in cross-account pipelines |168169If the user has not provided the pipeline name or execution ID, emit170`VERDICT: NEED_MORE_INFO` with the `list-pipeline-executions`171discovery command and the list of missing inputs (pipeline name +172region, execution ID, failed stage / action,173`lastStatusChangeReason` and `externalExecutionSummary` from174`list-action-executions`, CodeBuild build ID and logs for Build175failures, customer-managed role ARN for cross-account Deploy).176177### Step 1: Identify the failure category178179Map the observed failed action's stage to one of five categories.180181| Failed action / stage | Category | Diagnostic step |182|---|---|---|183| Source action FAILED (CodeCommit / S3 / GitHub / CodeStar) | **A. SOURCE_STAGE_FAILED** | Step 2 |184| Build action FAILED (CodeBuild project) | **B. BUILD_STAGE_FAILED** | Step 3 |185| Deploy action FAILED (CloudFormation / ECS / CodeDeploy / S3) | **C. DEPLOY_STAGE_FAILED** | Step 4 |186| Approval action FAILED | **D. APPROVAL_TIMEOUT** | Step 5 |187| Deploy action FAILED with `AccessDenied` / `sts:AssumeRole` / cross-account | **E. CROSS_ACCOUNT_ROLE_FAILED** | Step 6 |188| Pipeline never started | TRIGGER_MISCONFIGURED | Check the CloudWatch Events rule + the source action's `DetectionMode` |189190**Precedence rule.** When multiple actions in different stages fail191in the same execution, diagnose the **earliest** failed action first —192later stages may have failed as a cascade because they received no193input artifact. Filter `list-action-executions` by `lastStatus:194Failed`, sort by `lastUpdateTime` ascending.195196### Step 2: SOURCE_STAGE_FAILED diagnostic197198The pipeline's Source action failed to fetch the source artifact.199200| Sub-symptom (read from `externalExecutionSummary` + provider) | Root cause | Probe |201|---|---|---|202| `The reference name <branch> does not exist` (CodeCommit) | The configured branch was deleted or renamed in the repo | `aws codecommit get-branch --repository-name <name> --branch-name <branch>`; update the pipeline's `BranchName` |203| `Key does not exist` (S3 source) | The configured S3 object key was deleted or never uploaded | `aws s3api head-object --bucket <name> --key <key>`; upload the object or update `S3ObjectKey` |204| `The bucket does not exist` (S3 source) | The source bucket was deleted | Recreate the bucket or repoint `S3Bucket` |205| `Could not authenticate to GitHub` / `Personal access token expired` (GitHub v1 source) | The GitHub personal access token stored in Secrets Manager / Parameter Store expired or was revoked | Rotate the token; update the secret; re-create the pipeline structure (GitHub v1 source action) |206| `Connection pending` (CodeStar connection / GitHub v2 / Bitbucket) | The CodeStar connection was never authorised (pending handshake) | `aws codestar-connections get-connection --connection-arn <arn>`; complete the connection in the console |207| `Access denied for repository <name>` (CodeCommit) | The pipeline service role lacks `codecommit:GetRepository` / `GitPull` | `iam simulate-principal-policy` on the pipeline service role |208| Source action succeeded but pipeline never starts (polling source) | The source action is configured for polling but the polling interval is very long, or event-driven detection was disabled | Read `actionTypeId` and `configuration` for `PollForSourceChanges`; if `false`, verify the CloudWatch Events rule exists |209210Source-stage diagnostic commands (failed-execution discovery, failed-action listing, Source action config read): [Diagnostic commands](references/diagnostic-commands.md).211212Source-stage common fix patterns (branch deleted, S3 key missing, token expired, connection pending, polling silent): [Failure catalog and decision tree](references/failure-catalog-and-decision-tree.md).213214### Step 3: BUILD_STAGE_FAILED diagnostic215216The pipeline's Build action invoked a CodeBuild project that returned217`FAILED`. The pipeline console shows "Build failed"; the actionable218detail is in CodeBuild.219220| Sub-symptom (read from `batch-get-builds` phases + CloudWatch Logs) | Root cause | Probe |221|---|---|---|222| `DOWNLOAD_SOURCE` phase FAILED | CodeBuild cannot fetch the source from the artifact bucket (KMS denied, object missing, IAM role) | `batch-get-builds` phase details; check the CodeBuild service role's `s3:GetObject` and `kms:Decrypt` on the artifact bucket |223| `INSTALL` phase FAILED with `BUILD_CONTAINER_UNABLE_TO_PULL` | The build image cannot be pulled (private ECR auth, Docker Hub rate limit, image doesn't exist) | Check `environment.image`; for ECR, ensure CodeBuild role has `ecr:BatchGetImage`; for Docker Hub, use an authenticated secret or a mirror |224| `INSTALL` / `BUILD` phase FAILED with `buildspec.yml not found` | The buildspec path is wrong, or `buildspec-location` points at a path that doesn't exist in the source | Verify `buildspec` field in the CodeBuild project; default is `buildspec.yml` at the repo root |225| `BUILD` phase FAILED with a runtime / compile error | The build script itself failed (exit code non-zero) | Read CloudWatch Logs for the failing command; the `phaseStatus` only says `FAILED` |226| `TIMED_OUT` build status | The build exceeded `timeoutInMinutes` (default 60, max 480) | Raise `timeoutInMinutes` OR optimise the build; long builds often indicate a missing cache |227| `COMPLETED` build but the pipeline's Build action FAILED | The CodeBuild build succeeded but failed to upload the output artifact (KMS denied on PutObject, artifact bucket missing) | Check `UPLOAD_ARTIFACTS` phase status; verify KMS key policy allows the CodeBuild role to `kms:Encrypt` |228| VPC-enabled build FAILED with ` subnet does not exist` | The CodeBuild VPC config references a deleted subnet / security group | `aws codebuild batch-get-projects`; verify the subnet IDs and SG IDs exist |229| Environment variable `AWS_DEFAULT_REGION` mismatch | The build assumes a different region than it runs in | Set environment variables explicitly in the project |230231Build-stage diagnostic walk (batch-get-builds phase query, failing-phase log retrieval): [Diagnostic commands](references/diagnostic-commands.md).232233Build-stage common fix patterns (buildspec path, KMS denied, image pull, VPC config, timeout): [Failure catalog and decision tree](references/failure-catalog-and-decision-tree.md).234235### Step 4: DEPLOY_STAGE_FAILED diagnostic236237The pipeline's Deploy action invoked a deploy provider (CloudFormation,238ECS, CodeDeploy, S3) that returned FAILED.239240| Provider | Sub-symptom | Root cause | Probe |241|---|---|---|---|242| CloudFormation (CFN deploy) | `No changes to deploy. The submitted changelist didn't contain any changes.` (change-set empty) | The build produced an identical template; or the change-set was created against stale state | `aws cloudformation describe-change-set` for the auto-generated change-set; verify the template differs |243| CloudFormation (CFN deploy) | `UPDATE_FAILED` / `CREATE_FAILED` (see CloudFormation troubleshooter) | The stack itself failed; the pipeline is the messenger | Drill into `describe-stack-events` (delegate to the cloudformation-stack-troubleshooter skill) |244| CloudFormation (CFN deploy) | `TemplateURL` references a non-existent S3 object | The Build action did not produce the expected artifact, or `TemplatePath` is wrong | Verify the Build action's output artifacts include the template |245| ECS (ECS deploy) | `Invalid task definition` / `Reference does not exist` | The task definition ARN / family is invalid or was deregistered | `aws ecs describe-task-definition --task-definition <arn>`; verify `taskDefinitionTemplate` / `imageName1` in the pipeline action config |246| ECS (ECS deploy) | `Service did not stabilize` / `running count could not be updated` | The ECS service could not reach steady state (insufficient capacity, container failure, load balancer issue) | `aws ecs describe-services`; `aws ecs describe-tasks` for stopped tasks; read stopped-reason |247| CodeDeploy | `Deployment group unhealthy` / `Too many instances with error` | CodeDeploy lifecycle hook failed; Auto Scaling Group instances failed the health check | `aws codedeploy get-deployment`; read lifecycle events per instance |248| S3 (S3 deploy) | `The specified bucket does not exist` | Deploy bucket was deleted | Recreate or repoint |249| S3 (S3 deploy) | `Access Denied` on `PutObject` | Pipeline service role lacks `s3:PutObject` on the deploy bucket, or bucket policy blocks it | `iam simulate-principal-policy` on the pipeline role |250251**Diagnostic walk:**2522531. **Read the deploy provider** from `get-pipeline` action254 `actionTypeId.provider`.2552. **Drill into the provider's logs:**256 - CloudFormation: `describe-stack-events` (delegate to the257 cloudformation-stack-troubleshooter skill for the root cause).258 - ECS: `describe-services`, `describe-tasks` for stopped-reason.259 - CodeDeploy: `get-deployment`, lifecycle events.260 - S3: `head-bucket`, `simulate-principal-policy`.2613. **For CloudFormation change-set empty:** the deploy action is262 configured with `ActionMode: CREATE_UPDATE` /263 `CHANGE_SET_EXECUTE`. Verify the change-set was created from the264 right template version; an empty change-set often means the265 Build action produced an identical template.266267### Step 5: APPROVAL_TIMEOUT diagnostic268269The pipeline's Approval action failed because no one approved within270the configured window (or the SNS topic for notifications is271misconfigured).272273| Sub-symptom | Root cause | Probe |274|---|---|---|275| Approval FAILED with `Timed out` | The action's `timeoutInMinutes` was hit (default 7 days, but operators often set shorter) | `list-action-executions` for the Approval action; check `timeoutInMinutes` in `get-pipeline` |276| Approval never notified anyone | The SNS topic ARN in the Approval action is wrong, or the topic has no subscriptions | `aws sns get-topic-attributes --topic-arn <arn>`; `aws sns list-subscriptions-by-topic --topic-arn <arn>` |277| Approval notification went to spam / wrong email | The SNS subscription endpoint is wrong | Verify subscription endpoints |278| Approval never appeared in the console | The action was configured with `ExternalEntityLink` only; no SNS notification was set | Add `NotificationArn` to the Approval action configuration |279280**Common fix patterns:**281282- **Timed out:** raise `timeoutInMinutes`, or improve the notification283 target so approvers see the request promptly.284- **SNS topic missing:** create the topic, subscribe the approvers,285 and add `NotificationArn` to the Approval action.286- **Re-trigger:** after extending the timeout, run287 `RetryPipelineExecution` on the failed execution.288289### Step 6: CROSS_ACCOUNT_ROLE_FAILED diagnostic290291The Deploy action runs in the pipeline's account (B) but deploys into292another account (A) via a customer-managed role. Cross-account failures293are the most misdiagnosed because the error says "AccessDenied" but294the root cause is in account A's trust policy.295296| Sub-symptom | Root cause | Probe |297|---|---|---|298| `is not authorized to perform: sts:AssumeRole` on the customer role | The customer role's trust policy does not include the pipeline service role in account B as Principal | `aws iam get-role --role-name <cross-acct-role>` → read `AssumeRolePolicyDocument`; add the pipeline service role ARN to `Principal.AWS` |299| `is not authorized to perform: <service>:<Action>` after AssumeRole succeeded | The customer role lacks the action on the target resource | `iam simulate-principal-policy` on the customer role in account A |300| `KMS AccessDenied` when reading / writing artifacts across accounts | The KMS key policy in account B does not grant account A's role `kms:Decrypt` / `kms:Encrypt` | `aws kms get-key-policy --key-id <id> --policy-name default`; add account A's role to the key policy |301| `AccessDenied` on `s3:GetObject` / `PutObject` for the artifact bucket | The artifact bucket policy does not grant account A's role access | `aws s3api get-bucket-policy --bucket <name>`; add a statement for account A's role |302| Cross-region Deploy FAILED | The artifact bucket in the deploy region does not exist; CodePipeline creates per-region artifact buckets but the customer role lacks cross-region permissions | Verify the customer role's policy covers the deploy region's resources |303| Cross-account role expired (external trust with condition) | The trust policy has a `Condition` on a date or external ID that has changed | Read the trust policy's `Condition`; remove or update the stale condition |304305Cross-account diagnostic walk (trust policy read, pipeline service-role verification, KMS key policy): [Diagnostic commands](references/diagnostic-commands.md).306307Cross-account common fix patterns (trust policy, KMS key policy, bucket policy, external ID): [Failure catalog and decision tree](references/failure-catalog-and-decision-tree.md).308309### Step 7: Map to root-cause catalog310311| # | Root cause | Category | Fix pattern |312|---|---|---|---|313| 1 | CodeCommit branch deleted / renamed | SOURCE_STAGE_FAILED | Recreate branch or update pipeline `BranchName` |314| 2 | S3 source object key missing | SOURCE_STAGE_FAILED | Upload object; verify `S3Bucket` / `S3ObjectKey` |315| 3 | GitHub v1 token expired / revoked | SOURCE_STAGE_FAILED | Rotate PAT; migrate to CodeStar connection |316| 4 | CodeStar connection pending handshake | SOURCE_STAGE_FAILED | Complete the connection in the console |317| 5 | `buildspec` missing or path wrong | BUILD_STAGE_FAILED | Verify `buildspec.yml` at configured path |318| 6 | CodeBuild KMS denied on artifact bucket | BUILD_STAGE_FAILED | Add CodeBuild role to KMS key policy |319| 7 | Build image pull failure (Docker Hub rate limit / ECR auth) | BUILD_STAGE_FAILED | Use ECR mirror; grant `ecr:BatchGetImage` |320| 8 | CodeBuild VPC config references deleted subnet / SG | BUILD_STAGE_FAILED | Update `vpcConfig` with valid IDs |321| 9 | CodeBuild `TIMED_OUT` | BUILD_STAGE_FAILED | Raise `timeoutInMinutes`; enable cache |322| 10 | CloudFormation change-set empty | DEPLOY_STAGE_FAILED | Verify the build produced a different template; check `TemplatePath` |323| 11 | ECS deploy `Service did not stabilize` | DEPLOY_STAGE_FAILED | `describe-tasks` stopped-reason; fix the task |324| 12 | Approval timed out (no SNS notification) | APPROVAL_TIMEOUT | Configure `NotificationArn`; raise `timeoutInMinutes` |325| 13 | Cross-account role trust missing pipeline service role | CROSS_ACCOUNT_ROLE_FAILED | Add pipeline role ARN to trust policy `Principal.AWS` |326| 14 | Cross-account KMS key policy missing customer role | CROSS_ACCOUNT_ROLE_FAILED | Add customer role to KMS key policy |327| 15 | Cross-account artifact bucket policy missing customer role | CROSS_ACCOUNT_ROLE_FAILED | Add customer role to bucket policy |328329### Step 8: Validate via retry / replay before declaring fixed330331Before declaring the fix complete:3323331. **Re-run the failed action via `RetryPipelineExecution`:**334 `aws codepipeline retry-pipeline-execution --pipeline-name <name>335 --pipeline-execution-id <id> --retry-mode FAILED_ACTIONS`.3362. **For Source / Build fixes** that change the pipeline definition,337 apply the change with `update-pipeline`, then trigger a new338 execution with `start-pipeline-execution`.3393. **Monitor the new execution** with `get-pipeline-execution` until340 status is `Succeeded`; check each stage transition.3414. **For cross-account fixes,** verify the trust / KMS / bucket policy342 changes propagate before retrying (IAM and KMS policies are343 eventually consistent; allow 30-60 seconds).344345### Step 9: Decide — ROOT_CAUSE_FOUND vs NEED_MORE_INFO vs ESCALATE346347- **ROOT_CAUSE_FOUND.** The walk identified a specific failure348 category and a specific configuration element (pipeline action349 config, CodeBuild project setting, IAM role trust, KMS key policy,350 bucket policy, CodeBuild phase error). Output REMEDIATION with the351 exact change.352- **NEED_MORE_INFO.** The walk reached a step where the operator353 cannot supply evidence (e.g., `list-action-executions` requires354 elevated read access, or the build logs are in another account).355 Output the list of missing inputs.356- **ESCALATE.** The walk identifies a cause outside the operator's357 scope: a customer-managed cross-account role owned by another team,358 a CodeStar connection owned by a third-party org admin, an SCP359 owned by security. Output the escalation target and the specific360 request.361362## Output format363364```text365INCIDENT: <pipeline name> in <region> — <failed stage / action + symptom>366VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE367ROOT_CAUSE: <category name> — <specific failing config element>368EVIDENCE:369 - get-pipeline-execution: <status + statusSummary>370 - list-action-executions: <action + lastStatusChangeReason>371 - batch-get-builds: <phaseStatus + failureReason, if Build>372 - describe-stack-events: <ResourceStatusReason, if CFN Deploy>373 - iam get-role / simulate: <trust policy / decision>374ROOT_CAUSE_CATALOG: #<N>375REMEDIATION:376 1. <specific pipeline / CodeBuild / IAM change>377 2. <verification command>378 3. <post-apply monitoring>379```380381### Worked example — CodeBuild buildspec missing382383```text384INCIDENT: app-build-pipeline in us-east-1 — Build stage action385 "Build" FAILED386VERDICT: ROOT_CAUSE_FOUND387ROOT_CAUSE: BUILD_STAGE_FAILED — CodeBuild project "app-build"388 has buildspec set to "buildspec.yml" (default path) but the389 source artifact does not contain a buildspec.yml at the repo root;390 the DOWNLOAD_SOURCE phase succeeded but the INSTALL phase failed391 with "buildspec not found"392EVIDENCE:393 - list-action-executions: action "Build" in stage "Build",394 lastStatus Failed, lastStatusChangeReason "Action execution395 failed", externalExecutionSummary "Build failed"396 - batch-get-builds id <build-id>: buildStatus FAILED, phases show397 DOWNLOAD_SOURCE SUCCEEDED, INSTALL FAILED with phaseFailureReason398 "BUILD_CONTAINER_FAILED"; logs show399 "YAML_FILE_ERROR Message: buildspec.yml is empty or missing"400 - get-pipeline Build action configuration: ProjectName "app-build",401 no OverrideBuildspec set402 - The source artifact (inspected via S3) contains the repo but the403 buildspec.yml was moved to ci/buildspec.yml in the last commit404ROOT_CAUSE_CATALOG: #5 (buildspec missing or path wrong)405REMEDIATION:406 1. Update the CodeBuild project to use the new buildspec path:407 aws codebuild update-project --name app-build \408 --source '{type: CODEPIPELINE, buildspec: ci/buildspec.yml, location: "codepipeline://app-build-pipeline"}'409 Alternatively, update the pipeline action's OverrideBuildspec:410 aws codepipeline update-pipeline --cli-json-json file://updated-pipeline.json411 2. Trigger a fresh execution:412 aws codepipeline start-pipeline-execution --name app-build-pipeline413 3. Monitor the Build action's next execution:414 aws codepipeline list-action-executions --pipeline-name app-build-pipeline \415 --query 'actionExecutionDetails[?actionName==`Build`].{status:status,reason:lastStatusChangeReason}' \416 --output table417 Expect lastStatus Succeeded and a green Build stage.418```419420## Expert edge cases421422All eight expert edge cases (paraphrase vs logs, service-role-not-pipeline trust, KMS silent killer, change-set empty, polling vs event-driven, retry semantics, timeout layering, EventBridge signals, throttling): [Advanced patterns](references/advanced-patterns.md).423424## Expert heuristic — "Drill from the pipeline action into the service"425426Stage-to-real-cause lookup table and the drill-down rule: [Advanced patterns](references/advanced-patterns.md).427428## Anti-Patterns — NEVER429430- **NEVER** treat the pipeline stage status ("Build Failed") as the431 root cause. The stage is the category; the underlying service's432 logs are the cause. Always drill.433- **NEVER** declare `ROOT_CAUSE_FOUND` for a Build failure without434 quoting the CodeBuild `phaseFailureReason` AND the relevant log435 line. "Build failed" is the symptom, not the diagnosis.436- **NEVER** diagnose a cross-account Deploy failure without reading437 the customer-managed role's trust policy. `AccessDenied` in a438 cross-account context is almost always a trust / KMS / bucket439 policy issue, not a pipeline permission issue.440- **NEVER** recommend `RetryPipelineExecution` on a pipeline whose441 root cause is not fixed. Retry re-runs only failed actions; the442 same input will produce the same failure.443- **NEVER** confuse a polling source failure with an event-driven444 trigger failure. A polling source fails inside an execution; an445 event-driven source fails by never starting. Read446 `PollForSourceChanges` first.447- **NEVER** treat a CloudFormation change-set empty error as a build448 failure. The build succeeded; the template is identical to the449 deployed state. Check the change-set and `TemplatePath`.450- **NEVER** recommend raising the CodeBuild timeout without first451 reading the build logs. The cause of a 5-minute failure is in the452 failing command, not the 60-minute cap.453- **NEVER** add the pipeline ARN (not the role ARN) to a cross-454 account trust policy. `sts:AssumeRole` requires an IAM principal,455 not a pipeline resource. Use `metadata.pipelineExecutionRole`.456- **NEVER** ignore the KMS key policy on cross-account pipelines.457 The artifact bucket is encrypted; the customer role needs458 `kms:Decrypt` on the key, not just `s3:GetObject` on the bucket.459- **NEVER** declare a Source failure resolved without verifying the460 source object / branch / connection actually exists post-fix.461- **NEVER** confuse `RetryStageExecution` (re-runs only failed462 actions) with starting a new execution. Succeeded actions are not463 re-run; bad Source input requires a fresh execution.464- **NEVER** rely on `CodePipeline Pipeline Execution State Change`465 for action-level alerts. Use the underlying service's466 state-change event (CodeBuild, CloudFormation) for action-level467 failure notifications.468469## Recent AWS features (2024-2026)470471Recent features — pipeline rollback, FAILED_ACTIONS retry mode, GitHub v2 connections, CodeBuild fleets, EventBridge replay, V2 pipeline type: [Advanced patterns](references/advanced-patterns.md).472473## References474475See `references/failure-catalog-and-decision-tree.md` for the full476per-stage walk with worked examples per category, and477`references/diagnostic-commands.md` for the canonical command script478for each failure category.479480## References (load on demand)481482- [Advanced patterns](references/advanced-patterns.md) — expert edge cases, drill-down heuristic, recent features483- [Diagnostic commands](references/diagnostic-commands.md) — per-stage diagnostic command listings and walks484- [Failure catalog and decision tree](references/failure-catalog-and-decision-tree.md) — per-category walk, worked examples, canonical fixes485486## Domain487488AWS CloudOps / DevTools — CI/CD Pipeline Reliability.489490## AWS documentation491492- **AWS CodePipeline User Guide** — https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html493- **CodePipeline pipeline executions** — https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts-how-it-works.html494- **CodePipeline cross-account actions** — https://docs.aws.amazon.com/codepipeline/latest/userguide/security-iam.html495- **CodeBuild buildspec reference** — https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html496- **CodeStar Connections** — https://docs.aws.amazon.com/dtconsole/latest/userguide/welcome.html497- **CodePipeline CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/codepipeline/