skills/cloud/aws/codepipeline-cicd/SKILL.md
Use when building AWS CI/CD pipelines with CodePipeline/CodeBuild/CodeDeploy, choosing deployment strategies, configuring buildspec.yml, or setting up artifact management with CodeArtifact. Covers AWS DOP-C02 and DVA-C02 CI/CD domains.
npx skillsauth add kienbui1995/magic-powers codepipeline-cicdInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Standard pipeline flow:
Source → Build → Test → [Approval] → Deploy (Staging) → [Approval] → Deploy (Production)
Pipeline stages and actions:
| Stage | Services | Purpose | |-------|---------|---------| | Source | CodeCommit, S3, GitHub, ECR | Trigger on code/artifact change | | Build | CodeBuild | Compile, test, package artifacts | | Test | CodeBuild, Lambda | Integration/load tests | | Deploy | CodeDeploy, ECS, CloudFormation, S3, Elastic Beanstalk | Deploy to target | | Approval | Manual approval action | Human gate with SNS notification |
Action constraints:
runOrder to sequence actions within a stage (runOrder 1 before runOrder 2)version: 0.2
env:
variables:
ENV: production
parameter-store:
DB_PASSWORD: /myapp/db/password # from SSM Parameter Store
secrets-manager:
API_KEY: myapp/api-key # from Secrets Manager
phases:
install:
runtime-versions:
nodejs: 18
commands:
- npm install
pre_build:
commands:
- echo "Running pre-build checks..."
- aws ecr get-login-password | docker login --username AWS --password-stdin $ECR_REGISTRY
build:
commands:
- npm run build
- npm run test
- docker build -t $IMAGE_TAG .
post_build:
commands:
- docker push $IMAGE_TAG
- echo "Build completed"
artifacts:
files:
- '**/*'
base-directory: dist
discard-paths: no
cache:
paths:
- node_modules/**/* # cache for faster builds
Key sections:
install: Install runtime and toolspre_build: Authentication, setupbuild: Main compilation and testingpost_build: Push images, notificationsartifacts: Files passed to next pipeline stagecache: S3-backed cache between builds (speeds up dependency downloads)For EC2 / On-premises:
| Strategy | Description | Downtime | Rollback | |----------|------------|---------|---------| | In-Place (Rolling) | Deploy to existing instances; configurable batch size | Brief (batch update) | Redeploy old version | | Blue/Green | Create new ASG with new version; shift traffic via ELB | Zero downtime | Keep old ASG, redirect traffic back |
In-Place minimum health: MinimumHealthyHosts (percentage or count that must remain healthy during deployment).
For AWS Lambda:
| Strategy | Behavior | |----------|---------| | AllAtOnce | Immediately shift 100% traffic to new version | | Canary10Percent5Minutes | Shift 10%, wait 5 min, shift remaining 90% | | Linear10PercentEvery1Minute | Shift 10% every 1 minute (10 steps = 100% in 10 min) | | Linear10PercentEvery3Minutes | Shift 10% every 3 min (30 min total) |
For ECS (Blue/Green):
For EC2:
version: 0.0
os: linux
files:
- source: /src
destination: /var/www/html
hooks:
BeforeInstall:
- location: scripts/stop_server.sh
timeout: 60
AfterInstall:
- location: scripts/install_dependencies.sh
ApplicationStart:
- location: scripts/start_server.sh
ValidateService:
- location: scripts/validate.sh
timeout: 60
For Lambda:
version: 0.0
Resources:
- MyFunction:
Type: AWS::Lambda::Function
Properties:
Name: MyFunction
Alias: live
CurrentVersion: !Ref LambdaVersion
TargetVersion: !Ref NewLambdaVersion
Hooks:
BeforeAllowTraffic: PreTrafficHook # Lambda to run before traffic shift
AfterAllowTraffic: PostTrafficHook # Lambda to run after traffic shift
Hook lifecycle order (EC2): ApplicationStop → DownloadBundle → BeforeInstall → Install → AfterInstall → ApplicationStart → ValidateService
| Source event | Pipeline trigger | |-------------|----------------| | CodeCommit push | EventBridge rule (automatic) | | S3 object change | EventBridge rule | | GitHub/Bitbucket push | CodeStar Connection webhook | | ECR image push | EventBridge rule → pipeline (not direct) | | Scheduled | EventBridge schedule → pipeline | | Manual | Console, CLI, SDK |
ECR push → Pipeline: CodePipeline cannot watch ECR directly. Use EventBridge rule:
source: aws.ecr → detail-type: "ECR Image Action" → Pipeline trigger.
aws.ecr image action event) → trigger pipelineMinimumHealthyHosts) = must keep X% of instances healthy during rolling deploy to productionValidateService hookcontent-media
Use when designing for XR (AR/VR/MR), choosing interaction modes, or adapting 2D UI patterns for spatial computing
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment
development
Use when you have a spec or requirements for a multi-step task, before touching code
development
Use when executing a structured workflow — select and run a feature, bugfix, refactor, research, or incident template with correct agent and model assignments per phase.