Courseiva
DOP-C02Chapter 11 of 18Objective 1.4

Source Control and Artifact Management with CodeCommit and CodeArtifact

How does a team of dozens of developers, all working on the same software product at the same time, keep from overwriting each other’s work and losing changes? For the AWS Certified DevOps Engineer Professional (DOP-C02) exam, mastering source control and artefact management is fundamental – it is the bedrock upon which automated software delivery pipelines are built. This chapter explains how AWS CodeCommit and AWS CodeArtifact solve these exact problems, providing the secure, scalable, and versioned storage that every modern DevOps workflow depends on.

12 min read
Beginner
Updated Jul 24, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Source Control and Artifact Management with CodeCommit and CodeArtifact

The Shared Kitchen Renovation Analogy

Have you ever tried to cook a complex meal with four friends in a tiny, cluttered kitchen, only to have someone accidentally use the ingredient you were saving or put a dirty knife back in the drawer where you need your clean spoon?

Managing software code without proper tools is exactly like that disaster kitchen. Source control with AWS CodeCommit is your kitchen’s master recipe book and digital filing cabinet. Every time you make a change to the recipe – say, adding a new spice – you snap a Polaroid photo of that exact version and file it in the book. Later, if the spice ruins the dish, you can flip back to the photo of the previous, perfect version and restore it instantly. No more arguing over whose chopped onions are whose. The book also tracks who added the spice and why, so you have a perfect audit trail.

Now, once your final recipe is perfected, you need to share it with the bakery next door so they can make your cookies for sale. But you wouldn’t hand over your messy, coffee-stained notebook. You would create a clean, packaged, ingredient list – a neat little bundle that includes every flour, sugar, and tool needed. That’s exactly what AWS CodeArtifact does for software. It takes your compiled code (the finished recipe) and stores it in a secure, organised pantry called an artefact repository. Any colleague or automated system can then fetch that exact, trusted package without having to see your messy development workspace or worry about missing ingredients. The kitchen is now a peaceful, productive space, and the bakery gets exactly the right recipe, every time.

How It Actually Works

Let’s break down the two core services: CodeCommit and CodeArtifact.

Source Control with AWS CodeCommit

Source control (also called version control) is a system that records changes to a file or set of files over time so that you can recall specific versions later. Think of it as an infinite ‘undo’ button for your entire project. CodeCommit is AWS’s fully managed, private Git repository. Git is a widely used source control system developed by Linus Torvalds. A repository (repo) is the central location where all your project files and their history live. CodeCommit is like a supercharged, cloud-based hard drive that tracks every single edit.

How does it work? When you first create a CodeCommit repository, it’s empty. You then ‘clone’ it to your local computer, which downloads the empty repo. You add your code files, save them, and then you ‘commit’ those changes. A commit is a snapshot of your work at that moment, tagged with a unique ID, your name, and a message explaining the change. You then ‘push’ that commit from your computer up to the CodeCommit repository in the cloud. Now, the change is permanently stored. If your computer crashes tomorrow, the code is safe in AWS. If a colleague pushes a conflicting change, CodeCommit’s merge logic helps you combine them. It also supports ‘branching’ – creating an independent copy of the code to work on a new feature without disturbing the stable, main version (the ‘main’ branch). Once the feature is ready and tested, you ‘merge’ that branch back into main.

Why does this exist? Before source control, developers would copy files to a shared drive, email them to each other, or use clumsy manual processes. Files were constantly overwritten, lost, or corrupted. CodeCommit replaces this chaos with a pristine, auditable history of every change.

Artefact Management with AWS CodeArtifact

An artefact is a packaged, deployable piece of software, like a Java JAR file, a Python wheel, a Node.js package, or a Docker image. CodeArtifact is a secure, scalable artefact repository that stores and manages these packages. It acts as a central, trusted ‘package store’ for your entire organisation.

How does it work? Developers configure their build tools (like Maven, Gradle, npm, pip) to point to a CodeArtifact repository. When a developer needs a library, say a logging library, their build tool asks CodeArtifact for it. CodeArtifact can either serve the package from its own storage or automatically ‘proxify’ the request to a public repository like Maven Central or npmjs.org. This means CodeArtifact acts as a middleman, caching the package locally so that if the public repository goes down, your builds still work. It also prevents ‘dependency confusion’ attacks, where a malicious package with the same name as your internal one is fetched from a public repository.

Why does this exist? Manual download of libraries is insecure and unmanageable. Teams need a single source of truth for all software components. CodeArtifact ensures that every developer, build server, and deployment pipeline uses the exact same, approved, and secure version of every library. It integrates natively with AWS IAM (Identity and Access Management) for fine-grained permission control – you can decide exactly who can publish new packages and who can download them.

