How to Deploy Honeycomb Triggers/SLOs Across Multiple Environments Using Terraform

Last updated: October 14, 2025

Overview

When using Terraform to manage Honeycomb triggers/SLOs, you may want to deploy the same trigger/SLO configuration across multiple environments (e.g. production, staging, development). This article outlines the recommended approach for achieving this goal.

The Challenge

The Honeycomb Terraform provider doesn't have a direct method to specify target environments for triggers/SLOs. If you have multiple environments with the same dataset names (e.g. Prod|Stage|Dev each with a dataset checkout), you'll need a way to create the same trigger in each environment.

Solution: Provider Aliases with Environment-Specific API Keys

The recommended approach is to use Terraform provider aliases with separate API keys for each environment. Please note that the following examples are not fully complete and serve only as outlines of the approach we recommend.

Step 1: Set Up Environment Variables

Create prefixed environment variables for each environment's API key:

export TF_VAR_PROD_HONEYCOMB_API_KEY="your-prod-api-key"
export TF_VAR_STAGE_HONEYCOMB_API_KEY="your-stage-api-key"
export TF_VAR_DEV_HONEYCOMB_API_KEY="your-dev-api-key"

Step 2: Configure Provider Aliases

In the root of the Terraform configuration, define variables and provider aliases:

variable "PROD_HONEYCOMB_API_KEY" {}
variable "STAGE_HONEYCOMB_API_KEY" {}
variable "DEV_HONEYCOMB_API_KEY" {}

provider "honeycombio" {
  alias   = "prod"
  api_key = var.PROD_HONEYCOMB_API_KEY
}

provider "honeycombio" {
  alias   = "stage"
  api_key = var.STAGE_HONEYCOMB_API_KEY
}

provider "honeycombio" {
  alias   = "dev"
  api_key = var.DEV_HONEYCOMB_API_KEY
}

Step 3: Create Triggers for Each Environment

Use the provider aliases when creating triggers:

resource "honeycombio_trigger" "example_prod" {
  provider = honeycombio.prod
  
  name        = "Example Trigger"
  dataset     = "your-dataset-name"
  query_json  = jsonencode({
    # your trigger configuration
  })
  # other trigger settings
}

resource "honeycombio_trigger" "example_stage" {
  provider = honeycombio.stage
  
  name        = "Example Trigger"
  dataset     = "your-dataset-name"
  query_json  = jsonencode({
    # your trigger configuration
  })
  # other trigger settings
}

resource "honeycombio_trigger" "example_dev" {
  provider = honeycombio.dev
  
  name        = "Example Trigger"
  dataset     = "your-dataset-name"
  query_json  = jsonencode({
    # your trigger configuration
  })
  # other trigger settings
}

Alternative: Environment-Wide Triggers

For triggers that should apply to all datasets within an environment, you can simply omit the dataset field:

data "honeycombio_query_specification" "example" {
    calculation {
        op     = "AVG"
        column = "duration_ms"
    }
}

resource "honeycombio_trigger" "example" {
    name        = "Requests are slower than usual"
    description = "Average duration of all requests for the last 10 minutes."

    query_json = data.honeycombio_query_specification.example.json

    frequency = 600 // in seconds, 10 minutes

    threshold {
        op             = ">="
        value          = 1000
    }
}