Generated banner for AWS Deployment
Generated logo for AWS Deployment

AWS Deployment

AWSOfficialPublished by AWS

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk

From the author

Configures CI/CD pipelines using AWS CodePipeline, CodeBuild, CodeDeploy, CodeConnections, and CodeArtifact. Covers CodePipeline V2 (triggers, variables, execution modes, cross-account), buildspec.yml (caching, VPC, Docker), CodeDeploy strategies (blue/green, canary, linear), CodeArtifact (private package registries, auth tokens, cross-account), and source connections (GitHub, GitLab, Bitbucket). Applies when CodePipeline, CodeBuild, CodeDeploy, CodeConnections, CodeArtifact, buildspec.yml, appspec.yml, or CI/CD pipeline orchestration is referenced. Does NOT cover: ECS Fargate services or task definitions (use aws-containers), CDK Pipelines or cdk deploy (use aws-cdk), sam deploy (use aws-serverless), Amplify deployments (use aws-amplify), or GitHub Actions/GitLab CI.
— the description by AWS

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

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/aws/aws-deployment/download
  2. Unzip 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.

LayerServiceRole
SourceCodeConnectionsAuthenticates to GitHub/GitLab/Bitbucket, delivers code
PackagesCodeArtifactPrivate package registry, dependency caching from public registries
Build/TestCodeBuildCompiles, tests, packages artifacts
DeployCodeDeployDeploys to EC2/ECS/Lambda with traffic shifting strategies
OrchestratorCodePipelineChains 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 sourcecodeconnections.md
Write buildspec.yml / configure buildscodebuild.md
Set up private package registry for buildscodeartifact.md
Configure deployment strategy (blue/green, canary)codedeploy.md
Cross-account or cross-region deploymentcodepipeline.md
Fix failing pipeline, build, or deploymenttroubleshooting.md

Common Workflows

TaskActionReference
Pipeline from GitHub to ECSCreate connection → CodeBuild Docker stage → CodeDeploy ECS blue/greencodepipeline, codedeploy
Pipeline stuck at sourceCheck connection status; if PENDING, complete OAuth in AWS Consoletroubleshooting
Build timing outCheck VPC/NAT, increase timeoutInMinutes, verify Docker privileged modecodebuild
Deploy to another accountConfigure KMS + S3 bucket policy + cross-account role, add RoleArn to actioncodepipeline
Roll back failed deploymentAuto-rollback on alarm/failure; manual: stop-deployment --auto-rollback-enabledcodedeploy
Lambda canary deploymentCodeBuild packages → CodeDeploy Lambda with canary traffic shiftingcodedeploy

Troubleshooting

Error/SymptomCauseFix
YAML_FILE_ERROR in CodeBuildMissing or malformed runtime-versions in buildspec (recommended for standard images)Add runtime-versions block in install phase
file already exists on CodeDeployRedeployment without overwrite configSet file_exists_behavior: OVERWRITE
Pipeline trigger not firingFile path filter checks only first 100 files in diffReduce path filter scope or merge smaller
PARALLEL mode wrong revisionRace between event and source actionUse QUEUED mode for sequential consistency
Docker: Cannot connect to daemonMissing privileged modeSet privilegedMode: true AND start dockerd in buildspec
CODEBUILD_CLONE_REF permission errorCodeBuild role missing UseConnectionAdd codeconnections:UseConnection to CodeBuild service role
Deployment never completesMinimumHealthyHosts too high for instance countEnsure healthy threshold < total instances
ECS deployment stuckHealth check failing on new task setVerify 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 PLAINTEXT

  • MUST 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 * for s3:GetObject or kms:Decrypt

  • MUST 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

TopicUse instead
CDK Pipelines (aws-cdk-lib/pipelines)aws-cdk
sam deploy / SAM CLIaws-serverless
ECS service deployment config (circuit breaker, rolling params)aws-containers
GitHub Actions / GitLab CIThird-party tools, not covered

Files

references/codedeploy.md

CodeDeploy

Deployment Strategy Comparison

StrategyEC2/On-PremisesECSLambdaBest For
In-placeYesNoNoSimple apps with acceptable downtime
Blue/greenYes (new ASG)Yes (task set swap)Yes (alias shift)Zero-downtime with instant rollback
CanaryNoYesYesHigh-risk changes needing validation window
LinearNoYesYesGradual rollout with steady monitoring
All-at-onceYesYesYesNon-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: 300
EC2 Lifecycle Hooks (Ordered)