Together, CodeCommit and CodeArtifact form the first two stages of a CI/CD pipeline: source (where code lives and evolves) and package (where code is turned into deployable units).

Flowchart showing how source code moves from a developer's workstation through CodeCommit, to build and packaging in CodeArtifact, and finally to deployment on EC2.

Walk-Through

1

Create the CodeCommit Repository

Log into the AWS Management Console, navigate to CodeCommit, and create a new repository. Give it a meaningful name like 'my-app-source'. This step establishes the central cloud location where all your source code will be stored and versioned. Without this, developers would have no single source of truth.

2

Clone the Repository to Your Local Machine

Using the Git command line, run 'git clone <repository-URL>'. This copies the empty repository from AWS CodeCommit down to your local computer, creating a folder called a 'local repository'. This step allows you to work on the code offline and later sync changes back to the cloud.

3

Make Changes, Stage, and Commit Locally

Add new files or edit existing ones. Use 'git add' to stage the files you want to save, then 'git commit -m "your message"' to create a snapshot. The commit message explains what changed and why. This step creates a permanent record in your local history.

4

Push the Changes to AWS CodeCommit

Run 'git push origin main' to upload your local commits to the CodeCommit repository in the cloud. Now, other team members can see your changes by pulling. This step makes your work visible and backed up. If your computer fails, the code is safe in AWS.

5

Create a Build and Publish Artefacts to CodeArtifact

Configure a build system (like AWS CodeBuild) to compile your source code. After a successful build, configure the build to run a command like 'mvn deploy' to publish the resulting package (e.g., a .jar file) to a CodeArtifact repository. This step transforms your source code into a reusable, versioned package that can be deployed to servers.

6

Consume the Artefact from CodeArtifact for Deployment

Configure your deployment tool (like AWS CodeDeploy) to fetch the compiled package directly from CodeArtifact using its version number. This ensures that the exact same artefact that was tested in your staging environment is deployed to production, eliminating the 'it works on my machine' problem. This step completes the pipeline from source to running application.

What This Looks Like on the Job

Meet Sarah, a DevOps engineer at a company called FinFlow that builds a mobile banking app. Her team has 15 developers, two QA testers, and one operations person.

Step 1: Setting Up Source Control. Sarah creates a new CodeCommit repository called ‘finflow-app’. She configures IAM policies so that only the senior developers can push directly to the main branch, and every push triggers an email notification to the team. She clones the empty repo, adds the initial application skeleton, and pushes the first commit.

Step 2: Feature Development. A developer named Alex wants to add a new ‘transaction search’ feature. He creates a new branch called ‘feature/search’ from the main branch. He works on this branch for three days, making 17 commits. Each commit is a snapshot of his progress. He can instantly see what he changed at each step using the ‘git log’ command. If he makes a mistake, he uses ‘git revert’ to undo a specific commit without losing his other changes.

Step 3: Collaborative Merging. Alex finishes his feature and pushes his branch to CodeCommit. He then creates a ‘pull request’ (PR) – a formal request to merge his branch into main. The PR triggers an automated test suite via AWS CodePipeline. Sarah reviews the code and sees the diff (the difference between the two code versions) directly in the CodeCommit console. She leaves comments on specific lines of code. Alex fixes the issues, pushes new commits to the same branch, and Sarah approves the PR. CodeCommit automatically merges the branch into main.

Step 4: Building Artefacts. Once code is merged into main, a CodePipeline build action triggers. The build server compiles the Java code, runs unit tests, and then produces a .jar file – the deployable artefact. The build action automatically publishes that .jar file to a CodeArtifact repository called ‘finflow-releases’. This is a private repository. Only authorised build machines have IAM permissions to publish to it.

Step 5: Securing Dependencies. During the build, the build server needs external libraries like a logging framework. Instead of downloading them from the public internet (which is slow and risky), the build tool is configured to fetch them from a CodeArtifact repository that proxies the public Maven repository. CodeArtifact caches the library once, and all subsequent builds use the cached version, making builds faster and more reliable. It also prevents a scenario where a malicious actor publishes a fake ‘log4j’ package to the public repository – CodeArtifact would only serve the version Sarah’s team has approved.

Step 6: Consumption by Deployment. The operations team, using CodeDeploy, pulls the exact .jar file from the CodeArtifact repository and deploys it to an EC2 instance. Because the artefact is in a secure, versioned repository, they know exactly what is being deployed. Rollbacks are simple: just fetch a previous version of the artefact from CodeArtifact and re-deploy it. No more ‘it works on my machine’ problems.

