Skip to main content
In this lesson we cover the most common failure scenarios in AWS CI/CD pipelines, how to diagnose them, and practical fixes you can apply quickly. The frequent root causes are:
  • Permissions (IAM role/policy) issues
  • Misconfigurations (artifact paths, branch names, tags)
  • Missing resources or artifacts (ECR images, AMIs, quotas)
We’ll walk through failures at each stage of a pipeline — source → build → deploy → runtime — and suggest focused troubleshooting steps you can use to isolate and resolve problems. While many failures surface at the build step, problems can appear earlier (git triggers) or later (deployment/infrastructure). Quick overview: failure categories CodeBuild-level failures
  • Typical symptoms: build failure, unit/test failures, artifacts not produced, or build commands error.
  • Common causes:
    • Syntax or indentation errors in buildspec.yml.
    • Wrong or missing build commands in phases.
    • Artifacts configured to a path that doesn’t match produced outputs.
    • Environment variables missing or using incorrect values for environment.
    • Missing external dependencies (private registries, CodeArtifact, network restrictions).
A CI/CD pipeline diagram titled "Pipeline Configuration Failures" showing AWS-style icons for CodeCommit flowing to CodeBuild (marked with a warning), then CodeDeploy and ECS, with a Buildspec steps box and a Developer icon.
What to check and how to fix CodeBuild issues
  • Lint buildspec.yml for valid YAML and supported keys.
  • Reproduce build steps locally or inside a container matching the CodeBuild image to validate commands.
  • Print non-sensitive environment variables during the build to confirm they are set (avoid printing secrets).
  • Confirm artifact base-directory and files in buildspec.yml match the build output locations.
  • Inspect CodeBuild logs (CloudWatch/console logs) as the primary troubleshooting source.
  • Simplify the build: break it into small phases and validate each step independently.
A presentation slide titled "Why CodeBuild Fails From buildspec.yml?" showing a buildspec file icon with an error and a list of common causes: syntax errors in YAML, missing or wrong commands, artifacts misconfigured, and environment mismatch.
Practical buildspec example (minimal)
  • Use this template to ensure phases run, dependencies install, and non-sensitive variables are visible in logs:
Tips:
  • If artifacts are not found, double-check the base-directory value.
  • If builds succeed locally but fail in CodeBuild, compare runtime versions and environment variables.
A presentation slide titled "How to Fix It?" with blue icons. It lists troubleshooting steps like checking YAML syntax, fixing artifact paths, reviewing build commands, using build logs, matching the environment with commands, and testing iteratively.
Permission problems (the number one real-world issue)
  • Symptoms: “AccessDenied” or permission errors when CodeBuild tries to read/write S3, push/pull to ECR, retrieve secrets from Secrets Manager, or access CodeArtifact.
  • What to check:
    • Confirm the IAM role attached to the CodeBuild project has permissions required by every resource it interacts with.
    • Secrets Manager: role must include secretsmanager:GetSecretValue for the secret’s ARN; include kms:Decrypt if the secret is encrypted with a customer-managed KMS key.
    • ECR: role needs ecr:GetAuthorizationToken, ecr:BatchCheckLayerAvailability, and push permissions when writing images.
    • S3 artifacts: ensure s3:GetObject and s3:PutObject are allowed for the artifact bucket and that any bucket policy allows the build role.
    • If using cross-account resources, ensure roles and trust policies are configured for cross-account access.
A slide titled "IAM Permissions Issues" showing an AWS CI/CD flow: CodeCommit → CodeBuild (marked with a warning) → CodeDeploy → ECS. It also shows AWS Secrets Manager linked to CodeBuild with an "Access Denied: No permission" error.
Example: minimal CodeBuild service role trust and inline policy (illustrative)
  • Ensure the role trusts the CodeBuild service principal and includes the minimum permissions needed. Wrap JSON in a fenced code block to avoid MDX parsing issues.
