- Permissions (IAM role/policy) issues
- Misconfigurations (artifact paths, branch names, tags)
- Missing resources or artifacts (ECR images, AMIs, quotas)
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).
- Syntax or indentation errors in

- Lint
buildspec.ymlfor 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-directoryandfilesinbuildspec.ymlmatch 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.

- Use this template to ensure phases run, dependencies install, and non-sensitive variables are visible in logs:
- If artifacts are not found, double-check the
base-directoryvalue. - If builds succeed locally but fail in CodeBuild, compare runtime versions and environment variables.

- 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:GetSecretValuefor the secret’s ARN; includekms:Decryptif 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:GetObjectands3:PutObjectare 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.

- 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.
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.
- 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
masterwhile pushes go tomain). - 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.

- 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-imagesor 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.
- Confirm images exist in ECR with the expected tag. Use
- 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.

- 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.
- 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.
- AWS CodeBuild documentation
- AWS CodePipeline documentation
- AWS CodeDeploy documentation
- CloudFormation troubleshooting guide