Deploy/Resolve Terraform module artifact to Artifactory:

ARTIFACTORY: How to configure Terraform repositories in Artifactory

AuthorFullName__c
Tatarao Vana, Logeshwaran R
articleNumber
000005478
ft:sourceType
Salesforce
FirstPublishedDate
2022-11-30T08:56:48Z
lastModifiedDate
2024-04-10T17:38:53Z
VersionNumber
4
We can follow the below steps to deploy modules to Artifactory:
1. Create a new Terraform module by adding your contents to the tf file. Below is a sample of a new directory followed by
a “terraform init” command. 
cat main.tf
terraform {
 required_version = ">= 0.12.26"
}
output "hello_world" {
 value = "Hello, World!"
}

2. Navigate to the newly created directory and perform the following command to pack its contents into a zip file and name it according to the module version:
zip -r 1.0.0.zip .
adding: main.tf (deflated 9%)

3. Deploy the module using the cURL command found on the “Set Me Up” page as seen below.

Please note that my virtual repository name is test-terraform which consists of the local repository test-terraform-modules-local.
curl -utestuser:testpassword -XPUT "https://jpd.local/artifactory/test-terraform/myns/mymodule/myprovider/1.0.0.zip" -T 1.0.0.zip 
{
  "repo" : "test-terraform-modules-local",
  "path" : "/myns/mymodule/myprovider/1.0.0.zip",
  "created" : "2022-09-29T07:06:57.015Z",
  "createdBy" : "testuser",
  "downloadUri" : "https://jpd.local/artifactory/test-terraform-modules-local/myns/mymodule/myprovider/1.0.0.zip",
  "mimeType" : "application/zip",
  "size" : "253",
  "checksums" : {
    "sha1" : "a1f8d4026ddad3026278b072b3d476e4b50bf5de",
    "md5" : "5f7fb91cd0849148a15ebffe48958dcf",
    "sha256" : "a2bc2961618ab39dc18a559e7dccf58f2b83ebc70446dcdd5cc7dcc0f9f2f9a5"
  },
  "originalChecksums" : {
    "sha256" : "a2bc2961618ab39dc18a559e7dccf58f2b83ebc70446dcdd5cc7dcc0f9f2f9a5"
  },
  "uri" : "https://jpd.local/artifactory/test-terraform-modules-local/myns/mymodule/myprovider/1.0.0.zip"
}

4. In other Terraform projects (client machine for example), consume the published module using the following snippet:
cat main.tf 
module "mymodule" {
    source  = "jpd.local/test-terraform__myns/mymodule/myprovider"
}

5. Execute Terraform login command.
terraform login jfrog.local

6. Execute the Terraform init command to resolve it.
terraform init
Initializing modules...
Downloading jpd.local/test-terraform__myns/mymodule/myprovider 1.0.0 for mymodule...
- mymodule in .terraform/modules/mymodule
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!