CodeArtifact Repository Deployer
An AWS CloudOps agent skill that provisions AWS CodeArtifact domains and
repositories with correct production defaults — package-format-aware
configuration, upstream chaining, external connections, cross-account
domain sharing, and repository IAM. Emits a READY_TO_DEPLOY checklist
verifying every prerequisite.
Quick navigation
| Need |
Section |
| What MUST be in the response |
"STRICT output contract" |
| Why the provisioning order matters |
"Reasoning framework" |
| What to verify before provisioning |
"Prerequisites" |
| The ordered provisioning steps |
"Deployment procedure" |
| Common silent-failure pitfalls |
"NEVER" |
| Upstreams, external connections, domain sharing, IAM |
"Deployment procedure" Steps 3-8 |
| Format-specific defaults |
"Workload matrix" |
| 2024-2026 feature changes |
"Recent AWS features" |
| Deep CLI sequences |
references/deployment-cli-commands.md |
| Upstream chaining, domain sharing, IAM, login CLI guide |
references/upstreams-and-cross-account-guide.md |
STRICT output contract
When this skill is invoked with a CodeArtifact provisioning request
(domain name, repository name, package format, upstreams, or a partial
existing configuration), the agent MUST respond with the
READY_TO_DEPLOY checklist defined in "Output format" using the literal
all-caps labels REPOSITORY:, VERDICT:, CHECKLIST:, and
VERIFICATION_COMMANDS:. Do NOT preface the checklist with prose,
headings, or disclaimers — emit the block as the first lines of the
response.
Required output structure
REPOSITORY: <repository-arn-or-name> — the CodeArtifact repository
being provisioned.
VERDICT: READY_TO_DEPLOY OR VERDICT: PREREQUISITES_MISSING.
CHECKLIST: followed by indented lines with status markers
([✓], [✗], [OPTIONAL], [INPUT NEEDED]).
VERIFICATION_COMMANDS: followed by indented aws codeartifact ...
commands.
FORBIDDEN output patterns
- No prose preamble before
REPOSITORY: — the first non-empty line
MUST be REPOSITORY:.
- No markdown variants of labels — write
VERDICT:, not
**VERDICT:**, ### Verdict, Verdict =, or `VERDICT`.
- No swapping verdict tokens — exactly
READY_TO_DEPLOY or
PREREQUISITES_MISSING. Not "ready", "missing", "BLOCKED", "OK".
- No omitting
VERIFICATION_COMMANDS: — include even when
PREREQUISITES_MISSING; the operator needs commands to verify gaps.
- No extra sections after
VERIFICATION_COMMANDS: — the checklist
block is the entire response. Put deeper explanation in references/.
- No status marker drift — use only
[✓], [✗], [OPTIONAL],
[INPUT NEEDED]. Do not invent [?], [!], [WARN], or emoji.
Perfect example (copy the shape exactly)
REPOSITORY: shared-npm
VERDICT: READY_TO_DEPLOY
CHECKLIST:
[✓] Domain — shared (existing, owner 123456789012)
[✓] Repository — shared-npm
[✓] Format — npm
[✓] Upstream — shared-internal (internal npm mirror) + external:npmjs
[✓] External connection — public:npmjs (CodeArtifact managed)
[✓] Connection — arn:aws:codeartifact:us-east-1:123456789012:repository/shared/shared-npm
[✓] Domain owner IAM — arn:aws:iam::123456789012:role/devops-admin (codeartifact:* on domain)
[✓] Repository consume policy — arn:aws:iam::123456789012:role/ci-build (codeartifact:ReadFromRepository, codeartifact:GetPackageVersionAsset, codeartifact:GetAuthorizationToken)
[✓] Repository publish policy — arn:aws:iam::123456789012:role/release-pipeline (codeartifact:PublishPackageVersion, codeartifact:PutPackageMetadata, codeartifact:UpdatePackageVersionsStatus)
[OPTIONAL] Cross-account domain share — none (single-account deployment)
[OPTIONAL] Package ingestion — copy-package from upstream as needed
[OPTIONAL] Lifecycle policy — retain last 100 versions per package
VERIFICATION_COMMANDS:
aws codeartifact describe-domain --domain shared --domain-owner 123456789012
aws codeartifact describe-repository --domain shared --repository shared-npm
aws codeartifact list-repositories-in-domain --domain shared
aws codeartifact list-external-connections --domain shared
aws codeartifact get-repository-endpoint --domain shared --repository shared-npm --format npm
aws codeartifact login --tool npm --repository shared-npm --domain shared --domain-owner 123456789012
Reasoning framework (why the provisioning order matters)
CodeArtifact provisioning has dependency and ordering constraints
that make the procedure non-trivial. Applying configurations in the
wrong order causes empty repositories, failed npm install, broken
cross-account shares, or packages that cannot be published:
- Domain FIRST, then repository — a CodeArtifact repository MUST
belong to a domain. The domain is the unit of sharing (via RAM),
billing, and policy inheritance. Creating a repository without a
parent domain is impossible.
- External connection BEFORE upstream — an external connection
(
public:npmjs, public:pypi, public:maven-central,
public:nuget-org, public:cargo, public:rubygems) is a
CodeArtifact-managed bridge to a public registry. It is attached
to a repository in the domain, not directly to the repository
chain. Misordering creates a repository with no upstream.
- Upstream chain order matters — a repository points at upstream
repositories in priority order. Package resolution walks the chain
left-to-right. A package published in an earlier upstream shadows
a package with the same name in a later upstream. The order is
internal-mirror -> ... -> external-connection (most-internal
first).
- Domain sharing via RAM BEFORE consumer IAM — to share a domain
across accounts, the domain owner attaches a domain permissions
policy granting
codeartifact:* to the consumer account root.
THEN the consumer account's IAM grants its principals
codeartifact:CreateRepository, ReadFromRepository, etc.
- IAM is resource-scoped, not repository-scoped — CodeArtifact
IAM policies attach to the domain, not individual repositories.
A repository policy is OPTIONAL and supplements the domain policy.
codeartifact login requires an authorization token — the
codeartifact login CLI generates a short-lived (default 12-hour)
authorization token via GetAuthorizationToken. The token must
be exchanged for a per-format credential (npm: .npmrc, pip:
pip config, maven: settings.xml). The caller IAM must allow
codeartifact:GetAuthorizationToken.
- Package version immutability — once a package version is
published, it cannot be overwritten.
PublishPackageVersion with
the same version+revision is rejected. CI pipelines must use
unique versions or --revision overrides.
Prerequisites (verify before deployment)
| Prerequisite |
Why it matters |
How to verify |
| AWS account ID (domain owner) |
Domain ARN includes the owner account. Cross-account references must use the owner ID. |
aws sts get-caller-identity --query Account --output text |
| Domain exists OR is being created |
A repository cannot exist without a parent domain. |
aws codeartifact describe-domain --domain <name> |
| Domain owner IAM role |
Caller needs codeartifact:CreateDomain, codeartifact:CreateRepository, codeartifact:AssociateExternalConnection. |
aws sts get-caller-identity |
| External connection availability |
public:npmjs etc. are managed by CodeArtifact; availability is Region-dependent. |
aws codeartifact list-external-connections --domain <name> |
| KMS key (optional) |
CodeArtifact domains can be encrypted with a customer-managed KMS key. Default is AWS-owned. |
aws codeartifact describe-domain --domain <name> --query domain.encryptionKey |
| Cross-account consumer account ID (if sharing) |
The consumer account root ARN appears in the domain permissions policy. |
aws sts get-caller-identity in consumer account |
| Consumer IAM principal (if cross-account) |
Consumer account must grant its role codeartifact:ReadFromRepository etc. |
aws iam get-role --role-name <role> in consumer account |
| VPC endpoints (if private network) |
CodeArtifact interface VPC endpoints keep traffic off the public internet. |
aws ec2 describe-vpc-endpoints --filters service-name=codeartifact.<region>.amazonaws.com |
| IAM permissions for caller |
Caller needs codeartifact:Create*, codeartifact:PutRepositoryPermissionsPolicy, ram:CreateResourceShare. |
aws sts get-caller-identity |
Deployment procedure (apply in order)
Step 1: Create (or reuse) the domain
A domain is the unit of organization, sharing, and policy inheritance.
Create the domain in the owner account:
create-domain command (optional CMK): Diagnostic commands
Domain naming rules:
- Domain names are unique within an account + Region.
- Use a short, organization-wide name (
shared, companyname), not
a per-team name (per-team separation is at the repository level).
- Domain names cannot be renamed — choose carefully.
If the domain already exists, describe-domain returns the ARN
without error. Reusing a domain is the common case.
Step 2: Create the repository
A repository holds packages of one or more formats. CodeArtifact
repositories are format-aware — the format is implied by the endpoint
used (npm, pip, maven, nuget, cargo, rubygems, swift,
generic).
create-repository command with tags: Diagnostic commands
Repository naming rules:
- Repository names are unique within a domain.
- Use a
<domain>-<format> convention (shared-npm, shared-pip,
shared-maven) to avoid collisions.
- Repositories can hold multiple formats in principle, but the
standard pattern is one repository per format.
Step 3: Configure external connections (public upstreams)
External connections are CodeArtifact-managed bridges to public
registries. Available external connections:
| External connection |
Public registry |
public:npmjs |
npm (npmjs.com) |
public:pypi |
Python Package Index |
public:maven-central |
Maven Central |
public:maven-googleandroid |
Google Android Maven |
public:maven-gradleplugins |
Gradle plugins |
public:nuget-org |
NuGet Gallery |
public:cargo |
crates.io |
public:rubygems |
RubyGems |
Associate an external connection with a repository:
associate-external-connection command: Diagnostic commands
Once associated, the external connection appears in the repository's
externalConnections list. The repository can resolve packages from
the public registry without further configuration.
Step 4: Configure upstream repositories (internal chaining)
Upstream repositories chain internal repos + external connections.
Resolution walks the chain left-to-right; the first match wins.
update-repository single-upstream command: Diagnostic commands
For multi-hop chains:
Multi-hop chain command: Diagnostic commands
Resolution order for team-payments-npm:
team-payments-npm itself (first-party packages)
team-payments-internal (curated internal mirror)
shared-npm (org-wide mirror)
shared-internal (org-wide curated)
public:npmjs (external)
NEVER put an external connection upstream of an internal mirror.
Public packages with the same name would shadow internal packages,
creating a supply-chain risk.
Step 5: Configure repository IAM policies
CodeArtifact IAM is resource-scoped (the domain). A repository policy
is OPTIONAL and supplements the domain policy. Two patterns:
The three IAM policy JSON patterns (domain-owner admin, CI consume, release publish): Diagnostic commands
Apply a repository policy via put-repository-permissions-policy or
attach the policy to the IAM role. The role-based pattern is
recommended (it scales across repositories).
Step 6: Wire CI builds via the codeartifact login CLI
The codeartifact login CLI generates a short-lived authorization
token and configures the local package manager. The caller IAM must
allow codeartifact:GetAuthorizationToken and
codeartifact:ReadFromRepository.
Login CLI blocks for npm, pip, maven, and nuget: Diagnostic commands
Token lifetime defaults to 12 hours (max 12 hours, configurable via
--duration-seconds). For CI pipelines, run codeartifact login at
the start of each build.
Step 7: Cross-account domain sharing via RAM
To share a domain with another AWS account:
Domain-policy heredoc and put-domain-permissions-policy command: Diagnostic commands
Then the consumer account grants its principals
codeartifact:GetAuthorizationToken and
codeartifact:ReadFromRepository on the shared domain's ARN (owner
account ID embedded in the ARN).
Cross-account RAM resource share (alternative): for multi-account
sharing with Organizations or OUs, use a RAM resource share:
ram create-resource-share command: Diagnostic commands
RAM-based sharing is the recommended pattern for Organizations-based
multi-account setups. Full reference in
references/upstreams-and-cross-account-guide.md.
Step 8: Package ingestion via copy-package
To mirror a specific package version from upstream into the local
repository (e.g., to pin a version or air-gap):
copy-package-versions ingest command: Diagnostic commands
For air-gapped environments, copy-package-versions can pull from an
external-connection repository into an internal-only repository.
Step 9: Configure lifecycle policies (optional)
Lifecycle policies auto-retain or delete old package versions, preventing
unbounded growth on high-velocity internal packages. Policies support
retain and delete actions scoped by version count or age. Configured
via CloudFormation / IaC; see references/upstreams-and-cross-account-guide.md
for the full policy JSON schema and CLI surface.
Step 10: Tag, verify, and test the login
Verification and login smoke-test commands: Diagnostic commands
Edge-case handling
All eight edge cases (ENEEDAUTH, public-registry shadowing, cross-account AccessDenied, VersionConflict, Swift/Cargo Region gaps, private networks, token expiry, domain ownership transfer): Error handling.
Workload matrix
| Format |
Repository convention |
External connection |
Login tool |
Notes |
| npm (Node.js) |
<domain>-npm |
public:npmjs |
--tool npm |
Default recommendation; updates ~/.npmrc |
| pip (Python) |
<domain>-pip |
public:pypi |
--tool pip |
Configures pip.conf |
| maven (Java) |
<domain>-maven |
public:maven-central |
--tool mvn |
Updates ~/.m2/settings.xml |
| nuget (.NET) |
<domain>-nuget |
public:nuget-org |
--tool nuget |
Updates nuget.config |
| cargo (Rust) |
<domain>-cargo |
public:cargo |
manual config |
No native --tool cargo login |
| rubygems (Ruby) |
<domain>-rubygems |
public:rubygems |
manual config |
Configure gem source manually |
| swift |
<domain>-swift |
(Region-dependent) |
manual config |
Use SwiftPM Package.swift |
| generic |
<domain>-generic |
n/a |
n/a |
Any package format; manual publish |
Recent AWS features (2024-2026)
2024-2026 feature notes (Swift GA, Maven/NuGet login, immutability enforcement, policy-revision tracking, RAM GA, VPC endpoints, lifecycle, batch copy): Advanced patterns.
mirroring workflows.
NEVER (top 5 — full list in references)
- NEVER put an external connection (
public:npmjs, public:pypi, etc.)
upstream of an internal mirror in the chain. Public packages with the
same name would shadow internal packages — a supply-chain attack
vector. Order upstreams internal-first, external-last.
- NEVER grant
codeartifact:* to broad principals (e.g., * or
Developers). Scope repository consume and publish policies to the
specific role and the specific repository ARN.
- NEVER create a repository without verifying the parent domain exists
(or is being created in the same stack). The repository creation
silently fails with
ResourceNotFoundException.
- NEVER store long-lived
GetAuthorizationToken output in CI secrets.
Tokens expire in 12h; refresh via codeartifact login at the start
of each build. Long-lived tokens in CI secrets are a credential
leak risk.
- NEVER assume external connections are available in all Regions. Swift
and Cargo external connections are Region-limited. Verify with
list-external-connections before configuring upstreams.
Expert heuristic — designing domains, repositories, and upstreams
The nine design heuristics (one domain per org, one repository per format, internal-first cascade, per-format external connections, RAM over policy-only, login at build start, release-pipeline publishing, lifecycle retention, VPC endpoints): Advanced patterns.
Pre-flight safety checks (run before any provisioning CLI)
Pre-flight confirmation commands (owner account, domain, external connections, CI role, cross-account, VPC endpoints, KMS): Diagnostic commands
Output format — MANDATORY literal labels
When invoked with a CodeArtifact provisioning request, your ENTIRE
response MUST be the checklist block below. The labels are
case-sensitive all-caps keywords — write them EXACTLY as shown.
Do NOT write a preamble. Start with REPOSITORY: and stop after the
VERIFICATION_COMMANDS: block.
REPOSITORY: <repository-name>
VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING
CHECKLIST:
[✓] Domain — <domain-name> (existing | new, owner <account-id>)
[✓] Repository — <repository-name>
[✓] Format — <npm | pip | maven | nuget | cargo | rubygems | swift | generic>
[✓] Upstream chain — <internal-mirror> -> ... -> external:<registry>
[✓] External connection — public:<registry>
[✓] Connection — arn:aws:codeartifact:<region>:<account>:repository/<domain>/<repo>
[✓] Domain owner IAM — <admin-role-arn> (codeartifact:* on domain)
[✓] Repository consume policy — <ci-role-arn> (ReadFromRepository, GetAuthorizationToken, GetPackageVersionAsset)
[✓] Repository publish policy — <release-role-arn> (PublishPackageVersion, PutPackageMetadata)
[OPTIONAL] Cross-account domain share — <none | RAM resource share | consumer account IDs>
[OPTIONAL] Package ingestion — <none | copy-package-versions batch>
[OPTIONAL] Lifecycle policy — <none | retain last N versions>
VERIFICATION_COMMANDS:
aws codeartifact describe-domain --domain <domain> --domain-owner <account-id>
aws codeartifact describe-repository --domain <domain> --repository <repo>
aws codeartifact list-repositories-in-domain --domain <domain>
aws codeartifact list-external-connections --domain <domain>
aws codeartifact get-repository-endpoint --domain <domain> --repository <repo> --format <format>
aws codeartifact login --tool <tool> --repository <repo> --domain <domain> --domain-owner <account-id>
Status marker semantics:
[✓] — applied and verified.
[✗] — NOT applied or misconfigured. Cite the gap.
[OPTIONAL] — recommended but not required for the workload type.
[INPUT NEEDED] — prerequisite value missing; operator must provide.
PREREQUISITES_MISSING verdict: if any REQUIRED prerequisite is
missing (parent domain, external connection unavailable in Region,
CI role ARN, KMS key for encrypted domain), the verdict is
PREREQUISITES_MISSING with each gap listed.
References (load on demand)
- Diagnostic commands — per-step deployment commands and IAM policy JSON (Steps 1-10), plus pre-flight checks
- Error handling — edge-case handling
- Advanced patterns — expert design heuristics and recent AWS features
- Deployment CLI commands — full copy-pasteable CLI sequence with Terraform equivalents
- Upstreams and cross-account guide — upstream chaining, domain sharing, IAM patterns, full NEVER list
Domain
AWS CloudOps / Package Repository Provisioning.
AWS documentation
References
references/deployment-cli-commands.md — full copy-pasteable CLI
command sequence for all 10 provisioning steps, including Terraform
equivalents and per-format (npm / pip / maven / nuget / cargo /
rubygems / swift) snippets.
references/upstreams-and-cross-account-guide.md — deep reference
on upstream chaining semantics, external connection internals,
cross-account RAM sharing, IAM policy patterns, the full NEVER
list, and edge-case handling.
1---2name: codeartifact-repository-deployer3description: 'Provisions AWS CodeArtifact repositories: domain creation, repository creation across package formats (npm, pip, maven, nuget, cargo, rubygems, generic, swift), upstream repositories (public: npmjs, pypi, maven-central, nuget-org), external connections, package ingestion via copy-package, cross-account domain sharing via RAM, repository IAM policies (read/write/consume), codeartifact login CLI for npm/pip/maven, package versions, and lifecycle policies. Emits a READY_TO_DEPLOY checklist with every prerequisite verified. Use when creating a CodeArtifact domain or repository, configuring upstreams, sharing a domain across accounts, or wiring a package build to CodeArtifact. Triggers: codeartifact domain, codeartifact repository, npm pip maven nuget cargo rubygems swift repository, codeartifact upstream, codeartifact external connection, codeartifact login, codeartifact copy-package, codeartifact domain sharing, RAM codeartifact, codeartifact IAM policy.'4license: Apache-2.05compatibility: 'Requires an LLM agent runtime (Claude Code, Cursor, Windsurf, Codex, Gemini). For live deployment: AWS CLI v2 with codeartifact, ram, iam, sts, and resourcegroupstaggingapi access. Works with Terraform aws_codeartifact_domain / aws_codeartifact_repository / aws_codeartifact_domain_permissions_policy resources, CloudFormation AWS::CodeArtifact::Domain / AWS::CodeArtifact::Repository, and the CodeArtifact login CLI for npm / pip / maven.'6metadata:7 source: https://skillmd.com/skills/jhkchan/codeartifact-repository-deployer8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '1'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: DevTools15 task_type: deploy16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY_TO_DEPLOY | PREREQUISITES_MISSING19 version: 0.1.020 author: Jacky Chan — AWS Community Builder21 tags: aws, codeartifact, devtools, cloudops, deploy, package-repository, npm, pip, maven22 dependencies: aws-orchestrator23 keywords: aws, codeartifact, devtools, cloudops, deploy, provisioning, package-repository, npm, pip, maven, nuget, cargo, rubygems, swift, upstream, external-connection, domain-sharing, ram24 when_to_use: Invoke when the user wants to create a CodeArtifact domain or repository, configure upstream repositories (npmjs, pypi, maven-central, nuget-org), share a domain across AWS accounts via RAM, set repository permissions (read/write/consume), wire a CI build to CodeArtifact via the login CLI, or ingest packages from upstream. Do NOT invoke for plain S3-backed package storage, GitHub Packages (separate service), or for general artifact management outside CodeArtifact.25---2627# CodeArtifact Repository Deployer2829An AWS CloudOps agent skill that provisions AWS CodeArtifact domains and30repositories with correct production defaults — package-format-aware31configuration, upstream chaining, external connections, cross-account32domain sharing, and repository IAM. Emits a READY_TO_DEPLOY checklist33verifying every prerequisite.3435## Quick navigation3637| Need | Section |38|---|---|39| What MUST be in the response | "STRICT output contract" |40| Why the provisioning order matters | "Reasoning framework" |41| What to verify before provisioning | "Prerequisites" |42| The ordered provisioning steps | "Deployment procedure" |43| Common silent-failure pitfalls | "NEVER" |44| Upstreams, external connections, domain sharing, IAM | "Deployment procedure" Steps 3-8 |45| Format-specific defaults | "Workload matrix" |46| 2024-2026 feature changes | "Recent AWS features" |47| Deep CLI sequences | `references/deployment-cli-commands.md` |48| Upstream chaining, domain sharing, IAM, login CLI guide | `references/upstreams-and-cross-account-guide.md` |4950## STRICT output contract5152When this skill is invoked with a CodeArtifact provisioning request53(domain name, repository name, package format, upstreams, or a partial54existing configuration), the agent MUST respond with the55READY_TO_DEPLOY checklist defined in "Output format" using the literal56all-caps labels `REPOSITORY:`, `VERDICT:`, `CHECKLIST:`, and57`VERIFICATION_COMMANDS:`. Do NOT preface the checklist with prose,58headings, or disclaimers — emit the block as the first lines of the59response.6061### Required output structure62631. `REPOSITORY: <repository-arn-or-name>` — the CodeArtifact repository64 being provisioned.652. `VERDICT: READY_TO_DEPLOY` OR `VERDICT: PREREQUISITES_MISSING`.663. `CHECKLIST:` followed by indented lines with status markers67 (`[✓]`, `[✗]`, `[OPTIONAL]`, `[INPUT NEEDED]`).684. `VERIFICATION_COMMANDS:` followed by indented `aws codeartifact ...`69 commands.7071### FORBIDDEN output patterns7273- **No prose preamble before `REPOSITORY:`** — the first non-empty line74 MUST be `REPOSITORY:`.75- **No markdown variants of labels** — write `VERDICT:`, not76 `**VERDICT:**`, `### Verdict`, `Verdict =`, or `` `VERDICT` ``.77- **No swapping verdict tokens** — exactly `READY_TO_DEPLOY` or78 `PREREQUISITES_MISSING`. Not "ready", "missing", "BLOCKED", "OK".79- **No omitting `VERIFICATION_COMMANDS:`** — include even when80 PREREQUISITES_MISSING; the operator needs commands to verify gaps.81- **No extra sections after `VERIFICATION_COMMANDS:`** — the checklist82 block is the entire response. Put deeper explanation in `references/`.83- **No status marker drift** — use only `[✓]`, `[✗]`, `[OPTIONAL]`,84 `[INPUT NEEDED]`. Do not invent `[?]`, `[!]`, `[WARN]`, or emoji.8586### Perfect example (copy the shape exactly)8788```text89REPOSITORY: shared-npm90VERDICT: READY_TO_DEPLOY91CHECKLIST:92 [✓] Domain — shared (existing, owner 123456789012)93 [✓] Repository — shared-npm94 [✓] Format — npm95 [✓] Upstream — shared-internal (internal npm mirror) + external:npmjs96 [✓] External connection — public:npmjs (CodeArtifact managed)97 [✓] Connection — arn:aws:codeartifact:us-east-1:123456789012:repository/shared/shared-npm98 [✓] Domain owner IAM — arn:aws:iam::123456789012:role/devops-admin (codeartifact:* on domain)99 [✓] Repository consume policy — arn:aws:iam::123456789012:role/ci-build (codeartifact:ReadFromRepository, codeartifact:GetPackageVersionAsset, codeartifact:GetAuthorizationToken)100 [✓] Repository publish policy — arn:aws:iam::123456789012:role/release-pipeline (codeartifact:PublishPackageVersion, codeartifact:PutPackageMetadata, codeartifact:UpdatePackageVersionsStatus)101 [OPTIONAL] Cross-account domain share — none (single-account deployment)102 [OPTIONAL] Package ingestion — copy-package from upstream as needed103 [OPTIONAL] Lifecycle policy — retain last 100 versions per package104VERIFICATION_COMMANDS:105 aws codeartifact describe-domain --domain shared --domain-owner 123456789012106 aws codeartifact describe-repository --domain shared --repository shared-npm107 aws codeartifact list-repositories-in-domain --domain shared108 aws codeartifact list-external-connections --domain shared109 aws codeartifact get-repository-endpoint --domain shared --repository shared-npm --format npm110 aws codeartifact login --tool npm --repository shared-npm --domain shared --domain-owner 123456789012111```112113## Reasoning framework (why the provisioning order matters)114115CodeArtifact provisioning has **dependency and ordering constraints**116that make the procedure non-trivial. Applying configurations in the117wrong order causes empty repositories, failed `npm install`, broken118cross-account shares, or packages that cannot be published:1191201. **Domain FIRST, then repository** — a CodeArtifact repository MUST121 belong to a domain. The domain is the unit of sharing (via RAM),122 billing, and policy inheritance. Creating a repository without a123 parent domain is impossible.1242. **External connection BEFORE upstream** — an external connection125 (`public:npmjs`, `public:pypi`, `public:maven-central`,126 `public:nuget-org`, `public:cargo`, `public:rubygems`) is a127 CodeArtifact-managed bridge to a public registry. It is attached128 to a repository in the domain, not directly to the repository129 chain. Misordering creates a repository with no upstream.1303. **Upstream chain order matters** — a repository points at upstream131 repositories in priority order. Package resolution walks the chain132 left-to-right. A package published in an earlier upstream shadows133 a package with the same name in a later upstream. The order is134 `internal-mirror -> ... -> external-connection` (most-internal135 first).1364. **Domain sharing via RAM BEFORE consumer IAM** — to share a domain137 across accounts, the domain owner attaches a domain permissions138 policy granting `codeartifact:*` to the consumer account root.139 THEN the consumer account's IAM grants its principals140 `codeartifact:CreateRepository`, `ReadFromRepository`, etc.1415. **IAM is resource-scoped, not repository-scoped** — CodeArtifact142 IAM policies attach to the domain, not individual repositories.143 A repository policy is OPTIONAL and supplements the domain policy.1446. **`codeartifact login` requires an authorization token** — the145 `codeartifact login` CLI generates a short-lived (default 12-hour)146 authorization token via `GetAuthorizationToken`. The token must147 be exchanged for a per-format credential (npm: `.npmrc`, pip:148 `pip config`, maven: `settings.xml`). The caller IAM must allow149 `codeartifact:GetAuthorizationToken`.1507. **Package version immutability** — once a package version is151 published, it cannot be overwritten. `PublishPackageVersion` with152 the same version+revision is rejected. CI pipelines must use153 unique versions or `--revision` overrides.154155## Prerequisites (verify before deployment)156157| Prerequisite | Why it matters | How to verify |158|---|---|---|159| **AWS account ID (domain owner)** | Domain ARN includes the owner account. Cross-account references must use the owner ID. | `aws sts get-caller-identity --query Account --output text` |160| **Domain exists OR is being created** | A repository cannot exist without a parent domain. | `aws codeartifact describe-domain --domain <name>` |161| **Domain owner IAM role** | Caller needs `codeartifact:CreateDomain`, `codeartifact:CreateRepository`, `codeartifact:AssociateExternalConnection`. | `aws sts get-caller-identity` |162| **External connection availability** | `public:npmjs` etc. are managed by CodeArtifact; availability is Region-dependent. | `aws codeartifact list-external-connections --domain <name>` |163| **KMS key (optional)** | CodeArtifact domains can be encrypted with a customer-managed KMS key. Default is AWS-owned. | `aws codeartifact describe-domain --domain <name> --query domain.encryptionKey` |164| **Cross-account consumer account ID** (if sharing) | The consumer account root ARN appears in the domain permissions policy. | `aws sts get-caller-identity` in consumer account |165| **Consumer IAM principal** (if cross-account) | Consumer account must grant its role `codeartifact:ReadFromRepository` etc. | `aws iam get-role --role-name <role>` in consumer account |166| **VPC endpoints** (if private network) | CodeArtifact interface VPC endpoints keep traffic off the public internet. | `aws ec2 describe-vpc-endpoints --filters service-name=codeartifact.<region>.amazonaws.com` |167| **IAM permissions for caller** | Caller needs `codeartifact:Create*`, `codeartifact:PutRepositoryPermissionsPolicy`, `ram:CreateResourceShare`. | `aws sts get-caller-identity` |168169## Deployment procedure (apply in order)170171### Step 1: Create (or reuse) the domain172173A domain is the unit of organization, sharing, and policy inheritance.174Create the domain in the owner account:175176create-domain command (optional CMK): [Diagnostic commands](references/diagnostic-commands.md)177178Domain naming rules:179180- Domain names are unique within an account + Region.181- Use a short, organization-wide name (`shared`, `companyname`), not182 a per-team name (per-team separation is at the repository level).183- Domain names cannot be renamed — choose carefully.184185If the domain already exists, `describe-domain` returns the ARN186without error. Reusing a domain is the common case.187188### Step 2: Create the repository189190A repository holds packages of one or more formats. CodeArtifact191repositories are format-aware — the format is implied by the endpoint192used (`npm`, `pip`, `maven`, `nuget`, `cargo`, `rubygems`, `swift`,193`generic`).194195create-repository command with tags: [Diagnostic commands](references/diagnostic-commands.md)196197Repository naming rules:198199- Repository names are unique within a domain.200- Use a `<domain>-<format>` convention (`shared-npm`, `shared-pip`,201 `shared-maven`) to avoid collisions.202- Repositories can hold multiple formats in principle, but the203 standard pattern is one repository per format.204205### Step 3: Configure external connections (public upstreams)206207External connections are CodeArtifact-managed bridges to public208registries. Available external connections:209210| External connection | Public registry |211|---|---|212| `public:npmjs` | npm (npmjs.com) |213| `public:pypi` | Python Package Index |214| `public:maven-central` | Maven Central |215| `public:maven-googleandroid` | Google Android Maven |216| `public:maven-gradleplugins` | Gradle plugins |217| `public:nuget-org` | NuGet Gallery |218| `public:cargo` | crates.io |219| `public:rubygems` | RubyGems |220221Associate an external connection with a repository:222223associate-external-connection command: [Diagnostic commands](references/diagnostic-commands.md)224225Once associated, the external connection appears in the repository's226`externalConnections` list. The repository can resolve packages from227the public registry without further configuration.228229### Step 4: Configure upstream repositories (internal chaining)230231Upstream repositories chain internal repos + external connections.232Resolution walks the chain left-to-right; the first match wins.233234update-repository single-upstream command: [Diagnostic commands](references/diagnostic-commands.md)235236For multi-hop chains:237238Multi-hop chain command: [Diagnostic commands](references/diagnostic-commands.md)239240Resolution order for `team-payments-npm`:2411. `team-payments-npm` itself (first-party packages)2422. `team-payments-internal` (curated internal mirror)2433. `shared-npm` (org-wide mirror)2444. `shared-internal` (org-wide curated)2455. `public:npmjs` (external)246247**NEVER put an external connection upstream of an internal mirror.**248Public packages with the same name would shadow internal packages,249creating a supply-chain risk.250251### Step 5: Configure repository IAM policies252253CodeArtifact IAM is resource-scoped (the domain). A repository policy254is OPTIONAL and supplements the domain policy. Two patterns:255256The three IAM policy JSON patterns (domain-owner admin, CI consume, release publish): [Diagnostic commands](references/diagnostic-commands.md)257258Apply a repository policy via `put-repository-permissions-policy` or259attach the policy to the IAM role. The role-based pattern is260recommended (it scales across repositories).261262### Step 6: Wire CI builds via the `codeartifact login` CLI263264The `codeartifact login` CLI generates a short-lived authorization265token and configures the local package manager. The caller IAM must266allow `codeartifact:GetAuthorizationToken` and267`codeartifact:ReadFromRepository`.268269Login CLI blocks for npm, pip, maven, and nuget: [Diagnostic commands](references/diagnostic-commands.md)270271Token lifetime defaults to 12 hours (max 12 hours, configurable via272`--duration-seconds`). For CI pipelines, run `codeartifact login` at273the start of each build.274275### Step 7: Cross-account domain sharing via RAM276277To share a domain with another AWS account:278279Domain-policy heredoc and put-domain-permissions-policy command: [Diagnostic commands](references/diagnostic-commands.md)280281Then the consumer account grants its principals282`codeartifact:GetAuthorizationToken` and283`codeartifact:ReadFromRepository` on the shared domain's ARN (owner284account ID embedded in the ARN).285286**Cross-account RAM resource share (alternative):** for multi-account287sharing with Organizations or OUs, use a RAM resource share:288289ram create-resource-share command: [Diagnostic commands](references/diagnostic-commands.md)290291RAM-based sharing is the recommended pattern for Organizations-based292multi-account setups. Full reference in293`references/upstreams-and-cross-account-guide.md`.294295### Step 8: Package ingestion via `copy-package`296297To mirror a specific package version from upstream into the local298repository (e.g., to pin a version or air-gap):299300copy-package-versions ingest command: [Diagnostic commands](references/diagnostic-commands.md)301302For air-gapped environments, `copy-package-versions` can pull from an303external-connection repository into an internal-only repository.304305### Step 9: Configure lifecycle policies (optional)306307Lifecycle policies auto-retain or delete old package versions, preventing308unbounded growth on high-velocity internal packages. Policies support309`retain` and `delete` actions scoped by version count or age. Configured310via CloudFormation / IaC; see `references/upstreams-and-cross-account-guide.md`311for the full policy JSON schema and CLI surface.312313### Step 10: Tag, verify, and test the login314315Verification and login smoke-test commands: [Diagnostic commands](references/diagnostic-commands.md)316317## Edge-case handling318319All eight edge cases (ENEEDAUTH, public-registry shadowing, cross-account AccessDenied, VersionConflict, Swift/Cargo Region gaps, private networks, token expiry, domain ownership transfer): [Error handling](references/error-handling.md).320321## Workload matrix322323| Format | Repository convention | External connection | Login tool | Notes |324|---|---|---|---|---|325| npm (Node.js) | `<domain>-npm` | `public:npmjs` | `--tool npm` | Default recommendation; updates `~/.npmrc` |326| pip (Python) | `<domain>-pip` | `public:pypi` | `--tool pip` | Configures `pip.conf` |327| maven (Java) | `<domain>-maven` | `public:maven-central` | `--tool mvn` | Updates `~/.m2/settings.xml` |328| nuget (.NET) | `<domain>-nuget` | `public:nuget-org` | `--tool nuget` | Updates `nuget.config` |329| cargo (Rust) | `<domain>-cargo` | `public:cargo` | manual config | No native `--tool cargo` login |330| rubygems (Ruby) | `<domain>-rubygems` | `public:rubygems` | manual config | Configure `gem` source manually |331| swift | `<domain>-swift` | (Region-dependent) | manual config | Use SwiftPM `Package.swift` |332| generic | `<domain>-generic` | n/a | n/a | Any package format; manual publish |333334## Recent AWS features (2024-2026)3353362024-2026 feature notes (Swift GA, Maven/NuGet login, immutability enforcement, policy-revision tracking, RAM GA, VPC endpoints, lifecycle, batch copy): [Advanced patterns](references/advanced-patterns.md).337 mirroring workflows.338339## NEVER (top 5 — full list in references)340341- NEVER put an external connection (`public:npmjs`, `public:pypi`, etc.)342 upstream of an internal mirror in the chain. Public packages with the343 same name would shadow internal packages — a supply-chain attack344 vector. Order upstreams internal-first, external-last.345- NEVER grant `codeartifact:*` to broad principals (e.g., `*` or346 `Developers`). Scope repository consume and publish policies to the347 specific role and the specific repository ARN.348- NEVER create a repository without verifying the parent domain exists349 (or is being created in the same stack). The repository creation350 silently fails with `ResourceNotFoundException`.351- NEVER store long-lived `GetAuthorizationToken` output in CI secrets.352 Tokens expire in 12h; refresh via `codeartifact login` at the start353 of each build. Long-lived tokens in CI secrets are a credential354 leak risk.355- NEVER assume external connections are available in all Regions. Swift356 and Cargo external connections are Region-limited. Verify with357 `list-external-connections` before configuring upstreams.358359## Expert heuristic — designing domains, repositories, and upstreams360361The nine design heuristics (one domain per org, one repository per format, internal-first cascade, per-format external connections, RAM over policy-only, login at build start, release-pipeline publishing, lifecycle retention, VPC endpoints): [Advanced patterns](references/advanced-patterns.md).362363## Pre-flight safety checks (run before any provisioning CLI)364365Pre-flight confirmation commands (owner account, domain, external connections, CI role, cross-account, VPC endpoints, KMS): [Diagnostic commands](references/diagnostic-commands.md)366367## Output format — MANDATORY literal labels368369When invoked with a CodeArtifact provisioning request, your ENTIRE370response MUST be the checklist block below. The labels are371**case-sensitive all-caps keywords** — write them EXACTLY as shown.372Do NOT write a preamble. Start with `REPOSITORY:` and stop after the373`VERIFICATION_COMMANDS:` block.374375```text376REPOSITORY: <repository-name>377VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING378CHECKLIST:379 [✓] Domain — <domain-name> (existing | new, owner <account-id>)380 [✓] Repository — <repository-name>381 [✓] Format — <npm | pip | maven | nuget | cargo | rubygems | swift | generic>382 [✓] Upstream chain — <internal-mirror> -> ... -> external:<registry>383 [✓] External connection — public:<registry>384 [✓] Connection — arn:aws:codeartifact:<region>:<account>:repository/<domain>/<repo>385 [✓] Domain owner IAM — <admin-role-arn> (codeartifact:* on domain)386 [✓] Repository consume policy — <ci-role-arn> (ReadFromRepository, GetAuthorizationToken, GetPackageVersionAsset)387 [✓] Repository publish policy — <release-role-arn> (PublishPackageVersion, PutPackageMetadata)388 [OPTIONAL] Cross-account domain share — <none | RAM resource share | consumer account IDs>389 [OPTIONAL] Package ingestion — <none | copy-package-versions batch>390 [OPTIONAL] Lifecycle policy — <none | retain last N versions>391VERIFICATION_COMMANDS:392 aws codeartifact describe-domain --domain <domain> --domain-owner <account-id>393 aws codeartifact describe-repository --domain <domain> --repository <repo>394 aws codeartifact list-repositories-in-domain --domain <domain>395 aws codeartifact list-external-connections --domain <domain>396 aws codeartifact get-repository-endpoint --domain <domain> --repository <repo> --format <format>397 aws codeartifact login --tool <tool> --repository <repo> --domain <domain> --domain-owner <account-id>398```399400**Status marker semantics:**401- `[✓]` — applied and verified.402- `[✗]` — NOT applied or misconfigured. Cite the gap.403- `[OPTIONAL]` — recommended but not required for the workload type.404- `[INPUT NEEDED]` — prerequisite value missing; operator must provide.405406**PREREQUISITES_MISSING verdict:** if any REQUIRED prerequisite is407missing (parent domain, external connection unavailable in Region,408CI role ARN, KMS key for encrypted domain), the verdict is409`PREREQUISITES_MISSING` with each gap listed.410411## References (load on demand)412413- [Diagnostic commands](references/diagnostic-commands.md) — per-step deployment commands and IAM policy JSON (Steps 1-10), plus pre-flight checks414- [Error handling](references/error-handling.md) — edge-case handling415- [Advanced patterns](references/advanced-patterns.md) — expert design heuristics and recent AWS features416- [Deployment CLI commands](references/deployment-cli-commands.md) — full copy-pasteable CLI sequence with Terraform equivalents417- [Upstreams and cross-account guide](references/upstreams-and-cross-account-guide.md) — upstream chaining, domain sharing, IAM patterns, full NEVER list418419## Domain420421AWS CloudOps / Package Repository Provisioning.422423## AWS documentation424425- **CodeArtifact User Guide** — https://docs.aws.amazon.com/codeartifact/latest/ug/welcome.html426- **CodeArtifact Domains** — https://docs.aws.amazon.com/codeartifact/latest/ug/codeartifact-concepts.html#codeartifact-concepts-domain427- **CodeArtifact Repositories** — https://docs.aws.amazon.com/codeartifact/latest/ug/codeartifact-concepts.html#codeartifact-concepts-repository428- **CodeArtifact Upstreams** — https://docs.aws.amazon.com/codeartifact/latest/ug/codeartifact-concepts.html#codeartifact-concepts-upstream429- **CodeArtifact External Connections** — https://docs.aws.amazon.com/codeartifact/latest/ug/codeartifact-concepts.html#codeartifact-concepts-externalconnection430- **CodeArtifact IAM** — https://docs.aws.amazon.com/codeartifact/latest/ug/auth-and-access-control-iam.html431- **CodeArtifact Domain Sharing** — https://docs.aws.amazon.com/codeartifact/latest/ug/domain-share.html432- **CodeArtifact `login` CLI** — https://docs.aws.amazon.com/codeartifact/latest/ug/npm-auth.html433- **CodeArtifact VPC Endpoints** — https://docs.aws.amazon.com/codeartifact/latest/ug/vpc-support.html434- **CodeArtifact CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/codeartifact/435436## References437438- `references/deployment-cli-commands.md` — full copy-pasteable CLI439 command sequence for all 10 provisioning steps, including Terraform440 equivalents and per-format (npm / pip / maven / nuget / cargo /441 rubygems / swift) snippets.442443- `references/upstreams-and-cross-account-guide.md` — deep reference444 on upstream chaining semantics, external connection internals,445 cross-account RAM sharing, IAM policy patterns, the full NEVER446 list, and edge-case handling.