Build automated CI/CD pipelines with CodePipeline and CodeBuild
Creates automated CI/CD pipelines using AWS CodePipeline and CodeBuild. Triggers when you need to set up deployment pipelines from source repositories to ECS, Lambda, EC2, or S3 targets.
/plugin marketplace add pluginagentmarketplace/custom-plugin-aws/plugin install pluginagentmarketplace-aws-cloud-assistant@pluginagentmarketplace/custom-plugin-awsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/buildspec.ymlassets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyCreate automated CI/CD pipelines for application deployment.
| Attribute | Value |
|---|---|
| AWS Service | CodePipeline, CodeBuild |
| Complexity | Medium |
| Est. Time | 20-45 min |
| Prerequisites | Source repo, IAM role, deployment target |
| Parameter | Type | Description | Validation |
|---|---|---|---|
| pipeline_name | string | Pipeline name | ^[A-Za-z0-9.@_-]{1,100}$ |
| source_provider | string | Source type | GitHub, CodeCommit, S3 |
| deployment_target | string | Deploy target | ECS, Lambda, EC2, S3 |
| Parameter | Type | Default | Description |
|---|---|---|---|
| branch | string | main | Source branch |
| build_image | string | aws/codebuild/standard:7.0 | Build environment |
| deploy_strategy | string | rolling | rolling, blue_green, canary |
| approval_required | bool | false | Manual approval gate |
┌──────────┐ ┌───────┐ ┌──────┐ ┌─────────────┐
│ Source │───│ Build │───│ Test │───│ Deploy-Dev │
└──────────┘ └───────┘ └──────┘ └──────┬──────┘
│
┌─────────────┐ ┌──────────┐ ┌──────────┴──────────┐
│ Deploy-Prod │◄──│ Approval │◄──│ Deploy-Staging │
└─────────────┘ └──────────┘ └─────────────────────┘
# Create pipeline with GitHub source
aws codepipeline create-pipeline --cli-input-json '{
"pipeline": {
"name": "my-app-pipeline",
"roleArn": "arn:aws:iam::123456789012:role/CodePipelineRole",
"stages": [
{
"name": "Source",
"actions": [{
"name": "GitHub",
"actionTypeId": {
"category": "Source",
"owner": "ThirdParty",
"provider": "GitHub",
"version": "2"
},
"configuration": {
"ConnectionArn": "arn:aws:codestar-connections:...",
"FullRepositoryId": "org/repo",
"BranchName": "main"
},
"outputArtifacts": [{"name": "SourceOutput"}]
}]
},
{
"name": "Build",
"actions": [{
"name": "CodeBuild",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"inputArtifacts": [{"name": "SourceOutput"}],
"outputArtifacts": [{"name": "BuildOutput"}],
"configuration": {
"ProjectName": "my-build-project"
}
}]
}
]
}
}'
# buildspec.yml
version: 0.2
env:
variables:
NODE_ENV: production
secrets-manager:
DB_PASSWORD: prod/db:password
phases:
install:
runtime-versions:
nodejs: 20
commands:
- npm ci
pre_build:
commands:
- npm run lint
- npm run test:unit
build:
commands:
- npm run build
- docker build -t $ECR_REPO:$CODEBUILD_RESOLVED_SOURCE_VERSION .
post_build:
commands:
- docker push $ECR_REPO:$CODEBUILD_RESOLVED_SOURCE_VERSION
- printf '[{"name":"app","imageUri":"%s"}]' $ECR_REPO:$CODEBUILD_RESOLVED_SOURCE_VERSION > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json
- appspec.yml
cache:
paths:
- node_modules/**/*
| Strategy | Risk | Rollback | Use Case |
|---|---|---|---|
| Rolling | Medium | Minutes | Standard updates |
| Blue/Green | Low | Instant | Zero-downtime |
| Canary | Lowest | Instant | Gradual validation |
| All-at-once | High | Minutes | Dev/test only |
| Symptom | Cause | Solution |
|---|---|---|
| Source failed | Connection issue | Check GitHub connection |
| Build failed | buildspec error | Check CodeBuild logs |
| Deploy failed | IAM or target | Check deployment logs |
| Stuck at approval | No approver | Notify approvers |
# Get failed execution details
aws codepipeline get-pipeline-execution \
--pipeline-name my-pipeline \
--pipeline-execution-id abc-123
# Get action execution details
aws codepipeline list-action-executions \
--pipeline-name my-pipeline \
--filter 'pipelineExecutionId=abc-123'
def test_buildspec_syntax():
# Arrange
buildspec_path = "buildspec.yml"
# Act
with open(buildspec_path) as f:
buildspec = yaml.safe_load(f)
# Assert
assert buildspec['version'] == 0.2
assert 'phases' in buildspec
assert 'build' in buildspec['phases']
assets/buildspec.yml - CodeBuild specification templateThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.