ARTIFACTORY: Configure an Opentofu registry with the Artifactory

AuthorFullName__c
Shisiya Sebastian
articleNumber
000006233
FirstPublishedDate
2024-11-11T09:51:01Z
lastModifiedDate
2025-07-22

ARTIFACTORY: Configure an Opentofu registry with the Artifactory

This article provides detailed, step-by-step instructions on how to configure an Opentofu registry with Artifactory. 
By following these steps, you can effectively manage and store providers and modules to be used with OpenTofu. Let’s get started!



Configuration

Step 1:  Create a Terraform remote repository (e.g., tofu-terraform) using the information provided below, and ensure that no other settings are changed.
URL : https://github.com/
Registry URL : https://registry.opentofu.org
Providers URL: https://github.com/


Step 2: In the Tofu client, update the configuration file at “~/.tofurc” with the Artifactory repository information.
provider_installation {
    direct {
        exclude = ["registry.opentofu.org/*/*"]
    }
    network_mirror {
        url = "https://ARTIFACTORY_HOST/artifactory/api/terraform/<repo_name>/providers/"
    }
}


NOTE: Replace ARTIFACTORY_HOST with your Artifactory hostname.


Step 3: Use any of the below methods to authenticate with the Terraform repository in the Artifactory.

  • Use web login:
 tofu login ARTIFACTORY_HOST
  • Manually add the access token (recommended for CLI tasks) to

~/.terraform.d/credentials.tfrc.json:

{
    "credentials": {
        "ARTIFACTORY_HOST": {
            "token": "*******REDACTED****"
            }
        }
    }

 

 

Validate the Configuration

  • Sample main.tf:
    terraform {
      required_providers {
     datadog = {
          source = "opentofu/datadog"
          version = "3.44.1"
        }
      }
    }
    
    module "terraform-cloud-operator" {
      source = "ARTIFACTORY_HOST/tofu-terraform__hashicorp/terraform-cloud-operator/kubernetes"
      version = "v0.0.2"
    }

 

  • Run tofu init:
Initializing the backend...
Initializing modules...
Downloading ARTIFACTORY_HOST/tofu-terraform__hashicorp/terraform-cloud-operator/kubernetes 0.0.2 for terraform-cloud-operator...
- terraform-cloud-operator in .terraform/modules/terraform-cloud-operator
Initializing provider plugins...
- Finding hashicorp/kubernetes versions matching ">= 2.4.0"...
- Finding opentofu/datadog versions matching "3.44.1"...
- Installing hashicorp/kubernetes v2.33.0...
- Installed hashicorp/kubernetes v2.33.0 (unauthenticated)
- Installing opentofu/datadog v3.44.1...
- Installed opentofu/datadog v3.44.1 (unauthenticated)
OpenTofu has been successfully initialized!

 

 

Reference
https://search.opentofu.org/
Artifactory Terraform registry