4

npm provides a great way of associating a scope with a registry but I don't really see it working with AWS CodeArtifact.

I expect that once you created a domain @myco and a couple of repositories under that domain, ex: @myco/repo-a & @myco/repo-b I would be able to:

npm config set @myco:registry https://888999.d.codeartifact.eu-central-1.amazonaws.com/npm/

npm config set //888999.d.codeartifact.eu-central-1.amazonaws.com/npm/:_authToken=xxx

and all repositories could be installed with the same authToken, but aws codeartifact login expects repository which makes me think that it's not possible to install 2 private repos using one token.

Any ideas?

D.Dimitrioglo
  • 3,413
  • 2
  • 21
  • 41

1 Answers1

2

The root of my confusion was an assumption that AWS CodeArtifact has the following hierarchy:

  • Domains - I've interpreted that as a namespace
    • Repositories - I've interpreted that as list of npm packages

In fact, it's slightly different:

  • Domains - is a namespace/domain
    • Repositories - list of different repositories/registries
      • Where we can push lots of npm packages

As result generated token works as expected if we configure global .npmrc like this:

registry=https://registry.npmjs.com/
@myco:registry=https://xxx.d.codeartifact.region.amazonaws.com/npm/registry/
//xxx.d.codeartifact.region.amazonaws.com/npm/registry/:always-auth=true
//xxx.d.codeartifact.region.amazonaws.com/npm/registry/:_authToken=${CODEARTIFACT_AUTH_TOKEN}

That works for both default npm registry and your own.

D.Dimitrioglo
  • 3,413
  • 2
  • 21
  • 41