Example architecture to use Terraform to manage Datadog.
- In
modules/
all the standard monitors available OOTB. - In
company/
a folder per environment and team.
To create a new project for your team:
- Create a new folder under the relevant environment folder (
prod/
ordev/
) - Create a folder with your team name
- Create a file
main.tf
to initiate the relevant providers - Initiate the main variables for you team in
variables.tf
- Initiate the variables to connect to the providers in
terraform.tfvars
- Create your monitors using the modules in
monitors_*.tf
files
- Create a
terraform.tvars
file:cp terraform.tvars.example terraform.tvars
- Run
terraform init
- Run
terraform plan
- Run
terraform apply
- Datadog documentation: Importing Datadog Resources into Terraform.
- Google Terraformer: Repo
A dashboard, monitor or any other resource is already available in Datadog and needs to be terraformed.
Example for a monitor:
- Create empty ressource:
resource "datadog_monitor" "MONITOR_NAME" {
# To fill
}
- terraform import datadog_monitor.MONITOR_NAME MONITOR_ID
- terraform state show 'datadog_monitor.MONITOR_NAME'
- get output and add it in the
# To fill
- remove the id param and other params not supported
- Terraform monitors from Claranet
- Want to translate a dashboard / monitor exported JSON to a terraform file, check this tool.