In-place deployment:

  1. ApplicationStop — Runs PREVIOUS revision's stop script

  2. DownloadBundle — Agent-only; downloads revision

  3. BeforeInstall — Setup tasks (create dirs, decrypt)

  4. Install — Agent-only; copies files per files section

  5. AfterInstall — Post-install config (permissions, config generation)

  6. ApplicationStart — Start services

  7. ValidateService — Health checks, smoke tests

Additional hooks when a load balancer is configured (both in-place and blue/green):

  1. BeforeBlockTraffic — Pre-deregistration on original instances

  2. BlockTraffic — Agent-only; deregisters from ELB

  3. AfterBlockTraffic — Cleanup on original instances

  4. (Standard hooks 1-7 on replacement instances)

  5. BeforeAllowTraffic — Pre-registration on replacement instances

  6. AllowTraffic — Agent-only; registers with ELB

  7. AfterAllowTraffic — Post-registration validation

EC2 Deployment Configurations
ConfigurationBehavior
CodeDeployDefault.OneAtATimeOne instance at a time
CodeDeployDefault.HalfAtATimeUp to half simultaneously
CodeDeployDefault.AllAtOnceAll simultaneously
CustomSpecify 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)
  1. BeforeInstall — Lambda (scriptable)

  2. Install — Agent-only; creates replacement task set, waits for stability

  3. AfterInstall — Lambda (scriptable); validate replacement task set

  4. AllowTestTraffic — Agent-only; routes test listener to replacement target group

  5. AfterAllowTestTraffic — Lambda (scriptable); test via test traffic port

  6. BeforeAllowTraffic — Lambda (scriptable); pre-cutover gate

  7. AllowTraffic — Agent-only; shifts production traffic per config

  8. AfterAllowTraffic — Lambda (scriptable); post-cutover validation

Scriptable hooks: BeforeInstall, AfterInstall, AfterAllowTestTraffic, BeforeAllowTraffic, AfterAllowTraffic. All invoke Lambda functions (not shell scripts).

ECS Deployment Configurations
ConfigurationBehavior
CodeDeployDefault.ECSAllAtOnce100% immediately
CodeDeployDefault.ECSCanary10Percent5Minutes10% for 5 min, then 100%
CodeDeployDefault.ECSCanary10Percent15Minutes10% for 15 min, then 100%
CodeDeployDefault.ECSLinear10PercentEvery1Minutes10% every 1 min
CodeDeployDefault.ECSLinear10PercentEvery3Minutes10% 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
  1. BeforeAllowTraffic — Validate new version (invoke directly, run tests)

  2. AllowTraffic — Agent-only; shifts alias traffic per config

  3. AfterAllowTraffic — Validate production behavior post-shift

Lambda Deployment Configurations
ConfigurationBehavior
CodeDeployDefault.LambdaAllAtOnce100% immediately
CodeDeployDefault.LambdaCanary10Percent5Minutes10% for 5 min, then 100%
CodeDeployDefault.LambdaCanary10Percent10Minutes10% for 10 min, then 100%
CodeDeployDefault.LambdaLinear10PercentEvery1Minute10% every 1 min
CodeDeployDefault.LambdaLinear10PercentEvery2Minutes10% every 2 min
CodeDeployDefault.LambdaLinear10PercentEvery10Minutes10% 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
TriggerWhen
DEPLOYMENT_FAILUREAny deployment fails
DEPLOYMENT_STOP_ON_ALARMCloudWatch alarm breaches during deployment
DEPLOYMENT_STOP_ON_REQUESTManual 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_ALARM
ECS 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

ErrorCauseFix
"no instances were found"Tag filters match zero instancesVerify EC2 tags match deployment group filters
"too many individual instances failed"MinimumHealthyHosts impossibleRecalculate threshold for fleet size
"file already exists"file_exists_behavior not setSet OVERWRITE in CreateDeployment
"agent was not able to receive the lifecycle event"Agent not runningsudo service codedeploy-agent status
"HEALTH_CONSTRAINTS"Not enough healthy instancesReduce 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 auditing

  • MUST 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

  • See CodeDeploy security best practices

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