---
title: Honeybadger Terraform provider
description: Manage Honeybadger projects, uptime checks, check-ins, alarms, and integrations as code with the Honeybadger Terraform provider.
url: https://docs.honeybadger.io/tools/terraform/
---

The [Honeybadger Terraform provider](https://registry.terraform.io/providers/honeybadger-io/honeybadger/latest) lets you manage your Honeybadger configuration as code.

This guide gets you from zero to your first `terraform apply`. See the [provider docs on the Terraform Registry](https://registry.terraform.io/providers/honeybadger-io/honeybadger/latest/docs) for a full reference of the available resources and attributes.

## What can you manage?

| Area | Resources |
| - | - |
| Projects | `honeybadger_project`, `honeybadger_ingestion_key`, `honeybadger_environment` |
| Uptime and cron monitoring | `honeybadger_site`, `honeybadger_check_in` |
| Insights | `honeybadger_alarm`, `honeybadger_dashboard` |
| Access | `honeybadger_team` |
| Status pages | `honeybadger_status_page` |
| Integrations | `honeybadger_integration_<service>`, one resource per service |

There are 34 integration resources, including Slack, PagerDuty, GitHub, Jira, Linear, Microsoft Teams, Opsgenie, Discord, email, and webhooks. See the [Registry docs](https://registry.terraform.io/providers/honeybadger-io/honeybadger/latest/docs) for a full list.

## Create an API token

The provider calls [API v3](https://docs.honeybadger.io/api/v3/), so it needs an [API v3 token](https://docs.honeybadger.io/api/v3/authentication/). You can use two kinds of tokens:

* A **user API token** acts as you. Create one in your [user settings](https://docs.honeybadger.io/guides/user-settings/#api-tokens).
* An **account API token** acts as your account. Create one in your [account settings](https://docs.honeybadger.io/guides/accounts/#api-tokens). Use this for CI, so your Terraform runs don’t depend on one person’s access.

The token needs the read and write [scopes](https://docs.honeybadger.io/api/v3/authentication/#scopes) for each resource it manages. For example, check-ins need `checkins:read` and `checkins:write`. Creating a project also needs `projects:create`. The Registry docs include [a list of resources and their scopes](https://registry.terraform.io/providers/honeybadger-io/honeybadger/latest/docs#api-token-scopes).

EU region

If your account is in our [EU region](https://docs.honeybadger.io/resources/data-residency/), create the token in your EU account and point the provider at the EU region:

```sh
export HONEYBADGER_API_URL=https://eu-app.honeybadger.io
```

You can also set `api_url` in the provider block.

Export the token as `HONEYBADGER_API_TOKEN`. The provider reads it from the environment, which keeps it out of your repository:

```sh
export HONEYBADGER_API_TOKEN=hbu_your_token
```

## Write your first config

The provider works with Terraform 1.0 or later. This config creates a project, an ingestion key for your app to report with, a check-in for a nightly job, an uptime check, and an email integration that sends the alerts:

main.tf

```hcl
terraform {
  required_providers {
    honeybadger = {
      source  = "honeybadger-io/honeybadger"
      version = "~> 0.1"
    }
  }
}


provider "honeybadger" {
  # Reads HONEYBADGER_API_TOKEN from the environment.
}


resource "honeybadger_project" "app" {
  name     = "My App"
  language = "ruby"
}


# The key your app reports errors with.
resource "honeybadger_ingestion_key" "app" {
  project_id = honeybadger_project.app.id
  label      = "production"
}


# Alert when the nightly job doesn't report in.
resource "honeybadger_check_in" "nightly" {
  project_id    = honeybadger_project.app.id
  name          = "Nightly billing"
  report_period = "1 day"
  grace_period  = "10 minutes"
}


# Check the health endpoint from two continents.
resource "honeybadger_site" "api" {
  project_id = honeybadger_project.app.id
  url        = "https://api.example.com/health"
  locations  = ["Virginia", "Frankfurt"]
  match_type = "include"
  match      = "ok"
}


# Email alerts for errors, outages, and missed check-ins.
resource "honeybadger_integration_email" "alerts" {
  project_id = honeybadger_project.app.id
  config = {
    email = "alerts@example.com"
  }
}


output "ingestion_key" {
  value     = honeybadger_ingestion_key.app.key
  sensitive = true
}


output "check_in_url" {
  value = honeybadger_check_in.nightly.report_url
}
```

Then install the provider and apply the config:

```sh
terraform init
terraform apply
```

The outputs give you the values your app needs: the ingestion key (your project’s [API key](https://docs.honeybadger.io/guides/projects/#api-keys)) and the URL the nightly job calls to check in. Ingestion key values are marked sensitive, so an output that returns one needs `sensitive = true`. To read the key, run `terraform output -raw ingestion_key`.

You can also pass `honeybadger_ingestion_key.app.key` directly to another resource, such as a secret in your secrets manager, so nobody has to copy the key by hand.

See the provider’s GitHub repository for a [working example of every resource](https://github.com/honeybadger-io/terraform-provider-honeybadger/tree/main/examples/resources).

## Import your existing configuration

You don’t have to start from scratch. Every resource supports `terraform import`, so you can bring your existing Honeybadger resources into Terraform.

With Terraform 1.5 or later, add an `import` block for each object:

```hcl
import {
  to = honeybadger_project.app
  id = "Xk9mZp"
}


import {
  to = honeybadger_check_in.nightly
  id = "Xk9mZp/b4Ck9w"
}
```

Projects, teams, and status pages are imported by their ID. Everything else uses `<project_id>/<id>`. To find the IDs, list the objects with API v3. For example, [list your projects](https://docs.honeybadger.io/api/v3/projects/list-projects/) or [list a project’s check-ins](https://docs.honeybadger.io/api/v3/check-ins/list-check-ins/).

If you haven’t written the resource blocks yet, Terraform can write them for you:

```sh
terraform plan -generate-config-out=generated.tf
```

Honeybadger never returns integration credentials, so Terraform can’t read them during an import. Add them to your config, and the `terraform apply` that imports the resource sets them again.

## Additional resources

* [Provider docs on the Terraform Registry](https://registry.terraform.io/providers/honeybadger-io/honeybadger/latest/docs)
* [Terraform provider GitHub repository](https://github.com/honeybadger-io/terraform-provider-honeybadger)
* [API v3 authentication](https://docs.honeybadger.io/api/v3/authentication/)

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
