Introduction :
User publishing their private terraform modules in a cloud version of Artifactory . How can they authenticate the TFE workspace to Artifactory to resolve and download our private terraform modules
Expected Outcome :
Successfully authenticate the TFE workspace to Artifactory and TFE runs should fetch the private module source code from Artifactory . When a Terraform run is triggered in TFE, it will automatically retrieve the necessary module source code from Artifactory without requiring manual intervention. This ensures a smooth and efficient workflow .
Prerequisites :
-
Should have artifactory authentication token . you can follow below given link to generate the artifactory authentication token -
https://jfrog.com/help/r/jfrog-artifactory-documentation/generate-an-access-token-for-terraform?tocId=tR8lXeO2OmLkW06RPIY1IQ -
Terraform Configuration Files , Ensure you have the Terraform configuration files that reference the private modules stored in Artifactory.
-
Module Source Path , Update the source path in your Terraform configuration to point to the correct Artifactory URL where your modules are stored.
Procedure :
To authenticate Artifactory to TFE workspace , you can use a host-specific environment variable. Environment variable names should have the prefix TF_TOKEN_
added to the domain name, with periods encoded as underscores. For example, the value of a variable named TF_TOKEN_app_terraform_io
will be used as a bearer authorization token when the CLI makes service requests to the hostname app.terraform.io
.
Example - If your Artifactory hostname is examplecorp.jfrog.io
, you should use the environment variable TF_TOKEN_examplecorp_jfrog_io
and provide the authentication token.
Reference :