Skip to main content
In this lesson we’ll explore AWS CodeArtifact from the console and explain how domains, repositories, and upstream stores work. This guide focuses on common SDLC automation tasks: building and managing artifacts, and configuring artifact repositories for consumption by package managers like npm, Maven, and pip. CodeArtifact provides a managed artifact registry as an alternative to storing artifacts in S3. It supports multiple package formats and simplifies dependency resolution by caching upstream public registries.

Core concepts

  • Domains: top-level containers, typically used per organization (or per business unit). Domains deduplicate package storage across repositories — the same package version stored in multiple repositories is only kept once.
  • Repositories: live inside domains and support one or more package formats (Maven, npm, PyPI, RubyGems, etc.). Repositories can be:
    • Primary — host your own packages.
    • Pass-through (upstream-enabled) — act as caches that fetch packages from upstream public registries.
  • Upstream stores: configured public or private registries that CodeArtifact queries when a requested package is not present locally; the fetched package is then cached.
When you create a repository you can add upstream stores (for example, Maven Central). If a requested package is missing, CodeArtifact retrieves it from the upstream store and caches it for subsequent requests.
A screenshot of the AWS CodeArtifact "Create repository" page with a package store selection dialog open and "maven-central-store" checked among options like npm-store, pypi-store and rubygems-store. The dialog shows the repository selection and navigation buttons ("Cancel" and "Next") at the bottom.
If you select multiple upstream stores (for example, Maven Central and a CommonsWare store), CodeArtifact uses those upstreams when resolving packages. The console visualizes package flow from external registries into your repository and the upstream stores it relies on.
A screenshot of the AWS CodeArtifact console showing a "Package flow" diagram that maps external Maven connections (public:maven-central and public:maven-commonsware) to upstream stores and a repository named "maven2-repo." Below the diagram is the "Create repository" summary form with a "Create repository" button.
When repositories are created with upstreams enabled, CodeArtifact sets up the corresponding upstream store entries and caching behavior automatically. You can review and manage repositories in the console.
A screenshot of the AWS CodeArtifact Repositories console showing a table of repositories with their domain, owner, and descriptions. Visible repository names include commonsware-store, maven-central-store, maven-packages, npm-packages, and pypi-packages, with the Developer Tools navigation in the left sidebar.

Repository details and console features

  • Metadata: each repository displays metadata (ARN, tags, upstream stores, domain).
  • Connection instructions: the console provides ready-made, tool-specific instructions for npm, Maven, pip, and more.
  • Resource policies: apply resource-based repository policies to grant other AWS accounts access to a repository.
A screenshot of the AWS CodeArtifact console showing the "maven2-repo" repository details (domain "devops-demo-domain", repository ARN) with buttons to delete, edit, or view connection instructions. The packages table below is empty.
Example repository policy (resource policy JSON). Add statements here to allow another AWS account access:
You can also create generic (non-upstream) repositories to store installers, ML models, container artifacts, or other binary artifacts.
A screenshot of the AWS CodeArtifact "Create repository" web page with form fields for repository name, description, and public upstream repositories. The left shows step navigation and there's a "Next" button at the bottom right.

Cross-account access and encryption

  • Cross-account access: to grant other AWS accounts access to resources in your CodeArtifact domain, you must use a customer-managed CMK (Customer Master Key). AWS-managed keys cannot be used for cross-account CodeArtifact access.
  • Typical strings you will see when configuring endpoints and KMS ARNs:
(The placeholders above are wrapped in backticks to prevent MDX parsing issues.) Domain policy example
  • Domain policies are resource-based policies where the Principal can specify an account to grant permissions such as GetDomainPermissionsPolicy, ListRepositoriesInDomain, GetAuthorizationToken, and DescribeDomain.

Command-line usage and connection tips

CodeArtifact provides helper commands to configure package clients. Use aws codeartifact login to automatically configure npm or pip to use your repository endpoint. Common pitfall: “Domain not found” errors typically happen when the CLI command omits the --region flag or the --domain-owner value for a cross-account domain. Always specify the correct --region and --domain-owner when targeting domains outside your default region or account.
If you see “Domain not found”, verify you are targeting the correct region and domain owner account. A missing --region is a common cause.
Example: npm login (failing then fixed by specifying region) Command that fails (missing region):
Typical error output:
Command that succeeds (region specified):
Successful output example:

Maven connection instructions

The CodeArtifact console also provides exact steps to export an authorization token and add it to Maven’s settings.xml. Windows (CMD) example to set a token in an environment variable:
Example settings.xml server entry (use the CODEARTIFACT_AUTH_TOKEN as the password):
You can add the repository and activate it by default in a Maven profiles section:

Quick reference

Note: In table examples, wrap any placeholders or angle-bracket values in backticks (e.g., --domain <domain>) when you copy and adapt commands.
A screenshot of the AWS CodeArtifact web console showing the "maven-packages" repository page (marked "Connected to public repository") with no packages listed and buttons to view connection instructions, delete, or edit the repository.

Final notes

  • Domains contain repositories; repositories can be primary or pass-through (upstream-enabled).
  • Upstream-enabled repositories reduce external requests by caching packages fetched from public registries.
  • Use customer-managed CMKs for cross-account access and ensure CLI commands include --region when working outside your default region.
That’s the demo for AWS CodeArtifact. Thanks for following this lesson — see you in the next one.

Watch Video

Practice Lab