Trust policy (role trust for CodeBuild):
Example inline policy snippet (example permissions — scope down to specific resources in production):
Always follow least-privilege: restrict resource ARNs and actions to only what the build needs. Use AWS managed policies for common scenarios and add granular inline policies for resource-level control.
Git integration failures
  • Symptoms: pipeline does not trigger on pushes, triggers on the wrong branch, or uses stale commits.
  • Common causes:
    • Webhook or repository trigger misconfigured.
    • Branch name mismatch (for example, pipeline watches master while pushes go to main).
    • Branch protection rules or repository permissions prevent the CI service from reading events.
  • Fixes:
    • Verify the pipeline trigger configuration matches the branch and event type (pushes, PR merges, tags).
    • Test the repository webhook or CodeCommit trigger and inspect delivery logs for failures.
    • Ensure the CI role/user has read/trigger permissions and update branch protection or pipeline settings as needed.
A flow diagram titled "Git Integration Failures" showing an AWS CI/CD pipeline: CodeCommit (marked with a warning) flows to CodeBuild, CodeDeploy, and ECS. It also shows a developer and an event labeled "Push to 'main' branch" with the pipeline watching "master."
Deployment and artifact-target mismatches
  • Symptoms: deployment fails because the deployment agent cannot pull the expected image/artifact; ECS tasks or Lambda functions receive an incorrect or missing image.
  • Causes:
    • Image not pushed to ECR, or pushed under a different tag than the deploy expects.
    • AppSpec file, task definition, or deployment manifest references a non-existent tag/ARN.
    • IAM permissions prevent CodeDeploy or ECS from reading the artifact location.
  • Fixes:
    • Confirm images exist in ECR with the expected tag. Use aws ecr describe-images or the console.
    • Inspect AppSpec, task definition, or deployment manifests for exact image/tag values and ARNs.
    • Ensure the deployment roles have permission to pull images and read artifact storage.
Infrastructure and provisioning failures
  • Symptoms: CloudFormation stack creation/update fails; blue/green deployments do not complete; missing AMI/Docker image; capacity or quota errors.
  • Common causes:
    • CloudFormation lacks permission to create/update resources — missing service role or insufficient IAM for the principal performing the stack action.
    • Referenced AMI or Docker image does not exist in that region or account.
    • AWS service quotas reached (EC2 instance limits, EBS volumes, ENIs, etc.).
    • Environment parity issues — blue and green environments differ in configuration or capacity.
  • Fixes:
    • Inspect CloudFormation events and logs to pinpoint the failed resource and error message.
    • Verify referenced images/AMIs exist in the target region/account and update ARNs if necessary.
    • Check service quotas in the AWS Console and request increases when needed.
    • Ensure configuration and environment variables are consistent across environments.
An infographic titled "Infrastructure Failures" showing an AWS CloudFormation block with an error leading to Blue and Green environment groups of compute instances, the Green group marked with a warning. Labels list causes like "Lack of IAM permission" and "Infrastructure provisioning issues."
General troubleshooting checklist (quick reference)
  • Check logs first:
    • CodeBuild logs (build output and CloudWatch)
    • CloudFormation events and stack logs
    • Deployment logs (CodeDeploy or pipeline execution logs)
  • Verify IAM roles and policies for each service (CodeBuild, CodeDeploy, CodePipeline, CloudFormation).
  • Confirm artifacts exist and their paths/tags match the pipeline and deployment configuration.
  • Ensure branch triggers and webhooks are configured for the correct branch names and event types.
  • Reproduce build commands locally or within a container image matching the build environment.
  • Validate environment variables and secrets are available and correct for the environment (and check KMS permissions).
  • Check service quotas and region-specific resource availability (AMIs, ECR images).
If you see “AccessDenied” errors, stop and review the IAM role and attached policies for that CI/CD service. Most deployment failures stem from permissions, so resolving them early saves significant time.
Summary
  • Most pipeline failures fall into three buckets: permissions, misconfiguration (artifacts, branches, deployment targets), and resource/infrastructure issues (missing AMIs/images or quotas).
  • Use logs and iterative tests that isolate a single stage to identify the failing component.
  • Apply least-privilege IAM roles scoped to required resources and keep branch names and artifact tags consistent across build and deploy stages.
Links and references That concludes this domain covering common CI/CD failures and troubleshooting advice.

Watch Video