BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeAWS Certified DevOps Engineer - Professional (DOP-C02)Mastering Artifact Repositories: AWS CodeArtifact, ECR, and S3
Study Guide945 words

Mastering Artifact Repositories: AWS CodeArtifact, ECR, and S3

Creating and configuring artifact repositories (for example, AWS CodeArtifact, Amazon S3, Amazon Elastic Container Registry [Amazon ECR])

Mastering Artifact Repositories: AWS CodeArtifact, ECR, and S3

This guide covers the essential knowledge for creating and configuring artifact repositories in AWS, a core component of the SDLC Automation domain for the AWS Certified DevOps Engineer – Professional (DOP-C02) exam.

Learning Objectives

After studying this guide, you should be able to:

  • Design and configure Amazon ECR repositories for containerized applications.
  • Implement AWS CodeArtifact domains and repositories for language-specific dependencies.
  • Utilize Amazon S3 as a secure, versioned storage for raw build artifacts.
  • Apply least-privilege IAM policies to secure artifact access.
  • Automate artifact lifecycle management to optimize storage costs.

Key Terms & Glossary

  • Artifact: A file produced during the software development process (e.g., compiled binaries, JAR files, Docker images, or documentation).
  • Registry (ECR): A managed service that hosts one or more Docker repositories.
  • Domain (CodeArtifact): A higher-level container that groups repositories, allowing for shared assets and unified management.
  • Upstream Repository: A repository in CodeArtifact that provides packages to a downstream repository.
  • Lifecycle Policy: Rules that automate the cleanup of old or unused artifacts (e.g., deleting ECR images older than 30 days).

The "Big Idea"

In a DevOps pipeline, the Artifact Repository acts as the "Single Source of Truth" between the Build phase and the Deployment phase. Without a central, versioned, and secure repository, pipelines become brittle, environment consistency is lost, and the risk of deploying unvetted code increases. Effective artifact management ensures that what you test is exactly what you deploy.

Formula / Concept Box

FeatureECR (Elastic Container Registry)CodeArtifactAmazon S3
Primary UseDocker/OCI Imagesnpm, pip, maven, nugetStatic assets, .zip, .war
Access ToolDocker CLI / HelmLanguage CLIs (npm, pip)AWS CLI / SDK / Console
Auth Methodaws ecr get-login-passwordaws codeartifact get-authorization-tokenIAM / Bucket Policies
HierarchyRegistry > Repository > ImageDomain > Repository > PackageBucket > Folder > Object

Hierarchical Outline

  1. Amazon Elastic Container Registry (ECR)
    • Private vs. Public: Private for internal apps; Public for global distribution.
    • Image Scanning: Automated vulnerability detection on push.
    • Replication: Cross-region and cross-account replication for DR/Latency.
  2. AWS CodeArtifact
    • Domains: Centralized management for multiple repositories.
    • Upstream Sources: Integration with public registries (e.g., npmjs.com).
    • Versioning: Semantic versioning support for internal libraries.
  3. Amazon S3 for Artifacts
    • Versioning: Essential for preventing accidental overwrites.
    • Encryption: SSE-S3 or SSE-KMS for regulatory compliance.
    • Integrations: Direct support from AWS CodeBuild and CodeDeploy.

Visual Anchors

Artifact Flow in CI/CD

Loading Diagram...
Figure 1 — Mermaid diagram

CodeArtifact Hierarchy

Compiling TikZ diagram…
⏳
Running TeX engine…
This may take a few seconds
Figure 2 — TikZ diagram

Definition-Example Pairs

  • Immutable Artifacts: Once a version (e.g., v1.2.0) is published, it cannot be changed. If a fix is needed, v1.2.1 must be created.
    • Example: Tagging an ECR image as production-stable and using "Tag Immutability" to prevent anyone from overwriting that specific tag.
  • Upstream Connection: Linking a private repository to a public one to cache dependencies.
    • Example: A CodeArtifact repo points to npmjs.com. When a developer requests lodash, CodeArtifact downloads it once and stores it locally for future internal use.

Worked Examples

1. Authenticating and Pushing to ECR

To push an image to ECR, you must first authenticate the Docker client. This is a common exam scenario regarding CLI permissions.

bash
# 1. Retrieve the password and login aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com # 2. Tag your local image docker tag my-app:latest <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/my-app:v1 # 3. Push to the repository docker push <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/my-app:v1

2. S3 Bucket Policy for CodeDeploy

When using S3 for artifacts, the service (like CodeDeploy) needs permission to read from the bucket.

json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codedeploy.amazonaws.com" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-artifact-bucket/*" } ] }

Checkpoint Questions

  1. What is the benefit of a CodeArtifact Domain over individual standalone repositories?
  2. How do ECR Lifecycle Policies differ from S3 Lifecycle Policies?
  3. Which AWS CLI command is used to fetch a temporary token for npm to talk to CodeArtifact?
  4. Why should you enable Tag Immutability in an ECR repository?

Muddy Points & Cross-Refs

  • S3 vs. CodeArtifact: Use S3 for deployment bundles (zip/tar) used by CodeDeploy. Use CodeArtifact for library dependencies (npm/pip) used by developers and CodeBuild.
  • ECR Auth Timeout: Authorization tokens for ECR/CodeArtifact are valid for 12 hours. Pipelines running longer than this may fail if they don't re-authenticate.
  • Cross-Account Access: Remember that CodeArtifact requires permissions on both the Repository and the Domain to function across accounts.

Comparison Tables

CriterionAmazon ECRAWS CodeArtifactAmazon S3
SearchabilityBy image tag/digestBy package name/versionBy prefix/object key
CachingPull-through cache availableBuilt-in upstream cachingNo native package caching
ScanningBasic/Enhanced ScanningN/A (Manual/Third-party)Macie (Sensitive data)
Cost ModelStorage + Data TransferStorage + RequestsStorage + Requests
All AWS Certified DevOps Engineer - Professional (DOP-C02) Study Resources

Related Notes

  • Mastering AWS Alerting and Automated Remediation1,050 words
  • Study Guide: Analyzing Failed Deployments in AWS940 words
  • Incident Analysis: Troubleshooting Failed Processes in AWS1,050 words
  • Mastering AWS Monitoring & Security Analytics: Logs, Metrics, and Findings1,050 words
  • AWS Log Analysis: Athena, CloudWatch Insights, and OpenSearch920 words
  • Analyzing Real-Time Log Streams with Amazon Kinesis Data Streams985 words
  • CloudWatch Anomaly Detection Alarms: Professional Study Guide820 words
  • AWS Application Storage Patterns: EBS, EFS, and S31,054 words
  • Lab: Automating Security Controls and Data Protection with AWS Secrets Manager and Config942 words
  • Master Study Guide: Automating Security Controls & Data Protection (AWS DOP-C02)1,184 words
  • Mastering AWS CloudFormation StackSets: Multi-Account & Multi-Region Orchestration895 words
  • Mastering System Configuration Changes in AWS945 words

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
AWS Certified DevOps Engineer - Professional (DOP-C02) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, left to right. Source Code connects to CodeBuild. B connects to Amazon ECR ("Build Images"). B connects to CodeArtifact ("Build Packages"). B connects to Amazon S3 ("Build Binaries"). C & D & E connects to Deployment (ECS/EKS/Lambda).