Problem
Unable to define connection on custom worker to Jfrog Artifactory repository from TFE instance
Prerequisites (if applicable)
- Working TFE instance
- Providers configured in Artifactory
Cause
Even after adding the below configuration, Terraform Enterprise (TFE) is still not considering the configuration due to a missing credential file.
The custom worker has been modified by adding hooks as follows:
ADD --chown=tfc-agent:tfc-agent hooks /home/tfc-agent/.tfc-agent/hooks
In the hooks directory, there are two files: terraform-pre-plan
and terraform-pre-apply
, both containing the same content:
#!/bin/bash cat >> /tmp/cli.tfrc <<EOF provider_installation { direct { exclude = ["registry.terraform.io/*/*"] } network_mirror { url =
"https://providers.tfe-example.com/artifactory/terraform-providers/"
/" } } EOF
Solutions:
Set up the "TF_CLI_CONFIG_FILE" environment variable in the custom agent to point to the credential file.
When using an alternative worker image with Terraform Cloud or Terraform Enterprise, the credential file must be located at /tmp/cli.tfrc
because that is the default path where the Terraform CLI searches for it.
To use a different location for the credential file, specify the desired path by setting the TF_CLI_CONFIG_FILE
environment variable. For instance, you can set TF_CLI_CONFIG_FILE
to /root/.terraformrc
if you want the credential file to be located at /root/.terraformrc
inside the container.
Additional Information
-
Please visit the provider installation page for further information of the Terraform configuration file.
- To configure a Terraform module/provider mirror in Jfrog Artifactory, please refer this page