Configure your OpenTofu Client

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

To configure OpenTofu client, follow these steps:

  1. Authenticate your client using the following command: Natively run the Terraform login to your Artifactory domain to generate an access token and save it in the Credentials file ( ~/.terraform.d/credentials.tfrc.json)

    tofu login [JFrogPlatformURL]
    

    [JFrogPlatformURL]: The URL of your JPD

    For example:

    tofu login company.jfrog.io
    
  2. Click Approve on the JFrog Platform login page.

    The command line shows the success message after obtaining and saving the token.

  3. To configure the Terraform CLI to work with Artifactory as a remote state storage and locking provider, configure it in the main HCL file (main.tf) as follows..

    terraform {
        backend "remote" {
            hostname = "[JFrogPlatformURL]"
            organization = "REPOSITORY-KEY"
            workspaces {
                prefix = "jfrog-"
            }
        }
    }
    

    Where:

    • backend: Set as Remote by definition

    • hostname: Your Artifactory domain name

    • [JFrogPlatformURL]: The URL of your JPD

    • organization: Backend Artifactory Repository name

    • <REPOSITORY-KEY>: Name of the repository

    • prefix: Allows users to add a user-defined prefix when working with multiple workspace under the same prefix

    For example:

    terraform {
        backend "remote" {
            hostname = "company.jfrog.io"
            organization = "terraform-local"
            workspaces {
                prefix = "jfrog-"
            }
        }
    }
    

Note

You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.

Next Steps: