Manually Generate an Access Token for Terraform

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

To use Artifactory with your Terraform/OpenTofu CLI, you will need to generate an access token either manually or automatically:

The token will enable you to resolve Terraform modules and provide packages using the Terraform Registry, as well as set up Artifactory as the remote state and locking provider using the Terraform Backend repository.

  1. Generate an identity token that you can use to connect Artifactory to the Terraform CLI. For more details, please refer to User Profile - Identity Token.User Profile

  2. Create a file named 'credentials.tfrc.json' in your Terraform directory, ('~/.terraform.d/credentials.tfrc.json ').

  3. Update the token you generated in the credentials.tfrc.json file, as in the example below:

    #cat ~/.terraform.d/credentials.tfrc.json
     
    {
        "credentials": {
            "": {
                "token": "ACCESS-TOKEN"
                }
            }
        }
    

    For Example:

    #cat ~/.terraform.d/credentials.tfrc.json
     
    {
      "credentials": {
        "": {
          "token": "eyJ2ZXIy7tjWlgQUmSfjzCTzHz6TZPWycMNc17XbrPkvy91YF9nLYvwRnok25Uw"
        }
      }
    }
    

Note

If you have added the access token in credentials.tfrc.json, you do not need to log in again using Terraform login .