Introduction
Terraform Explorer is a feature available in Terraform Enterprise (TFE) v1.0.x and later that allows administrators and users to query Terraform state data across workspaces and resources. Explorer indexes Terraform state into a dedicated PostgreSQL database and provides an efficient query interface.
This guide provides the steps to enable Terraform Explorer in a Docker Compose–based TFE deployment.
Prerequisites
Before you begin, ensure you meet the following requirements:
- You are running Terraform Enterprise v1.0.x or a later version.
-
Your Terraform Enterprise deployment meets one of the following supported configurations:
- External Services
- Active-Active
Note: The Mounted Disk deployment mode is not supported.
- You have provisioned a separate PostgreSQL database that Explorer can use to index Terraform state. This can be a self-hosted instance or a managed service like AWS RDS.
- You have network access between the Terraform Enterprise nodes and the PostgreSQL host.
- You have the necessary permissions to edit the TFE deployment configuration (
compose.yaml) and restart the application.
Procedure
Follow these steps to configure and enable Terraform Explorer.
Step 1: Create the Explorer Database
Terraform Explorer requires a dedicated database. You have two options for creating it.
Option 1: Create a new PostgreSQL instance
This approach isolates Explorer indexing from the primary Terraform Enterprise database, which is the recommended configuration for performance and stability.
Option 2: Create a new database on an existing instance
Alternatively, you can create a new database on an existing PostgreSQL instance. Create the database with the following command.
CREATE DATABASE tfe_explorer;
After creating the database, ensure the database user has the appropriate privileges.
GRANT ALL PRIVILEGES ON DATABASE tfe_explorer TO postgres;
Step 2: Configure Terraform Enterprise
Edit the compose.yaml file for your TFE Docker deployment. Add the following environment variables under the terraform-enterprise service to configure the connection to the Explorer database.
environment: # ... existing variables # Enable Terraform Explorer TFE_EXPLORER_DATABASE_HOST: "example.ap-south-1.rds.amazonaws.com" TFE_EXPLORER_DATABASE_NAME: "tfe_explorer" TFE_EXPLORER_DATABASE_USER: "postgres" TFE_EXPLORER_DATABASE_PASSWORD: "<password>" TFE_EXPLORER_DATABASE_PARAMETERS: "sslmode=require"
Step 3: Restart Terraform Enterprise
Apply the configuration changes by restarting the Terraform Enterprise application. Run the following commands from the directory containing your compose.yaml file.
$ docker compose down $ docker compose up -d
During startup, Terraform Enterprise automatically connects to the Explorer database, initializes the schema, and begins indexing workspace state data.
Verification
Once Terraform Enterprise is back online, you can validate that Terraform Explorer is working correctly.
- Log in to the Terraform Enterprise UI.
- Locate Explorer in the left navigation panel.
- Run a sample query to search for resources. You can filter by workspace, provider, resource type, or module.
If state indexing is complete, results will appear in the Explorer UI.
Additional Information
- For more details on this feature, refer to the official documentation on enabling Terraform Explorer.