Terraform Backend Repository Structure
The Terraform Backend repository is a directory with a collection of workspaces consisting of these main coordinates;
- backend: Set as Remote by definition
- hostname: Your Artifactory domain name
- organization: Backend Artifactory Repository name
prefix: Allows users to add a user-defined prefix when working with multiple workspace under the same prefix.
Setting up a Local Terraform Backend Repository
Local repositories enable you to deploy Terraform Backend Zip files. Artifactory calculates the metadata for all file and indexes them to allow users to download these packages through the Terraform CLI.
- To create an Terraform Backend local repository, navigate to the Administration module.
- Navigate to Repositories | Repositories | Local | New Local Repository and select Terraform BE as the Package Type.
Setting Up Artifactory as the Remote State and Locking Provider
In Artifactory, you can set up the Terraform Backend repository as a remote state and locking provider.
To use Artifactory with your Terraform CLI, you will need to generate an access token.
- Generate an access token. For more information, see Generating an Access Token between Artifactory and the Terraform CLI.
- Navigate to Application Module | Artifactory | Artifacts.
- Select the desired repository.
- Select Set Me Up.
- Follow the instructions in the Configure tab.
Viewing Individual Terraform Workspace Information
Artifactory lets you view selected metadata of a Terraform Backend workspace directly from the UI.
In the Artifact Repository Browser, select your local Terraform Backend repository and scroll down to find and select the package you want to inspect.
The metadata is displayed in the Terraform Info tab, or viewed in the Packages view.
Viewing State and Lock Information and History
Artifactory automatically generates a state.json file when a workspace.json is deployed. The latest file is declared as the
state.latest.json and all previous states are renamed with a timestamp indicating the time they are were created, for example,
Artifactory provides information about the workspace deployment process.
In Artifactory, while performing Terraform configuration changes you will notice that the
locked.by property together with the name of the user performing the change is displayed in the Properties tab of the Workspace.