Fact
From Artifactory version 7.38.4 and above JFrog provides a fully-fledged Terraform repository solution giving you full control of your deployment and resolution process of Terraform Modules, Providers and Backend packages.
Prerequisites
Artifactory supports Terraform CLI version 1.0.0 and above. So install Terraform CLI.
Problem statement
While configuring Terraform CLI with Artifactory the request will be routed to JFrog platform browser page to Authorise Terraform CLI to access Artifactory. The screenshot is as below:
Steps to Manually Configure Terraform CLI with Artifactory
-
So install Terraform CLI from Terraform CLI -
Create dedicated Module and Provider registries. -
Create a Terraform Backend Repository in Artifactory. -
Generate an Access Token between Artifactory and the Terraform CLI
Navigate to JFrog_Platform_UI | Admin | User Management | Generate Token |
5. Create a “credentials.tfrc.json” under “~/.terraform.d/” path. The file path should be as below:
~/.terraform.d/credentials.tfrc.json
6. Update your Access Token generated in the previous step in the “credentials.tfrc.json” file and initialize via the command “terrafram init”
Example format below:
#cat ~/.terraform.d/credentials.tfrc.json
{
"credentials": {
"servername.jfrog.io": {"token": "ACCESS TOKEN" }
}
}
Note
If you are using Access Token in “credentials.tfrc.json” you don’t have to login again (terraform login servername.jfrog.io [not required] )