> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/reference/groundcover-terraform-provider.md).

# groundcover Terraform Provider

## Overview

Terraform is an infrastructure-as-code (IaC) tool for managing cloud and SaaS resources using declarative configuration. The groundcover Terraform provider enables you to manage observability resources such as policies, service accounts, API keys, and monitors as code—making them consistent, versioned, and automated.

We've partnered up with Hashicorp as an official Terraform provider- <https://registry.terraform.io/providers/groundcover-com/groundcover/latest>

Also available is our provider Github repository: <https://github.com/groundcover-com/terraform-provider-groundcover>

## Supported Resources

* **`groundcover_policy`** – Defines RBAC policies (roles and optional data scope filters) [Role-Based Access Control (RBAC)](/administer/role-based-access-control-rbac.md)
* **`groundcover_serviceaccount`** – Creates service accounts using attaches policies. [Service Accounts](/administer/service-accounts.md)
* **`groundcover_apikey`** – Creates API keys for service accounts. [API Keys](/administer/api-keys.md)
* **`groundcover_monitor`** – Defines alerting rules and monitors. [Monitors](/automate/monitors.md)
* **`groundcover_logspipeline`** - Defines Logs Pipeline configurations. [Logs Pipeline](/collect-data/data-pipelines/log-pipelines.md)
* **`groundcover_tracespipeline`** - Defines Traces Pipeline configurations. [Traces Pipeline](/collect-data/data-pipelines/traces-pipeline.md)
* **`groundcover_ingestionkey`** - Creates Ingestion keys. [Ingestion Keys](/collect-data/ingestion-keys.md)
* **`groundcover_dashboard`** - Define Dashboards. [Dashboards](/investigate/dashboards-and-alerts.md)
* **`groundcover_synthetic_test`** - Define Synthetics and their respective monitors. [Synthetics](/investigate/synthetics.md)
* **`groundcover_connected_app`** - Define [Destinations](/automate/connected-apps.md) (formerly called Connected Apps; the Terraform resource name is preserved for backward compatibility).
* **`groundcover_notification_route`** - Define Notification Routes. [Notification Routes](/automate/monitors/notification-routes.md)

## Installation and Setup

### Requirements

* [Terraform](https://www.terraform.io/downloads.html) ≥ 1.0 (Check `required_version` if specified in `main.tf`)
* [Go](https://golang.org/doc/install) >= 1.21 (to build the provider plugin)
* groundcover Account and API Key.

### Install the Provider

```
terraform {
  required_providers {
    groundcover = {
      source  = "registry.terraform.io/groundcover-com/groundcover"
      version = ">= 0.0.0" # Replace with actual version constraint
    }
  }
}
```

Run `terraform init` to install the provider.

### Configure the Provider

```
provider "groundcover" {
  api_key  = "YOUR_API_KEY" # Required
  base_url = "https://api.groundcover.com" # Optional, change if using onprem/airgap deployment
  backend_id = "groundcover" # Your Backend ID can be found in the groundcover UI under Settings->Access->API Keys
}
```

#### Arguments

* `api_key` (String, Required, Sensitive): Your groundcover API key. It is strongly recommended to configure this using the `TF_VAR_groundcover_api_key` environment variable rather than hardcoding it.
* `base_url` (String, Optional): The base URL for the groundcover API. Defaults to `https://api.groundcover.com` if not specified.
* `backend_id` (String, Required): Your Backend ID can be found in the API Keys screen in the groundcover UI (Under Settings -> Access):

<figure><img src="https://2771001740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUHgqKYgCiRKdOpWQdi52%2Fuploads%2Fgit-blob-37d952be9832c3118e1b37772570a3d44791f2cb%2FScreenshot%202025-08-18%20at%208.22.07.png?alt=media" alt=""><figcaption></figcaption></figure>

## Examples

For full examples of all existing resources, see: <https://github.com/groundcover-com/terraform-provider-groundcover/tree/main/examples/resources>

### Creating a Read-Only Service Account and API Key

```
resource "groundcover_policy" "read_only" {
  name        = "Read-Only Policy"
  description = "Grants read-only access"
  claim_role  = "ci-readonly-role"
  roles = {
    read = "read"
  }
}

resource "groundcover_serviceaccount" "ci_account" {
  name         = "ci-pipeline-account"
  description  = "Service account for CI"
  policy_uuids = [groundcover_policy.read_only.id]
}

resource "groundcover_apikey" "ci_key" {
  name               = "CI Key"
  description        = "Key for CI pipeline"
  service_account_id = groundcover_serviceaccount.ci_account.id
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groundcover.com/reference/groundcover-terraform-provider.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