This entire workflow demonstrates how CodeCommit and CodeArtifact move the organisation from a manual, error-prone process to an automated, secure, and auditable pipeline.

How DOP-C02 Actually Tests This

The DOP-C02 exam tests your understanding of source control and artefact management through scenario-based questions. You will be given a description of a team’s workflow and asked to choose the correct AWS service or configuration. Here is what you need to focus on.

Key Concepts to Know:

The difference between Git-based source control (CodeCommit) and artefact repositories (CodeArtifact). A common trap question describes a developer ‘storing compiled binaries’ – this points to CodeArtifact, not CodeCommit.

How to integrate CodeCommit with CI/CD pipelines. Questions will ask about using CodePipeline with CodeCommit as a source action. Know that CodePipeline can automatically detect changes in a CodeCommit branch and trigger a new pipeline execution.

IAM permissions for repositories. You need to understand how to grant specific users read-only access to a CodeCommit repository using IAM policies. Traps often include giving overly broad S3 permissions when CodeCommit requires its own specific actions like ‘codecommit:GitPull’.

CodeCommit’s integration with AWS KMS for encryption. If a company requires custom encryption keys for their source code, CodeCommit supports customer-managed CMKs (Customer Master Keys) in KMS.

The concept of ‘upstream repositories’ in CodeArtifact. CodeArtifact can be configured to automatically fetch packages from public repositories (upstreams). The exam loves testing that if you want to allow access to external packages but also host your own private ones, you should configure an upstream repository in CodeArtifact, not bypass it.

Notifications and triggers. CodeCommit can trigger AWS Lambda functions or SNS notifications on events like pushes to specific branches or pull request creation. The exam might ask: ‘How do you send a message to a Slack channel when a push happens to the main branch?’ The answer involves configuring an event rule in Amazon EventBridge that matches a CodeCommit event and routes it to an SNS topic.

Common Trap Patterns:

1.

Using S3 instead of CodeArtifact. A question describes storing versioned software packages securely. S3 can store them, but CodeArtifact provides repository management, proxying, and permission controls that S3 lacks. The best practice is CodeArtifact.

2.

Confusing branches and repositories. A branch is a line of development within a single repository. Creating separate repositories for each feature (instead of branches) is usually wrong. The exam will try to make you create many repos when a single repo with branches is appropriate.

3.

Ignoring IAM roles for cross-account access. If a company has accounts for dev, test, and prod, and wants the prod build server to pull packages from a CodeArtifact repository in the dev account, you need to set up an IAM cross-account role. Just copying the packages is insecure.

4.

Using CodeCommit for large binary files. CodeCommit has a limit on file size (2 GB per commit, but ideally files should be small). If a scenario involves storing large generated binaries (like a 10 GB game asset), the correct answer is S3, not CodeCommit. CodeCommit is for source code, not large artefacts.

Key Definitions to Memorise:

Commit: a snapshot of changes

Branch: a separate line of development

Merge: combining changes from two branches

Pull request: a request to merge code from one branch to another

Artefact: a packaged, deployable version of the software (e.g., .jar, .zip)

Key Takeaways

AWS CodeCommit is a fully managed, private Git repository for version-controlled source code, enabling team collaboration with branching, merging, and pull requests.

AWS CodeArtifact is a managed artefact repository for storing, sharing, and deploying software packages (like JARs, wheels, and npm packages) with built-in proxy support for external public repositories.

CodeCommit integrates natively with AWS IAM for fine-grained access control, allowing you to grant read-only or read-write permissions per repository or even per branch.

When building a CI/CD pipeline in AWS, CodeCommit acts as the source stage and CodeArtifact as the build output storage, forming a secure, auditable path from code commit to deployment.

CodeArtifact helps prevent dependency confusion attacks by allowing you to specify upstream repositories and control exactly which external packages are available to your builds.

For the DOP-C02 exam, remember that CodeCommit is for source code, CodeArtifact is for compiled packages, and they are not interchangeable – using S3 for source control or CodeCommit for binary artefacts is a common incorrect answer.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

AWS CodeCommit

Stores source code files (e.g., .py, .java, .yaml).

Tracks every change with version control using Git.

Uses Git commands like commit, push, and pull for interaction.

AWS CodeArtifact

Stores compiled software packages (e.g., .jar, .whl, .nupkg).

Manages package versions and dependencies.

Uses package manager tools like mvn, npm, pip for interaction.

Git Branch

A line of development that can have new commits added.

