Logo Aws Codepipeline And Codedeploy

Aws Codepipeline And Codedeploy

Cộng đồng
selvarajmurugesan90
aws-codepipeline-and-codedeploy

Designs AWS CodePipeline stage/action structure and integrates it with CodeDeploy deployment groups and appspec.yml for EC2/on-prem, ECS, or Lambda deploys. Use when the user asks to "set up CodePipeline," "add a CodeDeploy deployment group," "write an appspec.yml," "wire CodePipeline to CodeDeploy," "troubleshoot a stuck/failed CodePipeline action," or "add a manual approval action before an AWS deploy."

Tổng quan

Nhà phát hànhselvarajmurugesan90
Kho mãops-engineering-skills
Tên kỹ năngaws-codepipeline-and-codedeploy
Sao
44
Bản fork
18
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Đầy đủ trong hướng dẫn

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được selvarajmurugesan90 công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Aws Codepipeline And Codedeploy trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/selvarajmurugesan90/ops-engineering-skills/tree/main/plugins/cicd-tooling/skills/aws-codepipeline-and-codedeploy
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/selvarajmurugesan90/ops-engineering-skills.git /tmp/ops-engineering-skills
mkdir -p .claude/skills
cp -r /tmp/ops-engineering-skills/plugins/cicd-tooling/skills/aws-codepipeline-and-codedeploy .claude/skills/aws-codepipeline-and-codedeploy
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Aws Codepipeline And Codedeploy trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Aws Codepipeline And Codedeploy ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Aws Codepipeline And Codedeploy không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

AWS CodePipeline and CodeDeploy

Purpose

AWS CodePipeline orchestrates a release as a sequence of stages, each containing one or more actions (source, build, test, approval, deploy) that can run in parallel within a stage, while CodeDeploy handles the actual deployment mechanics — rolling out a new revision to EC2/on-prem instances, an ECS service, or a Lambda function according to a deployment group's configuration and an appspec.yml's lifecycle hooks. This skill covers the CodePipeline stage/action JSON/YAML structure and how it integrates with CodeDeploy specifically — not the generic pipeline-design concepts covered in ci-cd-pipeline-design, which apply here too but aren't repeated.

When to use

  • Standing up a new CodePipeline for an application already built elsewhere (or with a CodeBuild stage) that needs to deploy via CodeDeploy.
  • Writing or debugging an appspec.yml whose lifecycle hooks (BeforeInstall, AfterInstall, ApplicationStart, ValidateService) aren't firing in the expected order, or a hook script exits non-zero.
  • Configuring a CodeDeploy deployment group's deployment configuration (in-place vs. blue/green, CodeDeployDefault.OneAtATime vs. percentage- based) for EC2/on-prem, or the equivalent ECS/Lambda traffic-shifting options.
  • Adding a manual approval action to a CodePipeline before a production deploy stage.
  • Diagnosing a CodePipeline execution stuck or failed at a specific stage/ action, or a CodeDeploy deployment that failed a lifecycle hook or health check.

