Source Control, Connections and Pipeline Triggers
Overview
Every pipeline starts with a source: the Git repository where code lives and where a commit begins the journey to production. On AWS the source can be AWS CodeCommit, GitHub / GitHub Enterprise, GitLab, Bitbucket or an S3 / ECR object. Choosing the source and the trigger determines how quickly feedback reaches developers.
Think of source control as the front door of a factory. Whatever comes through that door is assumed to be built, tested and shipped, so you want a doorman: branch protection, pull-request reviews, and a trigger that only starts a build for the right branches and paths.
For the exam you need to know the integration options, how a pipeline is triggered (events, not polling), and the branching strategies that fit continuous delivery. Note that AWS stopped onboarding new CodeCommit customers in mid-2024, so many exam-style scenarios and real teams use GitHub, GitLab or Bitbucket via AWS CodeConnections; always verify current CodeCommit availability for your account.
Key Concepts
- AWS CodeConnections (formerly CodeStar Connections) authorises CodePipeline, CodeBuild and others to use GitHub, GitHub Enterprise Server, GitLab and Bitbucket without long-lived tokens in the pipeline.
- CodePipeline source actions: CodeCommit, S3, ECR, and CodeConnections based providers.
- Pipelines are triggered by events (EventBridge for CodeCommit/S3/ECR, webhook-like triggers for connections), not by polling; polling is the legacy method.
- CodePipeline V2 supports trigger filters on branches, tags, file paths and pull-request events.
- Trunk-based development with short-lived branches and feature flags is the best match for continuous delivery.
- CodeCommit supports approval rule templates, triggers/notifications and cross-account access via an IAM role.
- CodeBuild can also be a Git-native CI: webhooks start builds on push or PR events and can report build status back to GitHub.
- Use output artifact formats: CODE_ZIP (default) or CODEBUILD_CLONE_REF (full clone so the build can run Git commands).
Detailed Notes
Source providers
| Provider | Trigger mechanism | Notes |
|---|---|---|
| CodeCommit | EventBridge rule on repository state change | Cross-account use needs an assumable role; no new customers since 2024 |
| GitHub / GitLab / Bitbucket | CodeConnections + pipeline trigger | App-based OAuth; connection must be in Available state (manual handshake once) |
| Amazon S3 | EventBridge via CloudTrail data events or S3 events | Versioning must be enabled on the bucket |
| Amazon ECR | EventBridge on image push | Useful for image-promotion pipelines |
Connections
A connection is an AWS resource created once per provider account/organisation. The console handshake installs the AWS Connector app on GitHub. Pipelines reference its ARN:
- Name: Source
Actions:
- Name: GitHubSource
ActionTypeId: { Category: Source, Owner: AWS, Provider: CodeStarSourceConnection, Version: "1" }
Configuration:
ConnectionArn: arn:aws:codeconnections:us-east-1:111122223333:connection/abcd-1234
FullRepositoryId: my-org/orders-service
BranchName: main
OutputArtifactFormat: CODE_ZIP
DetectChanges: "true"
OutputArtifacts: [{ Name: SourceOut }]
V2 pipeline triggers
Type V2 pipelines add triggers with filters, so a monorepo can run different pipelines per directory:
{
"triggers": [{
"providerType": "CodeStarSourceConnection",
"gitConfiguration": {
"sourceActionName": "GitHubSource",
"push": [{
"branches": { "includes": ["main", "release/*"] },
"filePaths": { "includes": ["services/orders/**"] }
}]
}
}]
}
V2 also supports pipeline-level variables and execution modes: SUPERSEDED (newer execution replaces waiting ones), QUEUED (executions processed in order) and PARALLEL.
Branching strategies
| Strategy | Description | Fit |
|---|---|---|
| Trunk-based | Short-lived branches, merge to main many times a day, feature flags hide unfinished work | Best for CD |
| GitFlow | develop, release and hotfix branches | Scheduled releases; slower feedback |
| Environment branches | One branch per environment | Discouraged: code differs between environments |
CodeCommit specifics
- Approval rule templates require N approvers on pull requests to named branches.
- Triggers publish to SNS or invoke Lambda on pushes; EventBridge is preferred for pipelines.
- Access with HTTPS git-remote-codecommit (IAM credentials) or SSH keys; cross-account access = role in the repository account assumed by the other account.
- Encrypted at rest with KMS; no repository size limits for typical use but individual files max 6 MB through the console.
Quality gates before merge
Run CodeBuild on pull requests (webhook filter PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED) so tests, linters and secret scanners block a merge, then use branch protection to require the status check.
aws codebuild create-webhook --project-name orders-pr-checks \
--filter-groups '[[{"type":"EVENT","pattern":"PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED"}]]'
Secrets in source
Never commit credentials. Use git-secrets or Amazon CodeGuru Security / Amazon Q scanning in a pre-merge build, and fetch runtime secrets from Secrets Manager or SSM Parameter Store at deploy time.
SDLC phases and pipeline patterns across accounts
| SDLC phase | Typical AWS tooling | Automation goal |
|---|---|---|
| Plan and code | Git repository, pull requests, feature flags (AppConfig) | Small, reviewable changes |
| Build and test | CodeBuild, unit and static analysis, CodeGuru | Fast feedback on every commit |
| Release | CodePipeline, artifact stores, approvals | Versioned, immutable artifacts |
| Deploy | CodeDeploy, CloudFormation, ECS and Lambda deployments | Repeatable rollout with automatic rollback |
| Operate and monitor | CloudWatch, X-Ray, EventBridge | Feedback loops into the backlog |
For single-account pipelines, one pipeline role deploys everything. For multi-account delivery, run the pipeline in a tooling account and have it assume a deployment role in each stage account (dev, test, prod). The artifact bucket and its KMS key must be readable by those roles, and the production account's role should trust only the tooling account. Keep environments identical by deploying the same artifact to each stage and varying only parameters.
Real World Example
Scenario: a monorepo with five microservices on GitHub. The team creates a CodeConnections connection and five V2 pipelines. Each pipeline has a push trigger filtered on its own directory (services/orders/**), so a change to billing does not rebuild orders.
A separate CodeBuild project runs on pull requests (unit tests, linting, a secret scan) and posts status to GitHub; branch protection requires it. Merges to main start the pipeline with QUEUED execution mode so deployments never overlap or skip. Lead time falls from days to under 30 minutes.
Architecture Diagram
A push event is filtered and starts only the relevant pipeline.
- 1A developer pushes to a branch or opens a pull request.
- 2GitHub notifies AWS through the CodeConnections app.
- 3The V2 trigger filter matches branch and file paths.
- 4CodePipeline starts and stores the source zip in the artifact bucket.
- 5Later stages consume the artifact; PR builds report status back to GitHub.
Best Practices
- ✓Use CodeConnections instead of personal access tokens, and scope the GitHub app to specific repositories.
- ✓Trigger by events, never by polling; use V2 filters to avoid unnecessary executions.
- ✓Adopt trunk-based development with feature flags and short-lived branches.
- ✓Require PR build checks and approvals before merge to the release branch.
- ✓Scan for secrets and vulnerabilities in PR builds and keep secrets out of Git.
Common Interview Questions
Exam Tips
DOP-C02 focus
- S3 source = versioning must be enabled; ECR source = image-push event.
- Cross-account CodeCommit access = IAM role in the repo account assumed by the other account.
- "Start the pipeline immediately on commit" = event-based change detection, not periodic polling.
- A build that needs Git history/commands needs the full clone output artifact format (CODEBUILD_CLONE_REF).
Finished this lesson?
0 of 44 lessons done · 0% of the course