Used to develop features in isolation from the main codebase.

Moves forward as new commits are made on that branch.

Git Tag

A static label pointing to a specific commit in history.

Used to mark a release version (e.g., v1.0.0).

Does not change once created, unless forced with a new commit.

Pull Request (in CodeCommit)

Requires review and approval from another developer.

Ideal for collaborative development and quality control.

Can automatically trigger tests via CodePipeline.

Direct Push to Main Branch

Bypasses review and is risky for the main branch.

Suitable for emergencies or trivial hotfixes if allowed by policy.

Should be restricted via IAM policies to senior developers only.

Upstream Repository in CodeArtifact

A cached proxy that sits between your builds and a public repo.

Stores a local copy of packages to speed up builds and avoid outages.

Controlled by IAM policies for security.

External Public Repository (e.g., npmjs.org)

The original, external source of packages on the internet.

Directly accessed by build tools, which can be slow or fail if unavailable.

No access control from AWS – open to anyone.

Watch Out for These

Mistake

CodeCommit is just a fancy word for AWS S3, they both store files.

Correct

S3 is an object storage service for any type of file. CodeCommit is a Git repository that tracks file versions, manages branches, and supports collaborative workflows like merging and pull requests. S3 has no native version control or Git integration.

Both store data in AWS cloud, so beginners assume they are interchangeable. The exam will exploit this confusion by presenting a scenario where a team needs collaborative editing features – the wrong answer often suggests S3.

Mistake

AWS CodeArtifact is only for storing Docker images.

Correct

CodeArtifact is a general-purpose artefact repository that supports multiple package formats including Maven (Java), npm (Node.js), PyPI (Python), NuGet (.NET), and generic packages. Docker images have their own service called Amazon ECR (Elastic Container Registry).

Students often hear 'artefact' and think only of containers. The exam will test your knowledge of which AWS service handles which package type.

Mistake

If you use CodeCommit, you cannot use any other Git provider like GitHub or GitLab.

Correct

AWS CodeCommit can coexist with other Git providers. Many organisations use GitHub for open-source code and CodeCommit for proprietary internal code. CodeCommit is fully compatible with the Git protocol, so standard Git commands work with it.

People assume AWS services are mutually exclusive. The exam will present scenarios where a team uses both CodeCommit and GitHub, asking how to manage access across them.

Mistake

Artefact repositories are optional – you can just store built software in CodeCommit alongside source code.

Correct

Storing large binary artefacts (compiled packages) in a Git repository like CodeCommit is against best practice. It bloats the repository, slows down cloning, and wastes storage. CodeArtifact is specifically designed to store and serve compiled packages efficiently, with features like caching and proxy of upstream repositories.

It seems convenient to keep everything in one place. Beginners don't realise that Git is not designed for large binaries and that mixing source and artefacts creates management headaches. The exam tests this best practice as a correct answer choice.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between CodeCommit and CodeArtifact?

CodeCommit is for storing source code files and tracking their change history (version control). CodeArtifact is for storing built, packaged software artefacts like .jar or .zip files. You store code in CodeCommit, then build it, and store the result in CodeArtifact.

Can I use CodeCommit without Git?

No. CodeCommit is a Git-based repository, and you must use Git commands or Git-compatible tools (like Visual Studio Code or AWS CLI) to interact with it. There is no other way to upload or download files.

How do I control who can access my CodeCommit repository?

You use AWS IAM (Identity and Access Management) policies. You can create IAM users or roles and attach policies that allow specific actions like 'codecommit:GitPull' and 'codecommit:GitPush'. You can even restrict access to specific branches.

Is CodeArtifact only for Java or Maven packages?

No. CodeArtifact supports Maven, npm, PyPI, NuGet, and generic package formats. You can store any type of file as a 'generic' package, but for Docker images you should use Amazon ECR instead.

Can CodeArtifact automatically download packages from the public internet?

Yes. You can configure an 'upstream repository' in CodeArtifact that points to a public repository like npmjs.org. When a developer requests a package, CodeArtifact first checks its own cache, and if missing, fetches it from the public repository and caches it locally.

What happens if someone tries to merge conflicting code changes in CodeCommit?

CodeCommit will block the merge attempt. You need to resolve the conflict manually by editing the conflicting files on your local machine, marking them as resolved, and then pushing the corrected merge commit. CodeCommit provides tools in its web console to help you see conflicts.

Terms Worth Knowing

Keep going

You've finished Source Control and Artifact Management with CodeCommit and CodeArtifact. Continue through the DOP-C02 study guide to build a complete picture of the exam.

Done with this chapter?