To configure Terraform client, follow these steps:
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)terraform login [JFrogPlatformURL][JFrogPlatformURL]: The URL of your JPDFor example:
terraform login company.jfrog.ioClick Approve on the JFrog Platform login page.
The command line shows the success message after obtaining and saving the token.
To configure the Terraform CLI to work with Artifactory as a remote state storage and locking provider, simply configure it in the main HCL file (
main.tf) as follows..terraform { backend "remote" { hostname = "[JFrogPlatformURL]" organization = "<REPOSITORY-KEY>" workspaces { prefix = "my-prefix-" } } }Where:
backend: Set as Remote by definitionhostname: Your Artifactory domain name[JFrogPlatformURL]: The URL of your JPDorganization: Backend Artifactory Repository name<REPOSITORY-KEY>: Name of the repositoryprefix: 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: