AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides guidance on configuring and managing end-to-end CI/CD pipelines within the AWS ecosystem. It covers the integration of source control connections, build environments, package management, and deployment strategies. The content focuses on service orchestration, security best practices, and troubleshooting common infrastructure-level failures in build and deployment processes.
What it does
- Configures CI/CD pipelines using CodePipeline and CodeConnections.
- Defines build environments and buildspec logic for CodeBuild.
- Manages private package registries via CodeArtifact.
- Implements deployment strategies like blue/green, canary, and linear using CodeDeploy.
- Provides troubleshooting steps for pipeline, build, and deployment failures.
- Details security configurations for service roles and cross-account access.
When to use it
- When setting up automated build and deployment pipelines on AWS.
- When integrating external source providers like GitHub, GitLab, or Bitbucket.
- When managing private dependencies for build processes.
- When implementing traffic shifting strategies for application updates.
- When debugging pipeline stalls or deployment errors.
Advantages
- Native integration with AWS security and IAM policies.
- Supports complex deployment patterns like blue/green and canary.
- Enables secure cross-account artifact management.
- Provides centralized control over build and deployment phases.
Usage examples
- “How do I set up a pipeline that pulls from GitHub and deploys to ECS?”
- The agent provides a sequence to create a connection, configure a build stage for container packaging, and set up a deployment stage using blue/green traffic shifting.
- “My CodeBuild project is hanging at the download source phase.”
- The agent identifies the likely cause as a VPC configuration issue and suggests verifying the presence of a NAT gateway in the private subnets.
- “How can I share packages across different AWS accounts?”
- The agent explains how to configure CodeArtifact domain policies and use customer-managed KMS keys to enable cross-account access.
- “How do I handle a failed deployment in CodeDeploy?”
- The agent outlines how to use automated rollback settings or manual commands to stop and revert the deployment.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/aws/aws-deployment/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip aws-deployment.zip -d .agents/skills
Documentation by AWS
AWS Deploy (CI/CD)
Works best with the AWS MCP server for running CLI commands and validating configurations directly. All guidance also works with standard AWS CLI.
Critical Warnings
CodeConnections PENDING trap: Connections created via CLI/CloudFormation remain PENDING indefinitely — MUST complete OAuth in the AWS Console. No API-only path exists.
Cross-account triple requirement: Cross-account deploys need ALL THREE: (1) KMS key policy granting target account (use key ID, not alias), (2) S3 bucket policy for target account, (3) cross-account IAM role with trust policy. Missing any one = cryptic Access Denied.
CodeDeploy ApplicationStop uses PREVIOUS revision: Broken stop scripts in a prior deployment block ALL future deploys. Make stop scripts idempotent (exit 0 if service absent). Unblock with --ignore-application-stop-failures.
CodeBuild VPC without NAT: Builds in VPC subnets without NAT gateway hang at DOWNLOAD_SOURCE silently. Private subnets MUST have NAT gateway or VPC endpoints.
CodeConnections IAM: Use codeconnections: prefix for API calls and IAM policy Actions. Resource ARNs must match exactly — new resources use codeconnections prefix, existing resources may use codestar-connections prefix. Specify both in Resource if you have mixed-age resources.
UseConnection is over-permissive: codeconnections:UseConnection grants access to ALL repositories the connection can reach. MUST specify condition keys (codeconnections:FullRepositoryId, codeconnections:ProviderAction, codeconnections:BranchName) to limit CodeBuild to only the required repository.
How These Services Compose
CodeConnections → CodeBuild → CodeDeploy, orchestrated by CodePipeline.
| Layer | Service | Role |
|---|---|---|
| Source | CodeConnections | Authenticates to GitHub/GitLab/Bitbucket, delivers code |
| Packages | CodeArtifact | Private package registry, dependency caching from public registries |
| Build/Test | CodeBuild | Compiles, tests, packages artifacts |
| Deploy | CodeDeploy | Deploys to EC2/ECS/Lambda with traffic shifting strategies |
| Orchestrator | CodePipeline | Chains stages, manages transitions, approval gates |
Default: V2 pipeline type with QUEUED execution mode. Use PARALLEL only when executions are fully independent.
Quick Navigation
| You want to... | Go to |
|---|---|
| Create a pipeline (V2, triggers, variables, modes) | codepipeline.md |
| Connect GitHub/GitLab/Bitbucket source | codeconnections.md |
| Write buildspec.yml / configure builds | codebuild.md |
| Set up private package registry for builds | codeartifact.md |
| Configure deployment strategy (blue/green, canary) | codedeploy.md |
| Cross-account or cross-region deployment | codepipeline.md |
| Fix failing pipeline, build, or deployment | troubleshooting.md |
Common Workflows
| Task | Action | Reference |
|---|---|---|
| Pipeline from GitHub to ECS | Create connection → CodeBuild Docker stage → CodeDeploy ECS blue/green | codepipeline, codedeploy |
| Pipeline stuck at source | Check connection status; if PENDING, complete OAuth in AWS Console | troubleshooting |
| Build timing out | Check VPC/NAT, increase timeoutInMinutes, verify Docker privileged mode | codebuild |
| Deploy to another account | Configure KMS + S3 bucket policy + cross-account role, add RoleArn to action | codepipeline |
| Roll back failed deployment | Auto-rollback on alarm/failure; manual: stop-deployment --auto-rollback-enabled | codedeploy |
| Lambda canary deployment | CodeBuild packages → CodeDeploy Lambda with canary traffic shifting | codedeploy |
Troubleshooting
| Error/Symptom | Cause | Fix |
|---|---|---|
YAML_FILE_ERROR in CodeBuild | Missing or malformed runtime-versions in buildspec (recommended for standard images) | Add runtime-versions block in install phase |
file already exists on CodeDeploy | Redeployment without overwrite config | Set file_exists_behavior: OVERWRITE |
| Pipeline trigger not firing | File path filter checks only first 100 files in diff | Reduce path filter scope or merge smaller |
| PARALLEL mode wrong revision | Race between event and source action | Use QUEUED mode for sequential consistency |
Docker: Cannot connect to daemon | Missing privileged mode | Set privilegedMode: true AND start dockerd in buildspec |
CODEBUILD_CLONE_REF permission error | CodeBuild role missing UseConnection | Add codeconnections:UseConnection to CodeBuild service role |
| Deployment never completes | MinimumHealthyHosts too high for instance count | Ensure healthy threshold < total instances |
| ECS deployment stuck | Health check failing on new task set | Verify target group health check path/port |
Security
MUST store secrets in Secrets Manager or Parameter Store; reference via CodeBuild
type: SECRETS_MANAGER— MUST NOT embed in buildspec as PLAINTEXTMUST use customer-managed KMS keys for cross-account artifact encryption (default encryption does not support cross-account)
SHOULD scope CodeBuild/CodeDeploy service roles to specific resource ARNs; MUST NOT use
*fors3:GetObjectorkms:DecryptMUST use CodeConnections (not personal access tokens) for source connections; OAuth tokens cannot be rotated automatically
See CodePipeline security best practices for comprehensive guidance
Not Covered
| Topic | Use instead |
|---|---|
CDK Pipelines (aws-cdk-lib/pipelines) | aws-cdk |
sam deploy / SAM CLI | aws-serverless |
| ECS service deployment config (circuit breaker, rolling params) | aws-containers |
| GitHub Actions / GitLab CI | Third-party tools, not covered |
Files
- ATTRIBUTION.mdAdded by AutoGineer893 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer67 B
- SKILL.md7.0 KiB
- references/codeartifact.md6.4 KiB
- references/codebuild.md7.3 KiB
- references/codeconnections.md6.8 KiB
- references/codedeploy.md10.4 KiB
- references/codepipeline.md10.3 KiB
- references/troubleshooting.md7.9 KiB
references/codebuild.md
CodeBuild
Source Configuration
Code reaches CodeBuild via:
Pipeline action — CodePipeline passes artifacts (most common in CI/CD)
Direct source — CodeBuild pulls from CodeCommit, S3, GitHub, GitLab, or Bitbucket
No source — buildspec commands handle everything (e.g.,
git clonein install phase)
When using CodePipeline, the source is passed as an input artifact. When using CodeBuild standalone, configure source in the project:
aws codebuild create-project --name my-project \
--source type=CODECOMMIT,location=https://git-codecommit.REGION.amazonaws.com/v1/repos/REPO \
--source-version main \
--service-role arn:aws:iam::ACCOUNT_ID:role/codebuild-role \
--artifacts type=NO_ARTIFACTS \
--environment type=LINUX_CONTAINER,computeType=BUILD_GENERAL1_SMALL,image=aws/codebuild/amazonlinux2-x86_64-standard:5.0For GitHub/GitLab via CodeConnections, use type=CODEPIPELINE (pipeline manages source) or configure a webhook for standalone builds.
Phase Error Handling (on-failure)
Each buildspec phase supports an on-failure attribute controlling behavior when commands fail:
phases:
install:
on-failure: ABORT
commands:
- npm ci
build:
on-failure: CONTINUE
commands:
- npm run build
post_build:
on-failure: ABORT
commands:
- npm run package| Strategy | Behavior |
|---|---|
ABORT | Stop build immediately (default for install, pre_build, build) |
CONTINUE | Move to next phase even if commands fail |
RETRY | Retry failed command (default settings) |
RETRY-n | Retry up to n times (e.g., RETRY-3) |
RETRY-regex | Retry only if error matches regex pattern |
RETRY-n-regex | Retry up to n times only for matching errors |
Use RETRY-3-.*timeout.* for transient network failures during dependency install.
Note: post_build runs even if build phase failed. Gate post_build logic with the CODEBUILD_BUILD_SUCCEEDING env var.
VPC Configuration
Required when builds access private resources (RDS, internal APIs).
aws codebuild create-project --name my-project \
--source type=CODEPIPELINE \
--service-role arn:aws:iam::ACCOUNT_ID:role/codebuild-role \
--vpc-config vpcId=VPC_ID,subnets=PRIVATE_SUBNET_1,PRIVATE_SUBNET_2,securityGroupIds=SG_IDCRITICAL: CodeBuild CANNOT assign public IPs in VPC. Without a NAT gateway, builds hang silently at DOWNLOAD_SOURCE or dependency install with no error message.
| Requirement | Consequence if Missing |
|---|---|
| NAT gateway on private subnets | Build hangs indefinitely — no timeout error, just silence |
| Private subnets only | Public subnets not supported for CodeBuild VPC |
| S3 VPC endpoint | Artifact operations route through NAT (slow, costly) |
| CloudWatch Logs VPC endpoint | Logs missing or delayed |
Service role needs: ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, ec2:DeleteNetworkInterface, ec2:CreateNetworkInterfacePermission.
Security group: Restrict egress to required destinations only (VPC endpoints, NAT gateway). Avoid 0.0.0.0/0 egress — scope to S3 prefix lists and specific internal CIDRs. Ingress should be empty unless builds require inbound connections.
Caching
| Cache Type | Scope | Best For | Constraint |
|---|---|---|---|
| S3 | Across builds | Dependencies (node_modules, .m2, pip) | Network transfer cost |
| Local - docker_layer_cache | Same host | Docker rebuilds | Best-effort on-demand; reliable on fleet |
| Local - source_cache | Same host | Incremental git fetch | Best-effort on-demand; reliable on fleet |
| Local - custom_cache | Same host | Arbitrary paths | Best-effort on-demand; reliable on fleet |
S3 caching (works on-demand and fleet):
cache:
paths:
- '/root/.npm/**/*'
- '/root/.m2/**/*'Project config: --cache type=S3,location=BUCKET/cache (MUST enable SSE-KMS or SSE-S3 on the cache bucket — cached artifacts may contain dependency metadata)
Local caching (reliable on fleet, best-effort on on-demand): --cache type=LOCAL,modes=[LOCAL_DOCKER_LAYER_CACHE,LOCAL_SOURCE_CACHE]
Key distinction: S3 cache survives across any build host but costs network transfer. Local cache is instant (no transfer) but only works when consecutive builds land on the same host — guaranteed with fleet, probabilistic with on-demand.
Docker Image Builds
For custom images or VPC builds: privilegedMode: true AND manual dockerd start. CodeBuild-managed standard images may have Docker pre-configured, but privileged mode is still required for Docker-in-Docker.
aws codebuild create-project --name docker-builder \
--environment type=LINUX_CONTAINER,computeType=BUILD_GENERAL1_MEDIUM,image=aws/codebuild/amazonlinux2-x86_64-standard:5.0,privilegedMode=trueBuildspec for Docker + ECR push:
version: 0.2
phases:
pre_build:
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock &
- timeout 15 sh -c "until docker info; do sleep 1; done"
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $ECR_REPO_URI
build:
commands:
- docker build -t $IMAGE_REPO:$IMAGE_TAG .
- docker push $IMAGE_REPO:$IMAGE_TAGSecrets Reference
Secrets Manager format in buildspec: secret-id:json-key:version-stage:version-id (last two optional).
env:
parameter-store:
API_KEY: "/myapp/api-key"
secrets-manager:
DB_PASS: "myapp/db-creds:password"IAM: ssm:GetParameters for Parameter Store, secretsmanager:GetSecretValue for Secrets Manager.
Logging
Always enable CloudWatch Logs with KMS encryption (build logs may contain sensitive output):
--logs-config cloudWatchLogs={status=ENABLED,groupName=/aws/codebuild/PROJECT_NAME}Encrypt the log group: aws logs associate-kms-key --log-group-name /aws/codebuild/PROJECT_NAME --kms-key-id KEY_ARN
Timeouts
| Setting | Default | Maximum |
|---|---|---|
| Build timeout | 60 min | 480 min (8 hours) |
| Queued timeout | 480 min | 480 min |
Common Errors
| Error | Cause | Fix |
|---|---|---|
| Build hangs in VPC | No NAT gateway on private subnet | Add NAT gateway to route table |
Cannot connect to Docker daemon | Privileged mode off or dockerd not started | Set privilegedMode=true AND start dockerd |
CODEBUILD_CLONE_REF auth failure | CodeBuild role missing UseConnection | Add codeconnections:UseConnection to CodeBuild service role |
AccessDenied on artifacts | Cross-region bucket | Artifact bucket MUST be same region as project |
Security
MUST scope service role to specific S3 buckets and ECR repos; avoid
*resourceEnable SSE-KMS or SSE-S3 on cache buckets (cached artifacts may reveal application internals)
MUST NOT use
type: PLAINTEXTenvironment variables for secrets — usePARAMETER_STOREorSECRETS_MANAGERUse VPC endpoints to keep artifact and log traffic off the public internet
Enable CloudTrail for
codebuild:*API auditing
Related
codepipeline.md for pipeline build action configuration
troubleshooting.md for additional error patterns
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS
- Publisher
- AWS (Official)
- Source
- aws/agent-toolkit-for-aws · skills/core-skills/aws-deployment · commit 0a218f8
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- aws/agent-toolkit-for-aws
AutoGineer is not affiliated with or endorsed by AWS or AWS.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-deployment.zip