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://mp-staging.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/codedeploy.md
CodeDeploy
Deployment Strategy Comparison
| Strategy | EC2/On-Premises | ECS | Lambda | Best For |
|---|---|---|---|---|
| In-place | Yes | No | No | Simple apps with acceptable downtime |
| Blue/green | Yes (new ASG) | Yes (task set swap) | Yes (alias shift) | Zero-downtime with instant rollback |
| Canary | No | Yes | Yes | High-risk changes needing validation window |
| Linear | No | Yes | Yes | Gradual rollout with steady monitoring |
| All-at-once | Yes | Yes | Yes | Non-production or low-risk changes |
Recommendation: Blue/green for production EC2. Canary for ECS/Lambda production where you need a validation window.
EC2/On-Premises
appspec.yml
version: 0.0
os: linux
files:
- source: /
destination: /opt/myapp
overwrite: true
permissions:
- object: /opt/myapp/bin
pattern: "*.sh"
owner: appuser
mode: 755
type:
- file
hooks:
ApplicationStop:
- location: scripts/stop.sh
timeout: 120
runas: appuser
BeforeInstall:
- location: scripts/before_install.sh
timeout: 300
AfterInstall:
- location: scripts/after_install.sh
timeout: 300
ApplicationStart:
- location: scripts/start.sh
timeout: 120
ValidateService:
- location: scripts/validate.sh
timeout: 300EC2 Lifecycle Hooks (Ordered)
In-place deployment:
ApplicationStop — Runs PREVIOUS revision's stop script
DownloadBundle — Agent-only; downloads revision
BeforeInstall — Setup tasks (create dirs, decrypt)
Install — Agent-only; copies files per
filessectionAfterInstall — Post-install config (permissions, config generation)
ApplicationStart — Start services
ValidateService — Health checks, smoke tests
Additional hooks when a load balancer is configured (both in-place and blue/green):
BeforeBlockTraffic — Pre-deregistration on original instances
BlockTraffic — Agent-only; deregisters from ELB
AfterBlockTraffic — Cleanup on original instances
(Standard hooks 1-7 on replacement instances)
BeforeAllowTraffic — Pre-registration on replacement instances
AllowTraffic — Agent-only; registers with ELB
AfterAllowTraffic — Post-registration validation
EC2 Deployment Configurations
| Configuration | Behavior |
|---|---|
| CodeDeployDefault.OneAtATime | One instance at a time |
| CodeDeployDefault.HalfAtATime | Up to half simultaneously |
| CodeDeployDefault.AllAtOnce | All simultaneously |
| Custom | Specify HOST_COUNT or FLEET_PERCENT threshold |
EC2 Pitfalls
ApplicationStop uses PREVIOUS revision's scripts: Broken stop scripts block ALL future deployments. Fix: deploy a revision that only fixes the stop script, or remove /opt/codedeploy-agent/deployment-root/ on affected instances and restart agent.
file_exists_behavior unset: Redeploys fail with "file already exists." Always set in CreateDeployment: OVERWRITE, RETAIN, or DISALLOW.
Auto Scaling loop: Failed deployments on new instances cause infinite provision-terminate cycle. Fix: suspend Launch on ASG, fix deployment, resume.
MinimumHealthyHosts miscalculation: Setting 90% on 3 instances = 2.7 rounded to 3 — deployment can never proceed. Ensure at least one instance can be taken offline.
ECS (Blue/Green)
ECS deployments always use blue/green. CodeDeploy creates a replacement task set, optionally routes test traffic, then shifts production traffic.
appspec.yml (ECS)
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: "arn:aws:ecs:REGION:ACCOUNT:task-definition/my-task:3"
LoadBalancerInfo:
ContainerName: "my-container"
ContainerPort: 8080
PlatformVersion: "LATEST"
Hooks:
- BeforeInstall: "arn:aws:lambda:REGION:ACCOUNT:function:BeforeInstallHook"
- AfterInstall: "arn:aws:lambda:REGION:ACCOUNT:function:AfterInstallHook"
- AfterAllowTestTraffic: "arn:aws:lambda:REGION:ACCOUNT:function:TestTrafficHook"
- BeforeAllowTraffic: "arn:aws:lambda:REGION:ACCOUNT:function:BeforeTrafficHook"
- AfterAllowTraffic: "arn:aws:lambda:REGION:ACCOUNT:function:AfterTrafficHook"ECS Lifecycle Hooks (Ordered)
BeforeInstall — Lambda (scriptable)
Install — Agent-only; creates replacement task set, waits for stability
AfterInstall — Lambda (scriptable); validate replacement task set
AllowTestTraffic — Agent-only; routes test listener to replacement target group
AfterAllowTestTraffic — Lambda (scriptable); test via test traffic port
BeforeAllowTraffic — Lambda (scriptable); pre-cutover gate
AllowTraffic — Agent-only; shifts production traffic per config
AfterAllowTraffic — Lambda (scriptable); post-cutover validation
Scriptable hooks: BeforeInstall, AfterInstall, AfterAllowTestTraffic, BeforeAllowTraffic, AfterAllowTraffic. All invoke Lambda functions (not shell scripts).
ECS Deployment Configurations
| Configuration | Behavior |
|---|---|
| CodeDeployDefault.ECSAllAtOnce | 100% immediately |
| CodeDeployDefault.ECSCanary10Percent5Minutes | 10% for 5 min, then 100% |
| CodeDeployDefault.ECSCanary10Percent15Minutes | 10% for 15 min, then 100% |
| CodeDeployDefault.ECSLinear10PercentEvery1Minutes | 10% every 1 min |
| CodeDeployDefault.ECSLinear10PercentEvery3Minutes | 10% every 3 min |
ECS Pitfalls
Lifecycle hook 1-hour timeout: CodeDeploy waits up to 3600s for the PutLifecycleEventHookExecutionStatus callback. This is the CodeDeploy hook timeout, not the Lambda execution timeout (which is max 900s). If the Lambda doesn't call back within 1 hour, the hook fails.
Test listener required for AfterAllowTestTraffic: Without a test listener on the ALB, this hook is skipped — no pre-production validation window.
Original task set termination: Configure terminationWaitTimeInMinutes on deployment group. Default is 0 — original tasks terminated immediately after shift (no manual rollback window).
Lambda
Traffic shifts between two function versions using an alias.
appspec.yml (Lambda)
version: 0.0
Resources:
- MyFunction:
Type: AWS::Lambda::Function
Properties:
Name: "my-function"
Alias: "live"
CurrentVersion: "1"
TargetVersion: "2"
Hooks:
- BeforeAllowTraffic: "arn:aws:lambda:REGION:ACCOUNT:function:PreTrafficHook"
- AfterAllowTraffic: "arn:aws:lambda:REGION:ACCOUNT:function:PostTrafficHook"Lambda Lifecycle Hooks
BeforeAllowTraffic — Validate new version (invoke directly, run tests)
AllowTraffic — Agent-only; shifts alias traffic per config
AfterAllowTraffic — Validate production behavior post-shift
Lambda Deployment Configurations
| Configuration | Behavior |
|---|---|
| CodeDeployDefault.LambdaAllAtOnce | 100% immediately |
| CodeDeployDefault.LambdaCanary10Percent5Minutes | 10% for 5 min, then 100% |
| CodeDeployDefault.LambdaCanary10Percent10Minutes | 10% for 10 min, then 100% |
| CodeDeployDefault.LambdaLinear10PercentEvery1Minute | 10% every 1 min |
| CodeDeployDefault.LambdaLinear10PercentEvery2Minutes | 10% every 2 min |
| CodeDeployDefault.LambdaLinear10PercentEvery10Minutes | 10% every 10 min |
Rollback Configuration
aws deploy update-deployment-group \
--application-name MyApp \
--deployment-group-name MyDG \
--auto-rollback-configuration enabled=true,events=DEPLOYMENT_FAILURE,DEPLOYMENT_STOP_ON_ALARM| Trigger | When |
|---|---|
| DEPLOYMENT_FAILURE | Any deployment fails |
| DEPLOYMENT_STOP_ON_ALARM | CloudWatch alarm breaches during deployment |
| DEPLOYMENT_STOP_ON_REQUEST | Manual stop triggers rollback |
ECS/Lambda: rollback re-routes traffic to original task set/version. EC2: rollback creates a NEW deployment with last known good revision.
Manual rollback: aws deploy stop-deployment --deployment-id ID --auto-rollback-enabled
Recommendation: Always enable DEPLOYMENT_STOP_ON_ALARM with error rate + latency alarms for production.
Creating Deployment Groups
EC2 Deployment Group
aws deploy create-deployment-group \
--application-name MyApp \
--deployment-group-name MyDG \
--deployment-config-name CodeDeployDefault.OneAtATime \
--ec2-tag-filters Key=Environment,Value=MyEnvironment,Type=KEY_AND_VALUE \
--service-role-arn arn:aws:iam::ACCOUNT:role/CodeDeployServiceRole \
--auto-rollback-configuration enabled=true,events=DEPLOYMENT_FAILURE,DEPLOYMENT_STOP_ON_ALARMECS Deployment Group
aws deploy create-deployment-group \
--application-name MyECSApp \
--deployment-group-name MyECSDG \
--deployment-config-name CodeDeployDefault.ECSCanary10Percent5Minutes \
--service-role-arn arn:aws:iam::ACCOUNT:role/CodeDeployECSRole \
--ecs-services serviceName=my-service,clusterName=my-cluster \
--load-balancer-info "targetGroupPairInfoList=[{targetGroups=[{name=tg-blue},{name=tg-green}],prodTrafficRoute={listenerArns=[ALB_LISTENER_ARN]},testTrafficRoute={listenerArns=[TEST_LISTENER_ARN]}}]"Common Errors
| Error | Cause | Fix |
|---|---|---|
| "no instances were found" | Tag filters match zero instances | Verify EC2 tags match deployment group filters |
| "too many individual instances failed" | MinimumHealthyHosts impossible | Recalculate threshold for fleet size |
| "file already exists" | file_exists_behavior not set | Set OVERWRITE in CreateDeployment |
| "agent was not able to receive the lifecycle event" | Agent not running | sudo service codedeploy-agent status |
| "HEALTH_CONSTRAINTS" | Not enough healthy instances | Reduce minimumHealthyHosts or fix failing instances |
Security
Scope CodeDeploy service role to specific deployment groups and S3 artifact paths
Encrypt deployment artifacts in S3 (SSE-KMS recommended)
Enable CloudTrail for
codedeploy:*API auditingMUST NOT log secrets in appspec hook scripts (stdout is captured in deployment logs)
Encrypt CloudWatch Logs groups for CodeDeploy event logs with KMS
Configure CloudWatch alarms on error rate/latency metrics for use with
DEPLOYMENT_STOP_ON_ALARM
Related
codepipeline.md for CodeDeploy action in pipelines
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.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-deployment.zip