Configuring the Hevo Terraform Provider

Terraform connects to your Hevo account through the Hevo provider. To use the provider, add the following blocks to your configuration:

  • required_providers: Specifies the Hevo provider and the provider versions that Terraform can download.

  • provider "hevo": Specifies the host of your Hevo account and the API credentials that the provider uses to connect to it.

You can provide the host and the credentials through environment variables instead of the provider block, so that you do not need to write your credentials in your configuration files. If you manage more than one Hevo account, such as a test account and a production account, you can add a provider block for each account.

Prerequisites

Declaring the Provider

Terraform downloads each provider that your configuration uses from a registry. To find the Hevo provider, Terraform needs its source address, hevoio/hevo, which you specify in the required_providers block. The provider "hevo" block then holds the settings of the provider, such as the host of your Hevo account.

Add both blocks to your configuration:

terraform {
  required_providers {
    hevo = {
      source  = "hevoio/hevo"
      version = "~> 1.0"
    }
  }
}

provider "hevo" {
  host = "https://us.hevodata.com"
}

The version argument sets the versions of the provider that Terraform can install. With ~> 1.0, Terraform installs version 1.0 or a higher 1.x version, such as 1.1, but not version 2.0. After you add both blocks, run the terraform init command to download the provider:

terraform init

Provider Arguments

All the arguments of the provider block are optional. If you do not specify an argument, the provider uses the value of its environment variable.

ArgumentEnvironment variableDescription
access_key (String)HEVO_ACCESS_KEYThe access key of your API credentials.
secret_key (String, Sensitive)HEVO_SECRET_KEYThe secret key of your API credentials.
host (String)HEVO_HOSTThe address at which you access your Hevo account, from the list of hosts. Default value: https://us.hevodata.com.
skip_plan_time_validation (Boolean)NoneIf set to true, the provider does not check your Destination and Source configurations against the connector's settings, or the names of the objects in hevo_pipeline_objects, when you run the terraform plan command. Errors in the configuration are then reported only when you run the terraform apply command. Default value: false.

If you specify an argument in the provider block, the provider uses it and ignores its environment variable.

Specifying your Host

For teams created before Release 2.00, your API credentials are valid only on the host of the region in which you generated them. When you generate your API credentials, the API Key window shows the host in the API Host field.

Set the host argument, or the HEVO_HOST environment variable, to one of the following values:

Hevo Account RegionHost
Asiahttps://asia.hevodata.com
Australiahttps://au.hevodata.com
Europe Centralhttps://eu.hevodata.com
Europe Westhttps://eu2.hevodata.com
Indiahttps://in.hevodata.com
US Easthttps://us.hevodata.com
US Westhttps://us2.hevodata.com

Note: Specify the host as a URL that starts with https://.

If your API credentials are not valid on the host that the provider uses, every request fails with an authentication error. An incorrect access key or secret key also causes this error, so if you see it, check that your host is correct before you check your keys.

Providing your API Credentials

Provide your access key and secret key through environment variables or Terraform variables, instead of writing them in your configuration files. Configuration files are often committed to version control, where anyone with access to the repository can read them. Use one of the following methods.

Using the Provider Environment Variables

Set the provider environment variables in the shell where you run Terraform:

export HEVO_ACCESS_KEY="<your access key>"
export HEVO_SECRET_KEY="<your secret key>"
export HEVO_HOST="https://us.hevodata.com"

With these variables set, the provider block does not need any arguments:

provider "hevo" {}

Using Terraform Variables

Use Terraform variables when you need different keys for different provider blocks, or when your Continuous Integration and Continuous Delivery (CI/CD) system, such as HashiCorp Cloud Platform (HCP) Terraform, stores the keys as Terraform variables. Declare the keys as sensitive variables and pass them to the provider block:

variable "hevo_access_key" {
  type      = string
  sensitive = true
}

variable "hevo_secret_key" {
  type      = string
  sensitive = true
}

provider "hevo" {
  access_key = var.hevo_access_key
  secret_key = var.hevo_secret_key
  host       = "https://us.hevodata.com"
}

Set the values in TF_VAR_ environment variables:

export TF_VAR_hevo_access_key="<your access key>"
export TF_VAR_hevo_secret_key="<your secret key>"

If you do not provide an access key or a secret key, Terraform displays an error when you run the terraform plan command.

Managing More Than One Hevo Account

Your API credentials belong to one Hevo account on one host. To manage resources in more than one account from the same configuration, declare a provider block for each, with an alias:

provider "hevo" {
  alias = "us"
  host  = "https://us.hevodata.com"
}

provider "hevo" {
  alias      = "eu"
  host       = "https://eu.hevodata.com"
  access_key = var.hevo_eu_access_key
  secret_key = var.hevo_eu_secret_key
}

resource "hevo_destination" "eu_snowflake" {
  provider = hevo.eu
  # ...
}

The us provider block in the example has no keys, so it reads them from the HEVO_ACCESS_KEY and HEVO_SECRET_KEY environment variables. The eu block reads its keys from Terraform variables.

A resource or data source that does not specify provider uses the provider block without an alias. If no such block exists, Terraform uses a provider with no arguments, which reads the credentials and the host from the HEVO_ environment variables. To avoid creating a resource in the wrong account, specify provider in each resource when you use more than one provider block.