To use Artifactory with your Terraform/OpenTofu CLI, you will need to generate an access token either manually or automatically:
The token will enable you to resolve Terraform modules and provide packages using the Terraform Registry, as well as set up Artifactory as the remote state and locking provider using the Terraform Backend repository.
Generate an identity token that you can use to connect Artifactory to the Terraform CLI. For more details, please refer to User Profile - Identity Token.
Create a file named '
credentials.tfrc.json' in your Terraform directory, ('~/.terraform.d/credentials.tfrc.json').Update the token you generated in the
credentials.tfrc.jsonfile, as in the example below:#cat ~/.terraform.d/credentials.tfrc.json { "credentials": { "": { "token": "ACCESS-TOKEN" } } }For Example:
#cat ~/.terraform.d/credentials.tfrc.json { "credentials": { "": { "token": "eyJ2ZXIy7tjWlgQUmSfjzCTzHz6TZPWycMNc17XbrPkvy91YF9nLYvwRnok25Uw" } } }
Note
If you have added the access token in credentials.tfrc.json, you do not need to log in again using Terraform login .