AWS CodeArtifact Keyring Backend
The keyrings.codeartifact package provides authentication for publishing and consuming packages within a private
PyPi repository hosted on AWS CodeArtifact; it contains an extension to the
keyring library that will automatically inject a time-limited access token.
Installation
To install this package, install the "keyrings.codeartifact" package using pip:
pip install keyrings.codeartifact
Usage
The keyring library has been integrated with recent versions of pip and twine. Once installed, this library will
automatically supply credentials whenever pip/twine (or other keyring-enabled package) attempts to use a repository
hosted within CodeArtifact. It will use any appropriate AWS credentials provided in ~/.aws/credentials by default.
--index-url https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/pypi/${REPOSITORY}/simple/
Config
This backend provides a number of configuration options to modify the behaviour of the AWS client.
The configuration options can be specified within [codeartifact] sections of the keyringrc.cfg.
Run keyring diagnose to find its as the location; it varies between different platforms.
Available options:
profile_name: Use a specific AWS profile to authenticate with AWS.token_duration: Validity period (in seconds) for retieved authorization tokens.aws_access_key_id: Use a specific AWS access key to authenticate with AWS.aws_secret_access_key: Use a specific AWS secret access key to authenticate with AWS.
For more explanation of these options see the AWS CLI documentation.
Single Section Configuration
A trivial example keyringrc.cfg section for a single account:
[codeartifact]
# Tokens should only be valid for 30 minutes.
token_duration=1800
# Use the 'default' profile name.
profile_name=default
# Use the following access keys.
aws_access_key_id=xxxxxxxxx
aws_secret_access_key=xxxxxxxxx
Multiple Section Configuration (EXPERIMENTAL)
This backend can use multiple sections to select different configuration values.
Each section may also have any of the following "qualifiers" in any order:
domain: Matches on the repository domain.account: Matches on the repository account.region: Matches on the repository region.name: Matches on the repository name.
When looking up a CodeArtifact URL, each matching qualifier ranks that section higher.
The section with highest score (ie: the most specific match) will be selected for that URL.
When configured in this manner, the codeartifact section will specify default values.
An example of a more advanced configuration for using multiple sections:
# These are the defaults for other sections.
[codeartifact]
token_duration=1800
# Use for any repositories in account 000000000000.
[codeartifact account="000000000000"]
profile_name=special_profile
# Use for account 999999999999 with a repository named "staging".
[codeartifact account="999999999999" name="staging"]
profile_name=staging_profile
Development Environment
Use a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -e .[dev,test]
Release files for keyrings.codeartifact 2.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keyrings_codeartifact-2.1.2.tar.gz | 11.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keyrings_codeartifact-2.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / keyrings_codeartifact-2.1.2.tar.gz
| Download URL | keyrings_codeartifact-2.1.2.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac7b0082840216ee5445c786b5b6c599a455cb3a0dc02dd40fd4d50d0bcaac2e
|
|
BLAKE2b-256 checksum How to use checksums |
8d552941103eb3827f0952863ad847d76b467c5cd2c95ce7795d6cf22e9fa37c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2025.
Transparency logRelease files / keyrings_codeartifact-2.1.2-py3-none-any.whl
| Download URL | keyrings_codeartifact-2.1.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
068af85511de119bb8fde2d0bc142600239401a0824dfa298e25bdcb2286c7dc
|
|
BLAKE2b-256 checksum How to use checksums |
25e673e0796c24f2e605012f0313e8084d422918f68d80f01d17eae9f551de35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2025.
Transparency log