TemplatesModules
Back to Modules
JFrog (Token) Icon

JFrog (Token)

By:
Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider.
README
Variables (11)
Scripts (1)
Source

Install the JF CLI and authenticate package managers with Artifactory using Artifactory terraform provider.

1module "jfrog" {
2  source                   = "registry.coder.com/modules/jfrog-token/coder"
3  version                  = "1.0.10"
4  agent_id                 = coder_agent.example.id
5  jfrog_url                = "https://XXXX.jfrog.io"
6  artifactory_access_token = var.artifactory_access_token
7  package_managers = {
8    "npm" : "npm",
9    "go" : "go",
10    "pypi" : "pypi"
11  }
12}

For detailed instructions, please see this guide on the Coder documentation.

Note This module does not install npm, go, pip, etc but only configure them. You need to handle the installation of these tools yourself.

JFrog

Examples

Configure npm, go, and pypi to use Artifactory local repositories

1module "jfrog" {
2  source                   = "registry.coder.com/modules/jfrog-token/coder"
3  version                  = "1.0.10"
4  agent_id                 = coder_agent.example.id
5  jfrog_url                = "https://YYYY.jfrog.io"
6  artifactory_access_token = var.artifactory_access_token # An admin access token
7  package_managers = {
8    "npm" : "npm-local",
9    "go" : "go-local",
10    "pypi" : "pypi-local"
11  }
12}

You should now be able to install packages from Artifactory using both the jf npm, jf go, jf pip and npm, go, pip commands.

1jf npm install prettier
2jf go get github.com/golang/example/hello
3jf pip install requests
1npm install prettier
2go get github.com/golang/example/hello
3pip install requests

Configure code-server with JFrog extension

The JFrog extension for VS Code allows you to interact with Artifactory from within the IDE.

1module "jfrog" {
2  source                   = "registry.coder.com/modules/jfrog-token/coder"
3  version                  = "1.0.10"
4  agent_id                 = coder_agent.example.id
5  jfrog_url                = "https://XXXX.jfrog.io"
6  artifactory_access_token = var.artifactory_access_token
7  configure_code_server    = true # Add JFrog extension configuration for code-server
8  package_managers = {
9    "npm" : "npm",
10    "go" : "go",
11    "pypi" : "pypi"
12  }
13}

Add a custom token description

1data "coder_workspace" "me" {}
2
3module "jfrog" {
4  source                   = "registry.coder.com/modules/jfrog-token/coder"
5  version                  = "1.0.10"
6  agent_id                 = coder_agent.example.id
7  jfrog_url                = "https://XXXX.jfrog.io"
8  artifactory_access_token = var.artifactory_access_token
9  token_description        = "Token for Coder workspace: ${data.coder_workspace.me.owner}/${data.coder_workspace.me.name}"
10  package_managers = {
11    "npm" : "npm",
12    "go" : "go",
13    "pypi" : "pypi"
14  }
15}

Using the access token in other terraform resources

JFrog Access token is also available as a terraform output. You can use it in other terraform resources. For example, you can use it to configure an Artifactory docker registry with the docker terraform provider.

1
2provider "docker" {
3  # ...
4  registry_auth {
5    address  = "https://YYYY.jfrog.io/artifactory/api/docker/REPO-KEY"
6    username = module.jfrog.username
7    password = module.jfrog.access_token
8  }
9}

Here REPO_KEY is the name of docker repository in Artifactory.