2.1.1.1. Code, Image, and Artifact Repositories (Git via CodeConnections, ECR, S3)
2.1.1.1. Code, Image, and Artifact Repositories (Git via CodeConnections, ECR, S3)
Every CI/CD pipeline starts with a source of truth. If your team can't answer "what exact version of code is running in production right now?" — your repository strategy has failed. AWS provides three purpose-built repository types:
Third-party Git repositories (GitHub, GitHub Enterprise Server, GitLab.com, GitLab self-managed, Bitbucket Cloud) connect to CodePipeline through AWS CodeConnections (formerly AWS CodeStar Connections). A CodeStarSourceConnection source action starts the pipeline when a new commit reaches the configured branch, and the connection manages change detection through the provider's webhooks, so you do not set up a webhook or polling yourself. Branch protection, required reviews and merge rules live in the Git provider.
⚠️ CodeCommit Status: AWS CodeCommit still exists and has been open to new customers again since November 25, 2025, but it is not on this exam's in-scope service list.
Amazon ECR stores Docker container images with built-in vulnerability scanning (scanOnPush), lifecycle policies for automatic cleanup of untagged images, and cross-region/cross-account replication. ECR integrates natively with ECS, EKS, and Lambda for container deployments.
Amazon S3 serves as general-purpose artifact storage for deployment packages, static assets, and pipeline outputs. Use versioning to preserve every artifact version and lifecycle policies to archive or delete old artifacts.
Exam Trap: CodePipeline's Source stage accepts ECR, S3, and connection-based Git providers (GitHub, GitLab, Bitbucket), but each detects changes differently. ECR source actions use an EventBridge rule on the image push. S3 source actions also use an event rule, either on a bucket enabled for events or with CloudTrail resources that record the upload; the CloudTrail variant needs its trail, so a missing trail stops that variant from triggering. Connection-based sources need no rule or webhook from you, because the connection manages change detection.
# CodePipeline source action for S3 (event-based change detection, not polling)
- Name: SourceAction
ActionTypeId:
Category: Source
Provider: S3
Configuration:
S3Bucket: my-artifact-bucket
S3ObjectKey: app/source.zip
PollForSourceChanges: false # Use the event rule instead of polling
💡 Tip: Use ECR lifecycle policies aggressively — untagged images accumulate fast and drive up storage costs. A common policy keeps only the last 10 tagged images per repository. A policy can hold several rules evaluated in rulePriority order (lowest number first); each selects images by tag status/tag prefix and expires them by count (imageCountMoreThan) or age (sinceImagePushed), and an image matched by a higher-priority rule can't be expired by a lower-priority one. ECR storage is not an S3 bucket you can attach S3 lifecycle rules to.