CodePipeline V2 Deployer
Mindset
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Quick reference — deployment checklist
| Dimension |
Requirement |
Step |
| Pipeline type |
V2 (event-driven, no polling) |
1 |
| Source |
CodeCommit / S3 / GitHub via CodeConnections |
2 |
| Trigger |
Event-driven filter (branch, paths, tags) |
3 |
| Build |
CodeBuild project, artifacts to S3 |
4 |
| Deploy |
CloudFormation / ECS / S3 / Service Catalog / CodeDeploy |
5 |
| Manual approval |
Optional approval gate between stages |
6 |
| Namespace variables |
Variables passed between stages |
7 |
| Cross-account |
KMS key + IAM roles for target accounts |
8 |
| Artifact bucket |
Block public access + KMS encryption |
9 |
| Pipeline IAM role |
Scoped to source/build/deploy actions |
10 |
Pre-flight: deployment specification gate
Validate the input specification. Several requirements block
deployment — proceeding with an invalid spec produces a
non-functional or insecure pipeline.
Live-account pre-flight checks (skip if doing offline plan):
- Verify IAM permissions for
codepipeline:CreatePipeline,
UpdatePipeline, codebuild:CreateProject (or existing project
ARN), iam:CreateRole, iam:AttachRolePolicy, kms:CreateKey,
kms:PutKeyPolicy, s3:CreateBucket, s3:PutBucketPolicy,
s3:PutPublicAccessBlock.
- For GitHub source, verify a CodeConnections connection exists in
us-east-1 (the connection must be in us-east-1 even if the
pipeline is in another region) and is in AVAILABLE state.
- For cross-account deploy, verify the target account ID, KMS key
ARN, and cross-account IAM role ARN. The KMS key policy MUST grant
the pipeline role
kms:GenerateDataKey and kms:Decrypt.
- For CloudFormation deploy, verify the target stack name and the IAM
execution role in the target account. For ECS, verify the cluster,
service, and task definition family exist.
| Attribute |
Value |
Effect on plan |
pipelineType |
V2 / V1 |
V2 = event-driven, triggers required, namespace variables supported. V1 = polling, no triggers, no variables. |
| Source |
CodeCommit / S3 / GitHub (CodeConnections) |
Determines trigger type and connection ARN. |
| Trigger |
event-driven filter |
Required for V2 — without one, the pipeline never auto-runs. |
| Deploy |
CloudFormation / ECS / S3 / ServiceCatalog / CodeDeploy |
Determines IAM role policy scope and (for CFN) change-set mode. |
| Cross-account |
true / false |
If true, requires KMS key policy + cross-account IAM role. |
If the deployment spec is incomplete (missing source, trigger, or
deploy action), output:
PIPELINE_SPEC: <name-or-unknown>
VERDICT: PREREQUISITES_MISSING
REASON: Deployment specification is missing required fields (<list>).
Cannot produce a deployment plan without <field> — the resulting
pipeline would be non-functional or insecure.
REQUIRED:
- source (CodeCommit / S3 / GitHub via CodeConnections)
- trigger_filter (branch / paths / tags — required for V2)
- deploy_action (CloudFormation / ECS / S3 / ServiceCatalog / CodeDeploy)
- pipeline_role_arn or role policy document
STRICT output contract
When this skill is invoked with a V2 pipeline provisioning request,
the agent MUST respond with the deployment plan defined in the "Output
format" section using the literal all-caps labels PIPELINE_SPEC:,
VERDICT:, ARCHITECTURE:, CHECKLIST:, FINDINGS:, and
DEPLOY_COMMANDS:. Do NOT preface the block with prose, headings, or
disclaimers — emit it as the first lines of the response. This
contract is what assertion-based evals and downstream provisioning
pipelines rely on; deviating from the literal labels breaks automation
silently.
If any prerequisite is missing, the verdict is
PREREQUISITES_MISSING with a specific gap citation in the checklist
(marked [✗]), and READY_TO_DEPLOY MUST NOT also appear. The two
verdicts are mutually exclusive.
Quick navigation
| Section |
When to read |
| Pre-flight specification gate |
Always — verify before planning |
| Step 0 — Expert heuristic: V1 → V2 migration |
Migrating from polling |
| Step 1 — Pipeline type confirmation (V2) |
Boundary call |
| Step 2-3 — Source + Trigger |
CodeCommit / S3 / GitHub + filter scoping |
| Step 4-5 — Build (CodeBuild) + Deploy actions |
Action wiring |
| Step 6-7 — Manual approval + Namespace variables |
Gated releases, stage-to-stage data |
| Step 8-10 — Cross-account + Artifact bucket + Pipeline role |
Security + IAM |
| NEVER do these things |
Review before signing off |
| Output format |
The literal plan template |
| references/triggers-and-namespace-variables-reference.md |
Trigger filter + variable deep dive |
| references/cross-account-and-deploy-actions-reference.md |
Cross-account + per-deploy-type contracts |
Process — Architecture planning (apply in order)
Step 0: Expert heuristic — V1 to V2 migration gotchas
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Step 1: Pipeline type confirmation (V2)
| Dimension |
V1 |
V2 |
| Trigger model |
Polling or CloudWatch Events rule |
Triggers (event-driven, sub-second) |
| Trigger filter |
Branch only (via EventBridge rule) |
Branch, paths, tags, glob patterns |
| Namespace variables |
No |
Yes (stage-to-stage) |
| Stage conditions |
No |
Yes (skip stages based on variables) |
| Pricing |
$1/active pipeline/month |
$0.002/pipeline-execution |
Pick V2 when ALL hold: source supports event-driven triggers
(CodeCommit, S3 via EventBridge, GitHub via CodeConnections); you want
sub-second trigger latency (vs V1's ~17s polling); you want
pipeline-level variables or stage conditions; you want per-execution
pricing. Pick V1 only for legacy pipelines that cannot be migrated.
New pipelines should default to V2.
Step 2: Source action
Moved verbatim to references/worked-examples.md - load on demand (see References below).
| Source |
Provider |
Connection |
Trigger type |
| CodeCommit |
CodeCommit |
Native (no connection) |
referenceCreated / referenceUpdated |
| S3 |
S3 |
Native |
PutObject via EventBridge |
| GitHub |
CodeStarSourceConnection |
CodeConnections (us-east-1) |
push events |
| GitLab / Bitbucket |
CodeStarSourceConnection |
CodeConnections |
push events |
The connection ARN MUST be created in us-east-1 via
aws codeconnections create-connection, even if the pipeline is in
another region. The connection requires a one-time browser handshake
to authorize AWS to access the GitHub repo.
Step 3: Trigger configuration (event-driven filter)
V2 triggers replace V1's polling / CloudWatch Events rule. The filter
scopes which pushes start a run:
Moved verbatim to references/worked-examples.md - load on demand (see References below).
Critical trigger rules:
- A trigger with NO filter fires on EVERY push to EVERY branch —
always scope
Branches.Includes to production branches.
Branches.Includes supports glob (release/* matches
release/v1). main is exact-match only.
FilePaths.Includes limits runs to changes under those paths. Use
Excludes for docs/CI-only changes.
Tags filters on Git tags (annotated or lightweight). Useful for
"deploy only on tagged releases."
- Multiple triggers are OR'd; within a trigger, branches/paths/tags
are AND'd.
Step 4: Build (CodeBuild)
Moved verbatim to references/worked-examples.md - load on demand (see References below).
The Namespace: BuildVars block exposes the build's exported
variables to downstream stages as #{BuildVars.IMAGE_TAG}. The
CodeBuild project must declare the variables it exports in
buildspec.yml under exported-variables:
Step 5: Deploy actions
| Deploy type |
Provider |
Key configuration |
| CloudFormation |
CloudFormation |
ActionMode: CREATE_REPLACE, StackName, RoleArn (target), TemplatePath |
| ECS |
ECS |
ClusterName, ServiceName, Image1 (direct image) or TaskDefinitionTemplatePath |
| S3 deploy |
S3 |
BucketName, Extract: true (unzip artifact) |
| Service Catalog |
ServiceCatalog |
ProductId, ProvisionedProductName |
| CodeDeploy |
CodeDeploy |
ApplicationName, DeploymentGroupName, DeploymentStyle: BLUE_GREEN / IN_PLACE |
| Manual approval |
Manual |
ExternalEntityLink (optional), CustomData (reviewer context) |
Moved verbatim to references/worked-examples.md - load on demand (see References below).
For cross-account, RoleArn points to a role in the TARGET account;
the pipeline role in the source account needs sts:AssumeRole on it.
ECS deploy (direct image): uses Image1: #{BuildVars.IMAGE_URI}
(a namespace variable from Build); the deploy cannot start until the
build's exported variable is resolved. Configure ClusterName,
ServiceName, Image1.
CodeDeploy for EC2 (in-place or blue/green): configure
ApplicationName, DeploymentGroupName, DeploymentStyle
(IN_PLACE or BLUE_GREEN). EC2 instances must have the CodeDeploy
agent and the CodeDeploy service role configured.
Step 6: Manual approval gate
Moved verbatim to references/worked-examples.md - load on demand (see References below).
The pipeline blocks until put-job-approval-result --result APPROVED
(or REJECTED). Configure an SNS topic to notify reviewers via
email/Slack. ExternalEntityLink points to a Change Management
ticket; CustomData is free-form reviewer context. Approval timeouts
are NOT enforced — the pipeline waits indefinitely. Use an external
scheduled Lambda to auto-reject stale approvals.
Step 7: Namespace variables
Defined by setting Namespace: <name> on an action and exporting
variables from the action (CodeBuild's exported-variables,
CloudFormation's OutputFileName, or literal Variables block).
Consumption patterns:
- Downstream action configuration:
Image1: #{BuildVars.IMAGE_URI}
- Stage condition:
Conditions: [{ConditionKey: "#{BuildVars.ENV}", ConditionValue: prod, Operator: StringEquals}]
- Nested namespace:
#{BuildVars.Deeply.Nested.Key} (dotted paths for JSON-exported values)
Critical variable rules:
- Variables flow forward only — a stage cannot consume a variable from
a later stage.
- A missing variable renders as empty string (no error). Validate
with a stage condition before using in a deploy.
- Variables are scoped per-execution. Concurrent pipeline runs do not
share variable state.
- Secrets must NOT be namespace variables — they appear in plaintext
in the pipeline execution history. Use Secrets Manager or Parameter
Store SecureString, referenced by ARN in the action's IAM role.
Step 8: Cross-account deployment
Moved verbatim to references/cross-account-and-deploy-actions-reference.md - load on demand (see References below).
Step 9: Artifact bucket security
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Step 10: Pipeline IAM role
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Expert heuristic: trigger filter precision and the "every push" trap
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Expert heuristic: namespace variables and the silent-empty-string failure
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
Output format (per V2 pipeline deployment plan)
Every V2 deployment plan MUST emit a single block using these literal
labels, in this order. Do NOT substitute markdown headings or camelCase
variants — assertion-based evals and downstream provisioning parse the
literal labels PIPELINE:, VERDICT:, CHECKLIST:, FINDINGS:,
DEPLOY_COMMANDS:.
PIPELINE: <pipeline-name>
VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING
CHECKLIST:
[x] Pipeline type: V2 (event-driven, no polling; PollForSourceChanges=false)
[x] Source: CodeCommit <repo/main> | S3 <bucket/key> | GitHub via CodeConnections <connection-arn + repo/branch>
[x] Trigger filter: Branches=[main], FilePaths=src/**, Tags=deploy=prod (NOT unscoped)
[x] Build: CodeBuild project <name>, exports namespace variables <list>
[x] Test stage: CodeBuild <test-project> with unit + integration tests
[x] Manual approval: enabled between <stage A> and <stage B> | none (ExternalEntityLink + SNS topic arn)
[x] Deploy: CloudFormation <CREATE_REPLACE on stack> | ECS <cluster/service> | CodeDeploy <app/group> | S3 <bucket> | ServiceCatalog <product>
[x] Artifacts: S3 <bucket-name> (block-public-access=true, SSE-KMS CMK <key-arn>, versioning=enabled)
[x] Cross-account: target=<account>, KMS key policy grants kms:Decrypt+GenerateDataKey to <role>, IAM role <arn> | n/a
[x] Pipeline IAM role: arn:aws:iam::<source>:role/<name> (no wildcard resources on S3/KMS/CodeBuild)
[x] Namespace variables: validated non-empty via stage condition (no silent empty strings)
FINDINGS:
- [INFO] <observation (pricing, propagation time, etc.)>
- [WARN] <caution (trigger scoping, approval timeout, etc.)>
DEPLOY_COMMANDS:
<ordered list of aws codepipeline / kms / iam / s3api commands>
FORBIDDEN output patterns — NEVER
NEVER emit VERDICT: READY_TO_DEPLOY while any CHECKLIST item is
[ ] (unchecked). Any unmet requirement forces
PREREQUISITES_MISSING.
NEVER emit a V2 pipeline trigger without a filter (no Branches,
FilePaths, or Tags criteria). An unscoped trigger fires on EVERY
push to EVERY branch — flooding history, burning per-execution
costs ($0.002 × N feature pushes/day), and risking unintended prod
deploys from feature branches.
NEVER emit a cross-account deploy plan where the KMS key policy is
missing kms:Decrypt and kms:GenerateDataKey grants to the target
account's deployment role. S3 bucket policy alone does NOT grant
cross-account access to encrypted objects — the deploy fails with
"Access Denied" that looks like S3 but is actually KMS.
NEVER emit a pipeline IAM role with "Resource": "*" on s3:GetObject,
kms:*, or codebuild:*. Wildcards create a privilege escalation
path — a malicious CodeBuild project can exfiltrate other pipelines'
artifacts. Scope every resource to the exact ARN.
NEVER emit secrets (tokens, passwords, signing keys) as namespace
variables. Namespace variables render in plaintext in CloudTrail,
the pipeline execution history, and the console. Use Secrets Manager
or Parameter Store SecureString, referenced by ARN in the action's
IAM role.
NEVER emit a V2 pipeline with PollForSourceChanges: true. V2
rejects this with a confusing "Invalid action configuration" error.
After V1→V2 migration, set DetectOptions: false and add a trigger
block. Also delete the legacy CloudWatch Events rule — a leftover
rule fires alongside the V2 trigger and produces duplicate executions.
NEVER emit a deployment plan that consumes a namespace variable
(e.g., #{BuildVars.IMAGE_URI}) without a stage condition validating
the variable is non-empty. A missing variable silently renders as
"" — ECS rejects the empty image string with a confusing
"InvalidParameterException", not a clear "variable undefined" error.
Worked example — READY_TO_DEPLOY (CI/CD with test stage + manual approval + prod CFN deploy)
PIPELINE: payments-service-cicd
VERDICT: READY_TO_DEPLOY
CHECKLIST:
[x] Pipeline type: V2 (event-driven; PollForSourceChanges: false — replaced legacy V1 CloudWatch Events rule)
[x] Source: CodeCommit repo payments-service, branch main (OutputArtifacts: SourceOutput)
[x] Trigger filter: Branches=[main], FilePaths.Includes=[src/**], FilePaths.Excludes=[docs/**, README.md] (NO unscoped trigger)
[x] Build: CodeBuild project payments-service-build, exports IMAGE_URI, IMAGE_TAG, BUILD_VERSION
[x] Test stage: CodeBuild project payments-service-tests (unit + integration, buildspec at tests/buildspec.yml) — gates Build stage via InputArtifact
[x] Manual approval: enabled between Test and DeployProd (ExternalEntityLink: https://internal.example.com/change/CHG-78901, SNS topic arn:aws:sns:us-east-1:111111111111:prod-payments-approval)
[x] Deploy: CloudFormation CREATE_REPLACE on stack prod-payments-service, RoleArn arn:aws:iam::222222222222:role/CrossAccountCFNExecution (target account 222222222222), TemplatePath BuildOutput::template.yaml, Capabilities CAPABILITY_IAM
[x] Artifacts: S3 payments-pipeline-artifacts (block-public-access all true, SSE-KMS CMK arn:aws:kms:us-east-1:111111111111:key/abc-123, versioning enabled, lifecycle Glacier 90d)
[x] Cross-account: target=222222222222, KMS key policy grants kms:Decrypt+GenerateDataKey to arn:aws:iam::222222222222:role/CrossAccountCFNExecution, IAM role trust allows arn:aws:iam::111111111111:role/payments-pipeline-role
[x] Pipeline IAM role: arn:aws:iam::111111111111:role/payments-pipeline-role (scoped to exact ARNs — no wildcards on S3/KMS/CodeBuild/CodeCommit; iam:PassRole scoped to CrossAccountCFNExecution)
[x] Namespace variables: validated via stage condition on DeployProd — `Conditions: [{ConditionKey: "#{BuildVars.IMAGE_URI}", Operator: StringEquals, ConditionValue: "", Not: true}]` (empty IMAGE_URI blocks deploy)
FINDINGS:
- [INFO] Pricing: $0.002/execution + $1/active pipeline/month + $0.01/build-minute for CodeBuild
- [WARN] Manual approval has no enforced timeout — wire an external scheduled Lambda to auto-reject approvals older than 48 hours
- [WARN] After V1→V2 migration, delete the legacy CloudWatch Events rule payments-cicd-legacy-trigger to prevent duplicate executions
DEPLOY_COMMANDS:
# 1. Create KMS CMK with cross-account key policy (source account 111111111111)
aws kms create-key --policy file://kms-key-policy.json --description "payments-pipeline-artifacts CMK"
# 2. Create artifact bucket with block-public-access + KMS + versioning
aws s3api create-bucket --bucket payments-pipeline-artifacts --region us-east-1 \
--block-public-access BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-encryption --bucket payments-pipeline-artifacts \
--server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"arn:aws:kms:us-east-1:111111111111:key/abc-123"}}]}'
aws s3api put-bucket-versioning --bucket payments-pipeline-artifacts --versioning-configuration Status=Enabled
# 3. Create cross-account CFN execution role in TARGET account 222222222222
aws iam create-role --role-name CrossAccountCFNExecution --assume-role-policy-document file://trust-policy.json
# 4. Create the pipeline role in SOURCE account 111111111111
aws iam create-role --role-name payments-pipeline-role --assume-role-policy-document file://pipeline-trust-policy.json
aws iam put-role-policy --role-name payments-pipeline-role --policy-name scoped --policy-document file://pipeline-role-policy.json
# 5. Create the V2 pipeline (trigger filter scoped to main + src/**)
aws codepipeline create-pipeline --cli-input-json file://payments-service-cicd.json
# 6. Verify
aws codepipeline get-pipeline-state --name payments-service-cicd
Decision tree — V2 pipeline shape selection
Start: V2 deployment requirement
├─ Source = CodeCommit / GitHub via CodeConnections / S3 (event-driven capable)?
│ └─ No (legacy V1-only source) → emit ERROR — V2 requires event-driven source
├─ Cross-account deploy target?
│ ├─ Yes → KMS key policy grants kms:Decrypt + GenerateDataKey to target role?
│ │ ├─ Yes → CFN deploy action with RoleArn in target account
│ │ └─ No → PREREQUISITES_MISSING (KMS key policy is the actual blocker, not S3)
│ └─ No → same-account CFN / ECS / CodeDeploy / S3 / ServiceCatalog
├─ Gated release required?
│ ├─ Yes → Insert Manual approval action between Test and Deploy stages
│ │ (wire SNS topic for reviewer notification; schedule external Lambda
│ for stale-approval auto-reject — CodePipeline does NOT enforce timeouts)
│ └─ No → Continuous deploy (Test → Deploy direct)
├─ Trigger scope:
│ ├─ Filter present (Branches + FilePaths + Tags)? → READY_TO_DEPLOY
│ └─ No filter → PREREQUISITES_MISSING (unscoped trigger = every push to every branch)
└─ Namespace variables consumed downstream?
├─ Stage condition validates non-empty? → READY_TO_DEPLOY
└─ No validation → PREREQUISITES_MISSING (silent empty-string deploy risk)
Verification commands (run after deployment)
Moved verbatim to references/diagnostic-commands.md - load on demand (see References below).
Edge-case handling
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
NEVER do these things
NEVER create a V2 pipeline trigger without a filter. A trigger
with no Branches / FilePaths / Tags filter fires on EVERY
push to EVERY branch, flooding history, burning per-execution
costs, and risking unintended production deploys from feature
branches. Always scope Branches.Includes to production branches.
NEVER share the artifact bucket without KMS cross-account
policy. S3 bucket policy alone does NOT grant cross-account
access to encrypted objects. Without the matching KMS key policy
granting the target role kms:Decrypt and kms:GenerateDataKey,
the deploy action fails with "Access Denied" that looks like S3
but is actually KMS. Configure both.
NEVER pass secrets as namespace variables. Namespace variables
render in plaintext in CloudTrail, the pipeline execution history,
and the console. Use Secrets Manager or Parameter Store
SecureString, referenced by ARN in the action's IAM role.
NEVER use a wildcard in the pipeline IAM role for S3, KMS, or
CodeBuild. "Resource": "*" on s3:GetObject lets the pipeline
read any bucket. "Resource": "*" on codebuild:* lets it start
any CodeBuild project — a malicious project can exfiltrate other
pipelines' artifacts. Scope to exact ARNs.
NEVER leave PollForSourceChanges: true on a V2 pipeline. V2
rejects this with a confusing error. After V1 → V2 migration, set
DetectOptions: false and add a trigger. Also delete the legacy
CloudWatch Events rule from V1 — a leftover rule fires alongside
the V2 trigger and produces duplicate executions.
Additional hard constraints: approval timeouts are NOT enforced
(CodePipeline waits indefinitely); a missing namespace variable
silently renders as empty string; S3-managed encryption (SSE-S3) is
incompatible with cross-account (requires customer-managed KMS CMK);
iam:PassRole on * is a privilege escalation path.
Pre-flight safety checks (run before any deployment CLI)
Moved verbatim to references/diagnostic-commands.md - load on demand (see References below).
Remediation guidance
Moved verbatim to references/error-handling.md - load on demand (see References below).
References (load on demand)
- references/advanced-patterns.md - Step 0 + expert-heuristic deep dives, edge-case catalog, Step 9/10 hardening, recent AWS features
- references/worked-examples.md - per-step source / trigger / build / deploy / approval config examples
- references/diagnostic-commands.md - verification commands + pre-flight safety checks
- references/error-handling.md - remediation ordering + fixes
- references/cross-account-and-deploy-actions-reference.md - cross-account KMS/IAM wiring deep dive
- references/triggers-and-namespace-variables-reference.md - trigger filter + namespace variable detail
Domain
AWS CloudOps / CodePipeline V2 Provisioning.
Recent AWS features (2024-2026)
Moved verbatim to references/advanced-patterns.md - load on demand (see References below).
AWS documentation
1---2name: codepipeline-v2-deployer3description: Provisions production-grade CodePipeline V2-type pipelines with event-driven triggers (no polling), structure (stages and actions), source actions (CodeCommit, S3, GitHub via CodeConnections), build actions (CodeBuild), deploy actions (CloudFormation CREATE_CHANGE_SET / ECS deploy, S3 deploy, Service Catalog), manual approval actions, namespace variables passed between stages, cross-account deployment via KMS key policy + IAM roles, artifact bucket security (block public access, KMS encryption), and EC2/CodeDeploy deployments. Emits a READY_TO_DEPLOY checklist and ordered aws codepipeline create-pipeline commands. Use when provisioning a V2 pipeline, configuring event-based triggers with branch filter, wiring cross-account CloudFormation deploy, setting up manual approval gates, or replacing V1 polling pipelines with V2 event-driven.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline architecture planning. Live deployment uses aws codepipeline create-pipeline, update-pipeline, create-connection (CodeConnections), put-job- approval-result, aws kms create-key / put-key-policy, aws iam create-role / attach-role-policy, and aws s3api create-bucket with block-public-access (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/codepipeline-v2-deployer8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '1'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: DevTools15 task_type: deploy16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY_TO_DEPLOY | PREREQUISITES_MISSING19 when_to_use: Provisioning a new CodePipeline V2-type pipeline for production, configuring event-driven triggers with branch / path filter, wiring cross-account CloudFormation deploy via KMS-encrypted artifacts, setting up manual approval gates between stages, using namespace variables to pass data between stages, configuring ECS or S3 or Service Catalog deploy actions, replacing V1 polling pipelines with V2 event-driven triggers, or hardening the artifact bucket (block public access + KMS).20 activation_triggers: create a CodePipeline, provision pipeline V2, event-driven pipeline, CodePipeline trigger, CodePipeline branch filter, CodePipeline manual approval, cross-account deployment, namespace variables CodePipeline, CodePipeline GitHub source, CodeConnections pipeline, CodePipeline ECS deploy, CodePipeline CloudFormation deploy, CodePipeline CodeDeploy, V1 to V2 migration21 invocation_schema: 'Input shape (one of): (a) a deployment specification including pipeline type (V2), source (CodeCommit / S3 / GitHub / CodeConnections), build (CodeBuild), deploy (CloudFormation / ECS / S3 / Service Catalog / CodeDeploy), triggers (event filter), namespace variables, cross-account targets, manual approval stages; (b) a partial spec for interactive refinement; (c) an existing V1 pipeline for V2 migration review. Output shape: { PIPELINE_SPEC, VERDICT, ARCHITECTURE, CHECKLIST[], FINDINGS[], DEPLOY_COMMANDS } where VERDICT ∈ { READY_TO_DEPLOY, PREREQUISITES_MISSING, ERROR }.'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: CodePipeline, CodePipeline V2, pipeline type V2, event-driven pipeline, trigger, Git trigger, branch filter, CodeConnections, source action, CodeCommit source, S3 source, GitHub source, CodeBuild, build action, deploy action, CloudFormation deploy, ECS deploy, S3 deploy, Service Catalog deploy, CodeDeploy, EC2 deploy, manual approval, namespace variables, pipeline variables, cross-account, KMS key, artifact bucket, IAM role, CloudWatch Events, EventBridge25 tags: codepipeline, dev-tools, deploy, pipeline-v2, event-driven, triggers, codebuild, cloudformation-deploy, ecs-deploy, cross-account, manual-approval, namespace-variables, codeconnections, kms-artifacts26---2728# CodePipeline V2 Deployer2930## Mindset3132Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).333435## Quick reference — deployment checklist3637| Dimension | Requirement | Step |38|---|---|---|39| Pipeline type | V2 (event-driven, no polling) | 1 |40| Source | CodeCommit / S3 / GitHub via CodeConnections | 2 |41| Trigger | Event-driven filter (branch, paths, tags) | 3 |42| Build | CodeBuild project, artifacts to S3 | 4 |43| Deploy | CloudFormation / ECS / S3 / Service Catalog / CodeDeploy | 5 |44| Manual approval | Optional approval gate between stages | 6 |45| Namespace variables | Variables passed between stages | 7 |46| Cross-account | KMS key + IAM roles for target accounts | 8 |47| Artifact bucket | Block public access + KMS encryption | 9 |48| Pipeline IAM role | Scoped to source/build/deploy actions | 10 |4950## Pre-flight: deployment specification gate5152Validate the input specification. Several requirements **block53deployment** — proceeding with an invalid spec produces a54non-functional or insecure pipeline.5556**Live-account pre-flight checks (skip if doing offline plan):**571. Verify IAM permissions for `codepipeline:CreatePipeline`,58 `UpdatePipeline`, `codebuild:CreateProject` (or existing project59 ARN), `iam:CreateRole`, `iam:AttachRolePolicy`, `kms:CreateKey`,60 `kms:PutKeyPolicy`, `s3:CreateBucket`, `s3:PutBucketPolicy`,61 `s3:PutPublicAccessBlock`.622. For GitHub source, verify a CodeConnections connection exists in63 `us-east-1` (the connection must be in us-east-1 even if the64 pipeline is in another region) and is in `AVAILABLE` state.653. For cross-account deploy, verify the target account ID, KMS key66 ARN, and cross-account IAM role ARN. The KMS key policy MUST grant67 the pipeline role `kms:GenerateDataKey` and `kms:Decrypt`.684. For CloudFormation deploy, verify the target stack name and the IAM69 execution role in the target account. For ECS, verify the cluster,70 service, and task definition family exist.7172| Attribute | Value | Effect on plan |73|---|---|---|74| `pipelineType` | `V2` / `V1` | V2 = event-driven, triggers required, namespace variables supported. V1 = polling, no triggers, no variables. |75| Source | `CodeCommit` / `S3` / `GitHub` (CodeConnections) | Determines trigger type and connection ARN. |76| Trigger | `event-driven` filter | Required for V2 — without one, the pipeline never auto-runs. |77| Deploy | `CloudFormation` / `ECS` / `S3` / `ServiceCatalog` / `CodeDeploy` | Determines IAM role policy scope and (for CFN) change-set mode. |78| Cross-account | `true` / `false` | If true, requires KMS key policy + cross-account IAM role. |7980**If the deployment spec is incomplete** (missing source, trigger, or81deploy action), output:8283```text84PIPELINE_SPEC: <name-or-unknown>85VERDICT: PREREQUISITES_MISSING86REASON: Deployment specification is missing required fields (<list>).87Cannot produce a deployment plan without <field> — the resulting88pipeline would be non-functional or insecure.89REQUIRED:90 - source (CodeCommit / S3 / GitHub via CodeConnections)91 - trigger_filter (branch / paths / tags — required for V2)92 - deploy_action (CloudFormation / ECS / S3 / ServiceCatalog / CodeDeploy)93 - pipeline_role_arn or role policy document94```9596## STRICT output contract9798When this skill is invoked with a V2 pipeline provisioning request,99the agent MUST respond with the deployment plan defined in the "Output100format" section using the literal all-caps labels `PIPELINE_SPEC:`,101`VERDICT:`, `ARCHITECTURE:`, `CHECKLIST:`, `FINDINGS:`, and102`DEPLOY_COMMANDS:`. Do NOT preface the block with prose, headings, or103disclaimers — emit it as the first lines of the response. This104contract is what assertion-based evals and downstream provisioning105pipelines rely on; deviating from the literal labels breaks automation106silently.107108If any prerequisite is missing, the verdict is109`PREREQUISITES_MISSING` with a specific gap citation in the checklist110(marked `[✗]`), and `READY_TO_DEPLOY` MUST NOT also appear. The two111verdicts are mutually exclusive.112113## Quick navigation114115| Section | When to read |116|---|---|117| Pre-flight specification gate | Always — verify before planning |118| Step 0 — Expert heuristic: V1 → V2 migration | Migrating from polling |119| Step 1 — Pipeline type confirmation (V2) | Boundary call |120| Step 2-3 — Source + Trigger | CodeCommit / S3 / GitHub + filter scoping |121| Step 4-5 — Build (CodeBuild) + Deploy actions | Action wiring |122| Step 6-7 — Manual approval + Namespace variables | Gated releases, stage-to-stage data |123| Step 8-10 — Cross-account + Artifact bucket + Pipeline role | Security + IAM |124| NEVER do these things | Review before signing off |125| Output format | The literal plan template |126| references/triggers-and-namespace-variables-reference.md | Trigger filter + variable deep dive |127| references/cross-account-and-deploy-actions-reference.md | Cross-account + per-deploy-type contracts |128129## Process — Architecture planning (apply in order)130131### Step 0: Expert heuristic — V1 to V2 migration gotchas132133Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).134135136### Step 1: Pipeline type confirmation (V2)137138| Dimension | V1 | V2 |139|---|---|---|140| Trigger model | Polling or CloudWatch Events rule | Triggers (event-driven, sub-second) |141| Trigger filter | Branch only (via EventBridge rule) | Branch, paths, tags, glob patterns |142| Namespace variables | No | Yes (stage-to-stage) |143| Stage conditions | No | Yes (skip stages based on variables) |144| Pricing | $1/active pipeline/month | $0.002/pipeline-execution |145146**Pick V2 when ALL hold:** source supports event-driven triggers147(CodeCommit, S3 via EventBridge, GitHub via CodeConnections); you want148sub-second trigger latency (vs V1's ~17s polling); you want149pipeline-level variables or stage conditions; you want per-execution150pricing. Pick V1 only for legacy pipelines that cannot be migrated.151New pipelines should default to V2.152153### Step 2: Source action154155Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).156157| Source | Provider | Connection | Trigger type |158|---|---|---|---|159| CodeCommit | `CodeCommit` | Native (no connection) | `referenceCreated` / `referenceUpdated` |160| S3 | `S3` | Native | `PutObject` via EventBridge |161| GitHub | `CodeStarSourceConnection` | CodeConnections (us-east-1) | `push` events |162| GitLab / Bitbucket | `CodeStarSourceConnection` | CodeConnections | `push` events |163164165166The connection ARN MUST be created in us-east-1 via167`aws codeconnections create-connection`, even if the pipeline is in168another region. The connection requires a one-time browser handshake169to authorize AWS to access the GitHub repo.170171### Step 3: Trigger configuration (event-driven filter)172173V2 triggers replace V1's polling / CloudWatch Events rule. The filter174scopes which pushes start a run:175176Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).177178179**Critical trigger rules:**180- A trigger with NO filter fires on EVERY push to EVERY branch —181 always scope `Branches.Includes` to production branches.182- `Branches.Includes` supports glob (`release/*` matches183 `release/v1`). `main` is exact-match only.184- `FilePaths.Includes` limits runs to changes under those paths. Use185 `Excludes` for docs/CI-only changes.186- `Tags` filters on Git tags (annotated or lightweight). Useful for187 "deploy only on tagged releases."188- Multiple triggers are OR'd; within a trigger, branches/paths/tags189 are AND'd.190191### Step 4: Build (CodeBuild)192193Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).194195196The `Namespace: BuildVars` block exposes the build's exported197variables to downstream stages as `#{BuildVars.IMAGE_TAG}`. The198CodeBuild project must declare the variables it exports in199`buildspec.yml` under `exported-variables`:200201202### Step 5: Deploy actions203204| Deploy type | Provider | Key configuration |205|---|---|---|206| CloudFormation | `CloudFormation` | `ActionMode: CREATE_REPLACE`, `StackName`, `RoleArn` (target), `TemplatePath` |207| ECS | `ECS` | `ClusterName`, `ServiceName`, `Image1` (direct image) or `TaskDefinitionTemplatePath` |208| S3 deploy | `S3` | `BucketName`, `Extract: true` (unzip artifact) |209| Service Catalog | `ServiceCatalog` | `ProductId`, `ProvisionedProductName` |210| CodeDeploy | `CodeDeploy` | `ApplicationName`, `DeploymentGroupName`, `DeploymentStyle: BLUE_GREEN` / `IN_PLACE` |211| Manual approval | `Manual` | `ExternalEntityLink` (optional), `CustomData` (reviewer context) |212213Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).214215216For cross-account, `RoleArn` points to a role in the TARGET account;217the pipeline role in the source account needs `sts:AssumeRole` on it.218219**ECS deploy (direct image):** uses `Image1: #{BuildVars.IMAGE_URI}`220(a namespace variable from Build); the deploy cannot start until the221build's exported variable is resolved. Configure `ClusterName`,222`ServiceName`, `Image1`.223224**CodeDeploy for EC2 (in-place or blue/green):** configure225`ApplicationName`, `DeploymentGroupName`, `DeploymentStyle`226(`IN_PLACE` or `BLUE_GREEN`). EC2 instances must have the CodeDeploy227agent and the CodeDeploy service role configured.228229### Step 6: Manual approval gate230231Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).232233234The pipeline blocks until `put-job-approval-result --result APPROVED`235(or REJECTED). Configure an SNS topic to notify reviewers via236email/Slack. `ExternalEntityLink` points to a Change Management237ticket; `CustomData` is free-form reviewer context. Approval timeouts238are NOT enforced — the pipeline waits indefinitely. Use an external239scheduled Lambda to auto-reject stale approvals.240241### Step 7: Namespace variables242243Defined by setting `Namespace: <name>` on an action and exporting244variables from the action (CodeBuild's `exported-variables`,245CloudFormation's `OutputFileName`, or literal `Variables` block).246247**Consumption patterns:**248- Downstream action configuration: `Image1: #{BuildVars.IMAGE_URI}`249- Stage condition: `Conditions: [{ConditionKey: "#{BuildVars.ENV}", ConditionValue: prod, Operator: StringEquals}]`250- Nested namespace: `#{BuildVars.Deeply.Nested.Key}` (dotted paths for JSON-exported values)251252**Critical variable rules:**253- Variables flow forward only — a stage cannot consume a variable from254 a later stage.255- A missing variable renders as empty string (no error). Validate256 with a stage condition before using in a deploy.257- Variables are scoped per-execution. Concurrent pipeline runs do not258 share variable state.259- Secrets must NOT be namespace variables — they appear in plaintext260 in the pipeline execution history. Use Secrets Manager or Parameter261 Store SecureString, referenced by ARN in the action's IAM role.262263### Step 8: Cross-account deployment264265Moved verbatim to [references/cross-account-and-deploy-actions-reference.md](references/cross-account-and-deploy-actions-reference.md) - load on demand (see References below).266267268### Step 9: Artifact bucket security269270Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).271272273### Step 10: Pipeline IAM role274275Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).276277278## Expert heuristic: trigger filter precision and the "every push" trap279280Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).281282283## Expert heuristic: namespace variables and the silent-empty-string failure284285Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).286287288## Output format (per V2 pipeline deployment plan)289290Every V2 deployment plan MUST emit a single block using these literal291labels, in this order. Do NOT substitute markdown headings or camelCase292variants — assertion-based evals and downstream provisioning parse the293literal labels `PIPELINE:`, `VERDICT:`, `CHECKLIST:`, `FINDINGS:`,294`DEPLOY_COMMANDS:`.295296```text297PIPELINE: <pipeline-name>298VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING299CHECKLIST:300 [x] Pipeline type: V2 (event-driven, no polling; PollForSourceChanges=false)301 [x] Source: CodeCommit <repo/main> | S3 <bucket/key> | GitHub via CodeConnections <connection-arn + repo/branch>302 [x] Trigger filter: Branches=[main], FilePaths=src/**, Tags=deploy=prod (NOT unscoped)303 [x] Build: CodeBuild project <name>, exports namespace variables <list>304 [x] Test stage: CodeBuild <test-project> with unit + integration tests305 [x] Manual approval: enabled between <stage A> and <stage B> | none (ExternalEntityLink + SNS topic arn)306 [x] Deploy: CloudFormation <CREATE_REPLACE on stack> | ECS <cluster/service> | CodeDeploy <app/group> | S3 <bucket> | ServiceCatalog <product>307 [x] Artifacts: S3 <bucket-name> (block-public-access=true, SSE-KMS CMK <key-arn>, versioning=enabled)308 [x] Cross-account: target=<account>, KMS key policy grants kms:Decrypt+GenerateDataKey to <role>, IAM role <arn> | n/a309 [x] Pipeline IAM role: arn:aws:iam::<source>:role/<name> (no wildcard resources on S3/KMS/CodeBuild)310 [x] Namespace variables: validated non-empty via stage condition (no silent empty strings)311FINDINGS:312 - [INFO] <observation (pricing, propagation time, etc.)>313 - [WARN] <caution (trigger scoping, approval timeout, etc.)>314DEPLOY_COMMANDS:315 <ordered list of aws codepipeline / kms / iam / s3api commands>316```317318### FORBIDDEN output patterns — NEVER3193201. NEVER emit `VERDICT: READY_TO_DEPLOY` while any CHECKLIST item is321 `[ ]` (unchecked). Any unmet requirement forces322 `PREREQUISITES_MISSING`.3233242. NEVER emit a V2 pipeline trigger without a filter (no `Branches`,325 `FilePaths`, or `Tags` criteria). An unscoped trigger fires on EVERY326 push to EVERY branch — flooding history, burning per-execution327 costs ($0.002 × N feature pushes/day), and risking unintended prod328 deploys from feature branches.3293303. NEVER emit a cross-account deploy plan where the KMS key policy is331 missing `kms:Decrypt` and `kms:GenerateDataKey` grants to the target332 account's deployment role. S3 bucket policy alone does NOT grant333 cross-account access to encrypted objects — the deploy fails with334 "Access Denied" that looks like S3 but is actually KMS.3353364. NEVER emit a pipeline IAM role with `"Resource": "*"` on `s3:GetObject`,337 `kms:*`, or `codebuild:*`. Wildcards create a privilege escalation338 path — a malicious CodeBuild project can exfiltrate other pipelines'339 artifacts. Scope every resource to the exact ARN.3403415. NEVER emit secrets (tokens, passwords, signing keys) as namespace342 variables. Namespace variables render in plaintext in CloudTrail,343 the pipeline execution history, and the console. Use Secrets Manager344 or Parameter Store SecureString, referenced by ARN in the action's345 IAM role.3463476. NEVER emit a V2 pipeline with `PollForSourceChanges: true`. V2348 rejects this with a confusing "Invalid action configuration" error.349 After V1→V2 migration, set `DetectOptions: false` and add a trigger350 block. Also delete the legacy CloudWatch Events rule — a leftover351 rule fires alongside the V2 trigger and produces duplicate executions.3523537. NEVER emit a deployment plan that consumes a namespace variable354 (e.g., `#{BuildVars.IMAGE_URI}`) without a stage condition validating355 the variable is non-empty. A missing variable silently renders as356 `""` — ECS rejects the empty image string with a confusing357 "InvalidParameterException", not a clear "variable undefined" error.358359### Worked example — READY_TO_DEPLOY (CI/CD with test stage + manual approval + prod CFN deploy)360361```text362PIPELINE: payments-service-cicd363VERDICT: READY_TO_DEPLOY364CHECKLIST:365 [x] Pipeline type: V2 (event-driven; PollForSourceChanges: false — replaced legacy V1 CloudWatch Events rule)366 [x] Source: CodeCommit repo payments-service, branch main (OutputArtifacts: SourceOutput)367 [x] Trigger filter: Branches=[main], FilePaths.Includes=[src/**], FilePaths.Excludes=[docs/**, README.md] (NO unscoped trigger)368 [x] Build: CodeBuild project payments-service-build, exports IMAGE_URI, IMAGE_TAG, BUILD_VERSION369 [x] Test stage: CodeBuild project payments-service-tests (unit + integration, buildspec at tests/buildspec.yml) — gates Build stage via InputArtifact370 [x] Manual approval: enabled between Test and DeployProd (ExternalEntityLink: https://internal.example.com/change/CHG-78901, SNS topic arn:aws:sns:us-east-1:111111111111:prod-payments-approval)371 [x] Deploy: CloudFormation CREATE_REPLACE on stack prod-payments-service, RoleArn arn:aws:iam::222222222222:role/CrossAccountCFNExecution (target account 222222222222), TemplatePath BuildOutput::template.yaml, Capabilities CAPABILITY_IAM372 [x] Artifacts: S3 payments-pipeline-artifacts (block-public-access all true, SSE-KMS CMK arn:aws:kms:us-east-1:111111111111:key/abc-123, versioning enabled, lifecycle Glacier 90d)373 [x] Cross-account: target=222222222222, KMS key policy grants kms:Decrypt+GenerateDataKey to arn:aws:iam::222222222222:role/CrossAccountCFNExecution, IAM role trust allows arn:aws:iam::111111111111:role/payments-pipeline-role374 [x] Pipeline IAM role: arn:aws:iam::111111111111:role/payments-pipeline-role (scoped to exact ARNs — no wildcards on S3/KMS/CodeBuild/CodeCommit; iam:PassRole scoped to CrossAccountCFNExecution)375 [x] Namespace variables: validated via stage condition on DeployProd — `Conditions: [{ConditionKey: "#{BuildVars.IMAGE_URI}", Operator: StringEquals, ConditionValue: "", Not: true}]` (empty IMAGE_URI blocks deploy)376FINDINGS:377 - [INFO] Pricing: $0.002/execution + $1/active pipeline/month + $0.01/build-minute for CodeBuild378 - [WARN] Manual approval has no enforced timeout — wire an external scheduled Lambda to auto-reject approvals older than 48 hours379 - [WARN] After V1→V2 migration, delete the legacy CloudWatch Events rule payments-cicd-legacy-trigger to prevent duplicate executions380DEPLOY_COMMANDS:381 # 1. Create KMS CMK with cross-account key policy (source account 111111111111)382 aws kms create-key --policy file://kms-key-policy.json --description "payments-pipeline-artifacts CMK"383384 # 2. Create artifact bucket with block-public-access + KMS + versioning385 aws s3api create-bucket --bucket payments-pipeline-artifacts --region us-east-1 \386 --block-public-access BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true387 aws s3api put-bucket-encryption --bucket payments-pipeline-artifacts \388 --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"arn:aws:kms:us-east-1:111111111111:key/abc-123"}}]}'389 aws s3api put-bucket-versioning --bucket payments-pipeline-artifacts --versioning-configuration Status=Enabled390391 # 3. Create cross-account CFN execution role in TARGET account 222222222222392 aws iam create-role --role-name CrossAccountCFNExecution --assume-role-policy-document file://trust-policy.json393394 # 4. Create the pipeline role in SOURCE account 111111111111395 aws iam create-role --role-name payments-pipeline-role --assume-role-policy-document file://pipeline-trust-policy.json396 aws iam put-role-policy --role-name payments-pipeline-role --policy-name scoped --policy-document file://pipeline-role-policy.json397398 # 5. Create the V2 pipeline (trigger filter scoped to main + src/**)399 aws codepipeline create-pipeline --cli-input-json file://payments-service-cicd.json400401 # 6. Verify402 aws codepipeline get-pipeline-state --name payments-service-cicd403```404405### Decision tree — V2 pipeline shape selection406407```408Start: V2 deployment requirement409├─ Source = CodeCommit / GitHub via CodeConnections / S3 (event-driven capable)?410│ └─ No (legacy V1-only source) → emit ERROR — V2 requires event-driven source411├─ Cross-account deploy target?412│ ├─ Yes → KMS key policy grants kms:Decrypt + GenerateDataKey to target role?413│ │ ├─ Yes → CFN deploy action with RoleArn in target account414│ │ └─ No → PREREQUISITES_MISSING (KMS key policy is the actual blocker, not S3)415│ └─ No → same-account CFN / ECS / CodeDeploy / S3 / ServiceCatalog416├─ Gated release required?417│ ├─ Yes → Insert Manual approval action between Test and Deploy stages418│ │ (wire SNS topic for reviewer notification; schedule external Lambda419│ for stale-approval auto-reject — CodePipeline does NOT enforce timeouts)420│ └─ No → Continuous deploy (Test → Deploy direct)421├─ Trigger scope:422│ ├─ Filter present (Branches + FilePaths + Tags)? → READY_TO_DEPLOY423│ └─ No filter → PREREQUISITES_MISSING (unscoped trigger = every push to every branch)424└─ Namespace variables consumed downstream?425 ├─ Stage condition validates non-empty? → READY_TO_DEPLOY426 └─ No validation → PREREQUISITES_MISSING (silent empty-string deploy risk)427```428429## Verification commands (run after deployment)430431Moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) - load on demand (see References below).432433434## Edge-case handling435436Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).437438439## NEVER do these things4404411. **NEVER create a V2 pipeline trigger without a filter.** A trigger442 with no `Branches` / `FilePaths` / `Tags` filter fires on EVERY443 push to EVERY branch, flooding history, burning per-execution444 costs, and risking unintended production deploys from feature445 branches. Always scope `Branches.Includes` to production branches.4464472. **NEVER share the artifact bucket without KMS cross-account448 policy.** S3 bucket policy alone does NOT grant cross-account449 access to encrypted objects. Without the matching KMS key policy450 granting the target role `kms:Decrypt` and `kms:GenerateDataKey`,451 the deploy action fails with "Access Denied" that looks like S3452 but is actually KMS. Configure both.4534543. **NEVER pass secrets as namespace variables.** Namespace variables455 render in plaintext in CloudTrail, the pipeline execution history,456 and the console. Use Secrets Manager or Parameter Store457 SecureString, referenced by ARN in the action's IAM role.4584594. **NEVER use a wildcard in the pipeline IAM role for S3, KMS, or460 CodeBuild.** `"Resource": "*"` on `s3:GetObject` lets the pipeline461 read any bucket. `"Resource": "*"` on `codebuild:*` lets it start462 any CodeBuild project — a malicious project can exfiltrate other463 pipelines' artifacts. Scope to exact ARNs.4644655. **NEVER leave `PollForSourceChanges: true` on a V2 pipeline.** V2466 rejects this with a confusing error. After V1 → V2 migration, set467 `DetectOptions: false` and add a trigger. Also delete the legacy468 CloudWatch Events rule from V1 — a leftover rule fires alongside469 the V2 trigger and produces duplicate executions.470471Additional hard constraints: approval timeouts are NOT enforced472(CodePipeline waits indefinitely); a missing namespace variable473silently renders as empty string; S3-managed encryption (SSE-S3) is474incompatible with cross-account (requires customer-managed KMS CMK);475`iam:PassRole` on `*` is a privilege escalation path.476477## Pre-flight safety checks (run before any deployment CLI)478479Moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) - load on demand (see References below).480481482## Remediation guidance483484Moved verbatim to [references/error-handling.md](references/error-handling.md) - load on demand (see References below).485486487## References (load on demand)488489- [references/advanced-patterns.md](references/advanced-patterns.md) - Step 0 + expert-heuristic deep dives, edge-case catalog, Step 9/10 hardening, recent AWS features490- [references/worked-examples.md](references/worked-examples.md) - per-step source / trigger / build / deploy / approval config examples491- [references/diagnostic-commands.md](references/diagnostic-commands.md) - verification commands + pre-flight safety checks492- [references/error-handling.md](references/error-handling.md) - remediation ordering + fixes493- [references/cross-account-and-deploy-actions-reference.md](references/cross-account-and-deploy-actions-reference.md) - cross-account KMS/IAM wiring deep dive494- [references/triggers-and-namespace-variables-reference.md](references/triggers-and-namespace-variables-reference.md) - trigger filter + namespace variable detail495496## Domain497498AWS CloudOps / CodePipeline V2 Provisioning.499500## Recent AWS features (2024-2026)501502Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).503504505## AWS documentation506507- **CodePipeline User Guide + Pipeline types (V1 vs V2)** — https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html508- **V2 triggers / Namespace variables / Cross-account actions** — https://docs.aws.amazon.com/codepipeline/latest/userguide/triggers-v2.html509- **CodeConnections** — https://docs.aws.amazon.com/codeconnections/latest/userguide/welcome.html510- **CodePipeline CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/codepipeline/511- **Tutorial: V2 pipeline with manual approval** — https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-deploy.html512- **Blog: V2 pipeline launch** — https://aws.amazon.com/blogs/devops/introducing-aws-codepipeline-v2/