Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: support for AWS profiles for ecr helper #771

Open
luke-flow opened this issue Feb 3, 2025 · 2 comments
Open

FR: support for AWS profiles for ecr helper #771

luke-flow opened this issue Feb 3, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@luke-flow
Copy link

Hello!

I have a usecase for rules_oci to pull from a private ECR repository. One option is to have all my users define AWS_PROFILE env var before running Bazel, but this is awkward for the following reasons:

  • Breaks the build for users that forget to set it.
  • Does not work for multiple ECR registries with different profiles.

This is because in addition to the credential_helper, rules_oci also reads the default Docker credential helper configuration in

content = """\
#!/usr/bin/env bash
exec "docker-credential-{}" get <<< "$1" """.format(helper_name),
)

I would like to discuss if there is a way to cleanly add support for this, I would be happy to contribute a PR if we can agree on what the interface should look like. Locally I am patching this with a very naive approach:

rules_oci_env_pull.patch for which I then set the profile in my pull:

oci.pull(
    auth_env = {
        "AWS_PROFILE": "my-super-secret-profile",
    },
)

Let me know what you think!

@thesayyn
Copy link
Collaborator

thesayyn commented Feb 5, 2025

It's an interesting addition, we already support Bazel wide profiles with --client_env=AWS_PROFILE= but i never thought of per oci_pull counterpart. PRs are welcome for addition like this.

@thesayyn thesayyn added the enhancement New feature or request label Feb 5, 2025
@plobsing
Copy link
Contributor

This is because in addition to the credential_helper, rules_oci also reads the default Docker credential helper configuration in

rules_oci/oci/private/authn.bzl

FYI, that behaviour can be suppressed by passing an empty JSON document as a Docker config


MODULE.bazel

oci.pull(
    # ...
    config = ":empty.json",
    # ...
)

empty.json

{}

The way I've done it, it does add one line per pull. I believe it could also be achieved repo-wide by adding --repo_env=DOCKER_CONFIG=some/dir/containing/empty_config to the repo's .bazelrc, but I don't have experience doing things that way yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants