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
-
An active Hevo account. You can start with a 14-day full-feature, free trial account.
-
You are assigned the required role for the actions that you want to perform.
-
You have generated your API credentials. Read Authentication for the steps to generate them.
-
The machine or CI/CD runner that runs Terraform uses Terraform version 1.5 or higher.
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 initProvider 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.
| Argument | Environment variable | Description |
|---|---|---|
access_key (String) | HEVO_ACCESS_KEY | The access key of your API credentials. |
secret_key (String, Sensitive) | HEVO_SECRET_KEY | The secret key of your API credentials. |
host (String) | HEVO_HOST | The address at which you access your Hevo account, from the list of hosts. Default value: https://us.hevodata.com. |
skip_plan_time_validation (Boolean) | None | If 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 Region | Host |
|---|---|
| Asia | https://asia.hevodata.com |
| Australia | https://au.hevodata.com |
| Europe Central | https://eu.hevodata.com |
| Europe West | https://eu2.hevodata.com |
| India | https://in.hevodata.com |
| US East | https://us.hevodata.com |
| US West | https://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.