Hashicorp Terraform
HashiCorp Terraform is an infrastructure as code (IaC) platform that enables users to define, provision, and manage cloud and on-premises infrastructure through declarative configuration files. Terraform allows organizations to codify their infrastructure resources across multiple cloud providers and services including AWS, Azure, Google Cloud Platform (GCP), Oracle Cloud Infrastructure (OCI), VMware, Kubernetes, and hundreds of other providers through a unified workflow.
| Category | Infrastructure as code |
| Direction | Query source |
| Sign-in | API Token |
| Query languages | SQLite |
| Tables | 13 |
| Query templates | 34 |
| Website | hashicorp.com |
Before you start
Huntbase signs in to Hashicorp Terraform with API Token. Create the credential in Hashicorp Terraform first, then keep it to hand for the Connect step.
- In HCP Terraform or Terraform Enterprise, click your user icon and select Account settings.
- Click Tokens in the sidebar, then Create an API token.
- Enter a Description, choose an expiration, and click Create API token.
- Copy the token now. It is displayed only once.
- A user token has the permissions of its user. To avoid tying the connection to one person, create a team token under Organization Settings › API Tokens › Team Tokens: it can access the workspaces that team can access.
- All tokens expire. HashiCorp sends notifications 30 and 7 days before expiry.
For the vendor's own instructions, see HCP Terraform API token documentation.
Use a dedicated, read-only credential for Huntbase where the product allows it. Huntbase only needs to read.
Connect Hashicorp Terraform
- Go to Connections and click New connection, or click New connection on the Hashicorp Terraform product page.
- On Product, pick Hashicorp Terraform and choose the Owner.
- On Details, give the connection a Name and, optionally, a Description.
- On Connect, fill in the settings and credentials described below.
- On Verify, review the summary and click Create & check.
For everything else on the setup page — saving a draft, I'll do this later, and what each check result means — see Connections.
Settings
Where your Hashicorp Terraform lives:
| Field | Required | Notes |
|---|---|---|
| Organization | No | The name of the organization to query. |
| Hostname | No | Leave empty for HCP Terraform (app.terraform.io). For Terraform Enterprise, enter your instance hostname. |
Credentials
The only Method is API Token. Enter a Credential label (for example Production), then fill in:
| Field | Required | Notes |
|---|---|---|
| API Token | Yes | Secret — not shown again after you save it. |
Query it
Once connected, Hashicorp Terraform can serve these languages in a query tab, and Scout can use it when you ask in Auto:
| Language | Use it for |
|---|---|
| SQLite | SQL over the 13 tables listed below, alongside every other connected source. |
Example: SQLite
List all teams — Retrieve all teams present within your organization to understand the distribution of resources and tasks.
SELECT
*
FROM
tfe_team;
Hashicorp Terraform ships with 34 query templates. Find them in Library › Queries — see Query templates.
Tables
Hashicorp Terraform adds 13 tables. Browse their columns from Schema in the query bar's ⋯ menu.
All 13 tables
| Table | Contains |
|---|---|
tfe_current_user | User making the request. |
tfe_oauth_client | OAuth clients in the organization. |
tfe_organization | Organizations for the user. |
tfe_organization_member | List users who are members of the organization. |
tfe_project | Projects for the workspaces. |
tfe_run | Runs in the workspace. |
tfe_sentinel_policy | Sentinel Policy as Code is an embedded policy as code framework integrated with Terraform Enterprise. |
tfe_ssh_key | SSH keys in the organization. |
tfe_team | Teams in the organization. |
tfe_team_member | Team members in the organization. |
tfe_user_token | Tokens for the user. |
tfe_variable | Workspace variables for the user. |
tfe_workspace | Workspaces for the user. |
Next steps
- Connections — health, credentials and settings after you connect
- Query languages — syntax, parameters and time ranges
- Chatting with Scout — ask questions without writing a query
- All integrations — the rest of the catalog