---
title: Terraform
description: Manage your Datadog account using Terraform
breadcrumbs: Docs > Integrations > Terraform
---

# Terraform
Supported OS Integration version1.0.0
## Overview{% #overview %}

The Datadog Terraform provider allows you to interact with the Datadog API through a Terraform configuration. You can manage your Datadog resources, such as Dashboards, Monitors, Logs Configuration, etc, with this configuration.

## Setup{% #setup %}

### Installation{% #installation %}

The Datadog Terraform provider is available through the [Terraform Registry](https://registry.terraform.io/providers/DataDog/datadog/latest/docs).

### Configuration{% #configuration %}

1. [Install Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli).

1. Create a directory to contain the Terraform configuration files, for example: `terraform_config/`.

1. Create a `main.tf` file in the `terraform_config/` directory with the following content:

   ```gdscript3
   terraform {
     required_providers {
       datadog = {
         source = "DataDog/datadog"
       }
     }
   }
   
   # Configure the Datadog provider
   provider "datadog" {
     api_key = var.datadog_api_key
     app_key = var.datadog_app_key
   }
   ```

**Note**: If you are not using the Datadog US1 site, you must set the `api_url` [optional parameter](https://registry.terraform.io/providers/DataDog/datadog/latest/docs#optional) with your [Datadog site](https://docs.datadoghq.com/getting_started/site/). Ensure the documentation site selector on the right of the page is set to your correct Datadog site, then use the following URL as the value of the `api_url` parameter:

   ```
   https://api.<YOUR_DATADOG_SITE>/
   ```

1. Run `terraform init`. This initializes the directory for use with Terraform and pulls the Datadog provider.

1. Create any `.tf` file in the `terraform_config/` directory and start creating Datadog resources.

## Create a monitor{% #create-a-monitor %}

This example demonstrates a `monitor.tf` file that creates a [live process monitor](https://docs.datadoghq.com/monitors/types/process/).

````
```
# monitor.tf
resource "datadog_monitor" "process_alert_example" {
  name    = "Process Alert Monitor"
  type    = "process alert"
  message = "Multiple Java processes running on example-tag"
  query   = "processes('java').over('example-tag').rollup('count').last('10m') > 1"
  monitor_thresholds {
    critical          = 1.0
    critical_recovery = 0.0
  }

  notify_no_data    = false
  renotify_interval = 60
}
```
````

Run `terraform apply` to create this monitor in your Datadog account.

## Send Events to Datadog{% #send-events-to-datadog %}

By installing `datadogpy`, you have access to the Dogwrap command line tool, which you can use to wrap any Terraform command and bind it to a custom event.

Install `datadogpy`:

```
pip install datadog
```

For more information, see the [Datadog Python library](https://github.com/DataDog/datadogpy).

Send a `terraform apply` event:

```
dogwrap -n "terraform apply" -k $DD_API_KEY --submit_mode all --tags="source:terraform" "terraform apply -no-color"
```

Send a `terraform destroy` event:

```
dogwrap -n "terraform destroy" -k $DD_API_KEY --submit_mode all --tags="source:terraform" "terraform destroy -no-color"
```

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

Terraform does not include any metrics.

### Service Checks{% #service-checks %}

Terraform does not include any service checks.

### Events{% #events %}

Terraform does not include any events.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).
