Dependabot with AWS CodeArtifact

Viewed 180

I'm trying to use Dependabot with AWS CodeArtifact and I keep getting authentication issues.

Dependabot can't authenticate to a private package registry The following private package registry was used and caused the update to fail: ###-###.d.codeartifact..amazonaws.com/npm/private.

Logs:

proxy | 2022/06/29 16:52:05 [022] GET https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine proxy | 2022/06/29 16:52:06 [022] 401 https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine proxy | 2022/06/29 16:52:06 [024] GET https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine proxy | 2022/06/29 16:52:06 [024] 401 https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine updater | INFO <job_408163671> Handled error whilst updating hermes-engine: private_source_authentication_failure {:source=>"###-###.d.codeartifact.###.amazonaws.com/npm/private"}

I've tried playing with different dependabot.yml configs, such as full CodeArtifact URL with path or using token instead of username and password.

My dependabot.yml:

version: 2
registries:
  npm-codeartifact:
    type: npm-registry
    url: https://<registry>-<account>.d.codeartifact.<region>.amazonaws.com
    username: aws
    password: ${{secrets.CODEARTIFACT_TOKEN}}

  - package-ecosystem: "npm"
    schedule:
      interval: "daily"
    registries:
      - npm-codeartifact

What should I be using to make dependabot work with CodeArtifact?

1 Answers

If you are using tokens, you don't need to specify a username:

version: 2
registries:
  npm-codeartifact:
    type: npm-registry
    url: https://<registry>-<account>.d.codeartifact.<region>.amazonaws.com
    token: ${{secrets.CODEARTIFACT_TOKEN}}
updates:
  # Keep npm dependencies up to date
    - package-ecosystem: "npm"
      schedule:
        interval: "daily"
      registries:
      - npm-codeartifact
Related