Files
floci/docs/services/codeartifact.md
T
Priamo Germosen 66bcdaf675 feat(codeartifact): add CodeArtifact control-plane support (#3713)
Floci had zero CodeArtifact support: no service package, no docs, nothing.
Any terraform apply touching aws_codeartifact_domain, aws_codeartifact_repository,
or either permissions-policy resource failed outright. This adds the full
CodeArtifact control plane: domain and repository CRUD, resource policies with
optimistic-locking revisions, tags, and the fixed set of real AWS-hosted
external (upstream) connections (public:npmjs, public:pypi, public:maven-central,
etc.).

Package publish/fetch endpoints per format (npm, PyPI, Maven, NuGet, generic)
are intentionally out of scope here: this closes the terraform apply gap, not
real package serving.

ListTagsForResource (POST /v1/tags?resourceArn=) is CodeArtifact's one tag
operation that addresses the resource with a query parameter on the bare path
rather than a path segment, unlike every other V1TagsController/SharedTagsController
handler. That method lives on V1TagsController itself rather than the shared
AbstractTagsController base: SharedTagsController (mounted at /tags) already
declares its own bare POST (tagResourceByBody, for TagResource), so a bare POST
on the shared base collides with it and Quarkus refuses to start. CodeArtifact's
handler is @V1Tags-qualified and only ever registered against V1TagsController,
so the method belongs there. core/common stays service-free: CodeArtifactTagHandler
registers itself as a bean the same way MskTagHandler does, and TagHandler gained
a default for the lowercase key/value entry names CodeArtifact uses instead of
AWS's usual capitalized Key/Value.

Known, documented limitations (see docs/services/codeartifact.md): no cycle
detection across upstream chains, no referential-integrity check when deleting
a repository other repositories reference as an upstream, and no authorization
check on cross-account domainOwner addressing (consistent with Floci's opt-in
IAM enforcement elsewhere).

Verified against the real botocore codeartifact service-2.json (protocol, exact
querystring vs. body placement per operation, exact ARN format, epoch-seconds
timestamps, real error shapes) and the live AWS API docs for behavioral rules
not in the wire model (DeleteDomain blocked while repositories exist, the real
fixed external-connection name/format list, PutDomainPermissionsPolicy's
all-body field placement vs. the sibling repository operation's querystring
placement).

Live-verified three ways:
- Unit tests including a concurrent-create race test proving the synchronized
  guard actually holds under contention, plus full-stack QuarkusTest/RestAssured
  integration tests.
- A real terraform init/apply/plan/destroy cycle against a running Floci
  instance, independently confirming destroy actually tore the domain down via
  a follow-up describe-domain call.
- A live AWS SDK v2 Java test exercising the real CodeartifactClient against a
  live instance.
2026-09-16 22:01:34 -04:00

82 lines
5.1 KiB
Markdown

# CodeArtifact
**Protocol:** REST JSON
**Endpoint:** `http://localhost:4566`
Floci supports the CodeArtifact control plane: domains, repositories, resource policies, tags,
and public upstream (external) connections. Package publish/fetch endpoints for each format
(npm, PyPI, Maven, NuGet, generic, etc.) are not implemented yet.
## Supported Actions
<!-- floci:actions:start -->
| Action | Description |
| --- | --- |
| `CreateDomain` | Creates a domain, optionally with a KMS encryption key and initial tags. |
| `DeleteDomain` | Deletes a domain; fails with `ConflictException` while it still contains repositories. |
| `DescribeDomain` | Returns a domain's full description, including its repository count. |
| `ListDomains` | Lists domain summaries for the account and Region, paginated. |
| `PutDomainPermissionsPolicy` | Attaches or replaces a domain's resource policy, versioned by `policyRevision`. |
| `GetDomainPermissionsPolicy` | Returns a domain's current resource policy and revision. |
| `DeleteDomainPermissionsPolicy` | Removes a domain's resource policy, optionally checked against `policyRevision`. |
| `CreateRepository` | Creates a repository with optional description, upstreams (max 10), and tags. |
| `DeleteRepository` | Deletes a repository. |
| `DescribeRepository` | Returns a repository's full description, including upstreams and external connections. |
| `UpdateRepository` | Updates a repository's description and/or upstream list. |
| `ListRepositories` | Lists repository summaries across all domains, optionally filtered by name prefix. |
| `ListRepositoriesInDomain` | Lists repository summaries within one domain, optionally filtered by name prefix. |
| `GetRepositoryEndpoint` | Returns the package-format-specific endpoint URL for a repository. |
| `PutRepositoryPermissionsPolicy` | Attaches or replaces a repository's resource policy, versioned by `policyRevision`. |
| `GetRepositoryPermissionsPolicy` | Returns a repository's current resource policy and revision. |
| `DeleteRepositoryPermissionsPolicy` | Removes a repository's resource policy, optionally checked against `policyRevision`. |
| `AssociateExternalConnection` | Attaches a fixed-catalog public upstream (e.g. `public:npmjs`) to a repository; mutually exclusive with repository upstreams. |
| `DisassociateExternalConnection` | Removes a repository's external connection. |
| `TagResource` | Adds or updates tags on a domain or repository ARN. |
| `UntagResource` | Removes tags by key from a domain or repository ARN. |
| `ListTagsForResource` | Lists the tags on a domain or repository ARN. |
<!-- floci:actions:end -->
Domains and repositories are account and Region scoped and persisted through `StorageFactory`.
`DeleteDomain` fails with `ConflictException` while the domain still contains repositories, matching
AWS. `PutDomainPermissionsPolicy`/`PutRepositoryPermissionsPolicy` use the returned `policyRevision`
for optimistic locking on subsequent updates, also matching AWS.
`AssociateExternalConnection` accepts the same fixed set of AWS-hosted public upstreams
documented for real CodeArtifact (`public:npmjs`, `public:pypi`, `public:maven-central`, etc.) and
enforces the one-external-connection-per-repository limit AWS enforces. A repository can have
upstream repositories or an external connection, but not both, matching AWS; `CreateRepository`
and `UpdateRepository` also cap direct upstreams at 10, AWS's own repository limit.
## AWS-compatible failures
Domain and repository names, tags, pagination, duplicate names, missing upstreams, policy-revision
mismatches, and non-empty-domain deletes are validated. Floci returns `ValidationException`,
`ConflictException`, `ResourceNotFoundException`, and `ServiceQuotaExceededException` (tag limits)
for deterministic conditions represented by local state.
AWS also models `AccessDeniedException`, `InternalServerException`, and `ThrottlingException`.
Floci does not inject provider-side failures that cannot be derived from the request or emulator
state.
## Known limitations
- **Upstream cycles are not rejected.** `CreateRepository`/`UpdateRepository` reject a repository
naming itself as its own upstream and require each named upstream to already exist, but a longer
cycle (repository A has B as an upstream, B has A) is not detected.
- **`DeleteRepository` does not check whether other repositories still reference it as an
upstream.** Deleting a repository leaves any repository that named it as an upstream pointing at
one that no longer exists.
- **Cross-account `domainOwner` addressing has no authorization check.** Passing a `domainOwner`
that is not the caller's own account looks up that account's domain/repository with no
trust-policy or permissions-policy enforcement, consistent with Floci's IAM enforcement being
opt-in elsewhere, but worth knowing if you rely on domain-sharing semantics.
See the [CodeArtifact API Reference](https://docs.aws.amazon.com/codeartifact/latest/APIReference/Welcome.html).
## Configuration
| Variable | Default | Description |
|---|---|---|
| `FLOCI_SERVICES_CODEARTIFACT_ENABLED` | `true` | Enable or disable CodeArtifact |