Skip to main content

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.

CategoryInfrastructure as code
DirectionQuery source
Sign-inAPI Token
Query languagesSQLite
Tables13
Query templates34
Websitehashicorp.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.

  1. In HCP Terraform or Terraform Enterprise, click your user icon and select Account settings.
  2. Click Tokens in the sidebar, then Create an API token.
  3. Enter a Description, choose an expiration, and click Create API token.
  4. Copy the token now. It is displayed only once.
Watch out for
  • 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.

tip

Use a dedicated, read-only credential for Huntbase where the product allows it. Huntbase only needs to read.

Connect Hashicorp Terraform​

  1. Go to Connections and click New connection, or click New connection on the Hashicorp Terraform product page.
  2. On Product, pick Hashicorp Terraform and choose the Owner.
  3. On Details, give the connection a Name and, optionally, a Description.
  4. On Connect, fill in the settings and credentials described below.
  5. 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:

FieldRequiredNotes
OrganizationNoThe name of the organization to query.
HostnameNoLeave 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:

FieldRequiredNotes
API TokenYesSecret — 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:

LanguageUse it for
SQLiteSQL 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
TableContains
tfe_current_userUser making the request.
tfe_oauth_clientOAuth clients in the organization.
tfe_organizationOrganizations for the user.
tfe_organization_memberList users who are members of the organization.
tfe_projectProjects for the workspaces.
tfe_runRuns in the workspace.
tfe_sentinel_policySentinel Policy as Code is an embedded policy as code framework integrated with Terraform Enterprise.
tfe_ssh_keySSH keys in the organization.
tfe_teamTeams in the organization.
tfe_team_memberTeam members in the organization.
tfe_user_tokenTokens for the user.
tfe_variableWorkspace variables for the user.
tfe_workspaceWorkspaces for the user.

Next steps​