Pulumi Datadog

5.1.0 · active · verified Mon Apr 13

The `pulumi-datadog` Python package provides a way to declare, deploy, and manage Datadog resources like monitors, dashboards, and integrations using Pulumi's Infrastructure as Code framework. It mirrors the upstream Datadog Terraform Provider and typically releases new versions in sync with updates to that provider. The library is actively maintained and currently at version 5.1.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure the `pulumi-datadog` provider and create a simple Datadog metric alert monitor. It assumes `DD_API_KEY` and `DD_APP_KEY` environment variables are set or configured as Pulumi secrets. The `apiUrl` configuration is important and must not end with `/api/`.

import pulumi
import pulumi_datadog as datadog
import os

# Configure Datadog API and APP keys using environment variables
# pulumi config set datadog:apiKey --secret $DD_API_KEY
# pulumi config set datadog:appKey --secret $DD_APP_KEY

# Or, set them directly as provider arguments (less secure for sensitive keys)
# provider = datadog.Provider(
#     "datadog-provider",
#     api_key=os.environ.get('DD_API_KEY', ''),
#     app_key=os.environ.get('DD_APP_KEY', ''),
#     api_url="https://api.datadoghq.com/" # Ensure no /api/ suffix
# )

# Create a Datadog monitor
example_monitor = datadog.Monitor("example-monitor",
    name="Pulumi Example Host CPU Alert",
    type="metric alert",
    query="avg(last_5m):system.cpu.idle{*} by {host} < 10",
    message="High CPU detected on {{host.name}}! @pagerduty",
    tags=["environment:dev", "team:sre"],
    priority=3,
    monitor_thresholds=datadog.MonitorMonitorThresholdsArgs(
        critical=10.0,
        warning=20.0,
    ),
    force_delete=True # Useful for development, be cautious in production
)

pulumi.export('monitor_id', example_monitor.id)
pulumi.export('monitor_name', example_monitor.name)

view raw JSON →