Prerequisites & environment

  • An AWS account with IAM permissions to create/manage CodePipeline pipelines, CodeDeploy applications/deployment groups, and (for EC2/on- prem deploys) an IAM instance profile on target instances allowing the CodeDeploy agent to pull deployment bundles from S3.
  • The CodeDeploy agent installed and running on target EC2/on-prem instances (not needed for ECS or Lambda deployment types, which use CodeDeploy's native integration instead).
  • A CodePipeline service role with permission to invoke each stage's action provider (CodeCommit/GitHub/S3 for source, CodeBuild for build, CodeDeploy for deploy) — least-privilege scoped per action, not a single account-wide admin role.
  • An S3 artifact bucket (CodePipeline's default artifact store, or a specified one) that all pipeline stages can read/write to pass build output between stages.
  • For blue/green EC2 deployments: an Elastic Load Balancer (ALB/CLB) already provisioned and referenced in the deployment group config.

Step-by-step guidance

  1. Model the pipeline as stages of parallelizable actions, not one flat list — actions within a stage can run in parallel via runOrder, while stages themselves execute sequentially:

    json
    {
      "pipeline": {
        "name": "checkout-api-pipeline",
        "roleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/codepipeline-service-role",
        "artifactStore": { "type": "S3", "location": "codepipeline-artifacts-<AWS_ACCOUNT_ID>" },
        "stages": [
          {
            "name": "Source",
            "actions": [{
              "name": "Source",
              "actionTypeId": { "category": "Source", "owner": "AWS", "provider": "CodeStarSourceConnection", "version": "1" },
              "configuration": { "ConnectionArn": "arn:aws:codestar-connections:<REGION>:<AWS_ACCOUNT_ID>:connection/<CONNECTION_ID>", "FullRepositoryId": "org/checkout-api", "BranchName": "main" },
              "outputArtifacts": [{ "name": "SourceOutput" }]
            }]
          },
          {
            "name": "Build",
            "actions": [{
              "name": "Build",
              "actionTypeId": { "category": "Build", "owner": "AWS", "provider": "CodeBuild", "version": "1" },
              "configuration": { "ProjectName": "checkout-api-build" },
              "inputArtifacts": [{ "name": "SourceOutput" }],
              "outputArtifacts": [{ "name": "BuildOutput" }]
            }]
          },
          {
            "name": "ApproveProduction",
            "actions": [{
              "name": "ManualApproval",
              "actionTypeId": { "category": "Approval", "owner": "AWS", "provider": "Manual", "version": "1" },
              "configuration": { "CustomData": "Approve deploy of build ${env.CODEBUILD_RESOLVED_SOURCE_VERSION} to production" }
            }]
          },
          {
            "name": "Deploy",
            "actions": [{
              "name": "Deploy",
              "actionTypeId": { "category": "Deploy", "owner": "AWS", "provider": "CodeDeploy", "version": "1" },
              "configuration": { "ApplicationName": "checkout-api", "DeploymentGroupName": "checkout-api-production" },
              "inputArtifacts": [{ "name": "BuildOutput" }]
            }]
          }
        ]
      }
    }

    The ApproveProduction stage blocks pipeline progress until a human approves/rejects in the console or via aws codepipeline put-approval-result — this is CodePipeline's equivalent of a GitHub Actions protected environment: or GitLab when: manual.

  2. Write appspec.yml to define the deployment's file mapping and lifecycle hooks (EC2/on-prem example — the revision bundle's root):

    yaml
    version: 0.0
    os: linux
    files:
      - source: /
        destination: /opt/checkout-api
    permissions:
      - object: /opt/checkout-api
        owner: appuser
        group: appuser
        mode: "755"
    hooks:
      BeforeInstall:
        - location: scripts/stop_service.sh
          timeout: 60
      AfterInstall:
        - location: scripts/install_deps.sh
          timeout: 300
      ApplicationStart:
        - location: scripts/start_service.sh
          timeout: 60
      ValidateService:
        - location: scripts/health_check.sh
          timeout: 120

    Hooks run strictly in this order (BeforeInstall → AfterInstall → ApplicationStart → ValidateService, plus ApplicationStop/ BeforeBlockTraffic/AfterBlockTraffic/BeforeAllowTraffic/ AfterAllowTraffic for load-balanced deployments) — a hook script must exit 0 for the deployment to proceed to the next hook.

  3. Choose the deployment type and configuration deliberately. For EC2/on-prem, in-place CodeDeployDefault.OneAtATime is safest for stateful services but slowest; percentage-based (CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce) trades safety for speed. Blue/green (deploymentType: BLUE_GREEN) provisions a new instance set behind the load balancer and shifts traffic only after ValidateService passes, giving an automatic rollback path if validation fails:

    json
    {
      "applicationName": "checkout-api",
      "deploymentGroupName": "checkout-api-production",
      "deploymentConfigName": "CodeDeployDefault.OneAtATime",
      "autoScalingGroups": ["checkout-api-asg"],
      "loadBalancerInfo": { "elbInfoList": [{ "name": "checkout-api-alb-tg" }] },
      "deploymentStyle": { "deploymentType": "BLUE_GREEN", "deploymentOption": "WITH_TRAFFIC_CONTROL" },
      "blueGreenDeploymentConfiguration": {
        "terminateBlueInstancesOnDeploymentSuccess": { "action": "TERMINATE", "terminationWaitTimeInMinutes": 30 }
      }
    }
  4. For ECS deployments, CodeDeploy uses appspec.yml referencing the task definition and container, with CodePipeline's ECS deploy provider (blue/green via CodeDeploy) or the simpler native ECS provider (rolling update, no CodeDeploy):

    yaml
    version: 0.0
    Resources:
      - TargetService:
          Type: AWS::ECS::Service
          Properties:
            TaskDefinition: "<TASK_DEFINITION_ARN>"
            LoadBalancerInfo:
              ContainerName: "checkout-api"
              ContainerPort: 8080
  5. Wire automatic rollback on deployment failure at the deployment group level rather than relying on someone to notice and manually roll back:

    json
    "autoRollbackConfiguration": {
      "enabled": true,
      "events": ["DEPLOYMENT_FAILURE", "DEPLOYMENT_STOP_ON_ALARM"]
    }

    Pair with a CloudWatch alarm (DEPLOYMENT_STOP_ON_ALARM) tied to a real health metric (error rate, latency) so a deployment that passes ValidateService but degrades under real traffic still triggers rollback.

  6. Scope IAM roles per action/service, not one shared admin role — the CodePipeline service role needs only codebuild:StartBuild, codedeploy:CreateDeployment, s3:*Object on the artifact bucket, etc., scoped to the specific resources it orchestrates; the CodeDeploy service role and the EC2 instance profile are separate roles with their own narrower scopes.

  7. Verify a stuck pipeline execution's specific failed action via aws codepipeline get-pipeline-state --name <pipeline> and the CodeDeploy deployment's event log (aws deploy get-deployment --deployment-id <id>) rather than only looking at the pipeline's overall red/green status — the actual error (a failed hook script, an IAM permission denial, a health check timeout) is in the deployment's lifecycle event detail, not the pipeline summary.

Best practices

  • Put a manual Approval action immediately before any production Deploy action, and route its notification (via SNS) to the actual on-call/release channel — an approval stage nobody sees defeats the purpose.
  • Always enable autoRollbackConfiguration for production deployment groups; a deployment with no rollback path turns a bad release into an extended incident instead of an automatic recovery.
  • Use blue/green (or ECS/Lambda's native traffic-shifting) for anything where a bad deploy causes user-facing errors before you can react manually — in-place AllAtOnce should be reserved for low-risk, easily-recoverable services.
  • Keep appspec.yml hook scripts idempotent and fast-failing (exit non-zero immediately on a real problem) — a hook that hangs blocks the whole deployment until its timeout is hit.
  • Store deployment configuration (deployment group settings, alarm ARNs) as infrastructure-as-code (CloudFormation/CDK/Terraform) alongside the pipeline definition, not as manually-clicked console configuration that can't be diffed in a PR.
  • Tag pipeline artifacts and CodeDeploy revisions with the source commit SHA so a running deployment is traceable back to exactly which commit produced it, mirroring the traceability guidance in ci-cd-pipeline-design.

Common pitfalls

  • Symptom: A CodePipeline execution shows "Failed" on the Deploy stage with no further detail in the pipeline console view. Fix: Pull the specific CodeDeploy deployment's event log (aws deploy get-deployment-instance / the CodeDeploy console's deployment details) — the actual cause (a specific appspec.yml hook script exiting non-zero, a health check failing, an instance not running the CodeDeploy agent) is only visible there, not in the pipeline's stage-level status.

  • Symptom: A deployment "succeeds" per CodeDeploy but the application is actually broken for users. Fix: The ValidateService hook is likely missing or too shallow (e.g. just checking the process is running, not that it responds correctly); write a real health check that exercises a meaningful endpoint, and pair it with DEPLOYMENT_STOP_ON_ALARM auto-rollback tied to a post-deploy CloudWatch alarm so problems caught only under real traffic still trigger rollback.

  • Symptom: A blue/green EC2 deployment leaves the old ("blue") instance set running indefinitely, doubling infrastructure cost. Fix: Set blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess with an explicit action: TERMINATE and a reasonable terminationWaitTimeInMinutes, rather than leaving it at KEEP_ALIVE indefinitely by default/oversight.

  • Symptom: The pipeline's IAM service role has broad codedeploy:*/s3:* permissions "to make it work," and a compromised pipeline execution can affect resources far outside its intended scope. Fix: Scope the CodePipeline and CodeDeploy service roles to the specific applications/deployment groups/buckets they orchestrate, using resource ARNs rather than wildcards — treat an overly broad pipeline role as a real security finding, not a convenience shortcut.

  • Symptom: Someone manually triggers aws deploy create-deployment directly against production, bypassing the pipeline's approval stage entirely, and there's no record of who approved it or why. Fix: This is a destructive/dangerous action if used to skip an intended approval gate — restrict direct codedeploy:CreateDeployment IAM permission on production deployment groups to the pipeline's own service role, so a production deploy can only happen through the pipeline (and its approval stage), not by a human or script calling the API directly.

Worked example

Scenario: A checkout service deploys to an EC2 Auto Scaling Group behind an ALB, using CodePipeline (source → build → manual approval → blue/green CodeDeploy) with automatic rollback on failed health checks.

Pipeline stage sequence (as JSON stage array, abbreviated to the deploy portion):

json
{
  "name": "Deploy",
  "actions": [{
    "name": "BlueGreenDeploy",
    "actionTypeId": { "category": "Deploy", "owner": "AWS", "provider": "CodeDeploy", "version": "1" },
    "configuration": {
      "ApplicationName": "checkout-api",
      "DeploymentGroupName": "checkout-api-production-bg"
    },
    "inputArtifacts": [{ "name": "BuildOutput" }]
  }]
}

Deployment group (created via CloudFormation, abbreviated):

yaml
CheckoutApiDeploymentGroup:
  Type: AWS::CodeDeploy::DeploymentGroup
  Properties:
    ApplicationName: checkout-api
    DeploymentGroupName: checkout-api-production-bg
    DeploymentConfigName: CodeDeployDefault.ECSAllAtOnce
    ServiceRoleArn: !GetAtt CodeDeployServiceRole.Arn
    AutoScalingGroups: [!Ref CheckoutApiAsg]
    DeploymentStyle:
      DeploymentType: BLUE_GREEN
      DeploymentOption: WITH_TRAFFIC_CONTROL
    BlueGreenDeploymentConfiguration:
      TerminateBlueInstancesOnDeploymentSuccess:
        Action: TERMINATE
        TerminationWaitTimeInMinutes: 15
    AutoRollbackConfiguration:
      Enabled: true
      Events: [DEPLOYMENT_FAILURE, DEPLOYMENT_STOP_ON_ALARM]
    AlarmConfiguration:
      Enabled: true
      Alarms:
        - Name: checkout-api-5xx-rate-high

appspec.yml in the build artifact:

yaml
version: 0.0
os: linux
files:
  - source: /
    destination: /opt/checkout-api
hooks:
  AfterInstall:
    - location: scripts/install_deps.sh
      timeout: 300
  ApplicationStart:
    - location: scripts/start_service.sh
      timeout: 60
  ValidateService:
    - location: scripts/health_check.sh
      timeout: 120

scripts/health_check.sh curls /healthz and exits non-zero on a non-200 response, so a bad build fails ValidateService before traffic ever shifts to the new ("green") instance set, and the pre-existing checkout-api-5xx-rate-high CloudWatch alarm triggers automatic rollback if errors spike shortly after traffic does shift.

Cross-references

  • ci-cd-pipeline-design — vendor-neutral stage/gate/rollback concepts this pipeline implements in AWS-specific terms.
  • github-actions-centralized-reusable-workflows — comparable centralized-pipeline pattern if the build stage is migrated off CodeBuild to GitHub Actions while keeping CodeDeploy for the deploy stage.
  • secure-cicd-gates — where to place scan actions relative to the manual approval and deploy stages here.

Câu hỏi thường gặp

Kỹ năng AI Aws Codepipeline And Codedeploy làm được gì?

Designs AWS CodePipeline stage/action structure and integrates it with CodeDeploy deployment groups and appspec.yml for EC2/on-prem, ECS, or Lambda deploys. Use when the user asks to "set up CodePipeline," "add a CodeDeploy deployment group," "write an appspec.yml," "wire CodePipeline to CodeDeploy," "troubleshoot a stuck/failed CodePipeline action," or "add a manual approval action before an AWS deploy."

Vì sao nên dùng Aws Codepipeline And Codedeploy trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Aws Codepipeline And Codedeploy là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Aws Codepipeline And Codedeploy trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/selvarajmurugesan90/ops-engineering-skills/tree/main/plugins/cicd-tooling/skills/aws-codepipeline-and-codedeploy. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Aws Codepipeline And Codedeploy?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Aws Codepipeline And Codedeploy với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Aws Codepipeline And Codedeploy với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Aws Codepipeline And Codedeploy có miễn phí không?

Có. Kỹ năng này được selvarajmurugesan90 phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