Open hughack opened 9 months ago
This would be compatible with both pip
and poetry
Thanks for the feature request. I'll share this with the CodeArtifact team, who owns and maintains this customization. In the meantime we can continue to track the request and gather feedback here.
Adding creds to .netrc would help to support Bazel access to CodeArtifact as well. Currently I have to roll my own credential helper to get access to pip packages in Codeartifact with the Bazel native downloader. However, Bazel already supports .netrc for credentials, and that would likely be less maintenance burden than developing a separate CodeArtifact Bazel login tool.
Describe the feature
Add the ability to have
aws codeartifact login --tool pip ...
write credentials to~/.netrc
. "Tool" could also benetrc
or something.Use Case
When using
requirements.txt
to define dependencies, I can't find a clean way to securely build a docker image with a private package repository in a way that is resilient by default against dependency confusion, and works across developer machines and builds.The problem with writing to
pip.conf
is it sets the index outside ofrequirements.txt
, which means someone can still runpip install -r requirements.txt
without logging in to codeartifact, and if there are name collisions with a package in pypi then they will be installed.We could add
--index-url https://aws:${CODEARTIFACT_TOKEN}@...
at the start ofrequirements.txt
but this falls apart when building in docker, since that means setting an env var which can easily be accidentally built in to the container.Proposed Solution
Add the ability to have
aws codeartifact login --tool pip ...
write credentials to~/.netrc
instead ofpip.conf
.This allows us to force
requirements.txt
to use our codeartifact repo like this:Since
pip
honours creds in~/.netrc
it will fail to install anything unless that file exists and has correct creds.Users and build tools can login using the cli.
Within a Dockerfile we can put:
And build using:
Other Information
Someones blog post: https://zapata.ai/building-a-python-docker-image-using-private-pypi-repository/
Acknowledgements
CLI version used
2.15.18
Environment details (OS name and version, etc.)
macos sonoma 14.0