Skip to main content

Module: platform

Terraform module to provision Datadog resources.

The module consists of the following submodules:

Notes on Datadog child organizations:

  • Users can be added to the parent-organization and/or multiple child-organizations and switch between them from the user account settings menu
  • The parent-organization can view the usage of individual child-organizations, allowing them to track trends in usage
  • The Multi-organization account feature is not enabled by default. Contact Datadog support to have it enabled
  • Free and Trial organizations cannot enable SAML
  • We can only create Datadog child organizations with terraform, but cannot destroy them. When trying to destroy, the following error is thrown:
      Warning: Cannot delete organization.

    Remove organization by contacting support (https://docs.datadoghq.com/help).

Introduction

Datadog resources (monitors, roles, etc.) are defined as catalog of YAML configuration files.

We maintain a comprehensive catalog of Datadog resources and welcome contributions via pull request!

The examples/complete in this module uses the catalog to provision the monitors on Datadog.

The examples/synthetics shows how to provision synthetic tests on Datadog for monitoring. Consult the synthetics README module for more details.

The examples/rbac shows how to use custom RBAC to provision Datadog roles with permissions and assign roles to monitors.

The examples/slo shows how to provision Service Level Objectives on Datadog for SLO monitoring.

The examples/child_organization shows how to provision Datadog child organizations.

The examples/organization_settings shows how to provision Datadog organization settings.

Usage

Provision Datadog monitors from the catalog of YAML definitions:

module "monitor_configs" {
source = "cloudposse/config/yaml"
version = "1.0.2"

map_config_local_base_path = path.module
map_config_paths = var.monitor_paths

context = module.this.context
}

module "datadog_monitors" {
source = "cloudposse/platform/datadog//modules/monitors"
# version = "x.x.x"

datadog_monitors = module.monitor_configs.map_configs
alert_tags = var.alert_tags
alert_tags_separator = var.alert_tags_separator

context = module.this.context
}

Provision Datadog synthetics:

locals {
synthetics_files = flatten([for p in var.synthetic_paths : fileset(path.module, p)])
synthetics_list = [for f in local.synthetics_files : yamldecode(file(f))]
synthetics_map = merge(local.synthetics_list...)
}

module "datadog_synthetics" {
source = "cloudposse/platform/datadog//modules/synthetics"
# version = "x.x.x"

datadog_synthetics = local.synthetics_map
alert_tags = var.alert_tags
alert_tags_separator = var.alert_tags_separator

context = module.this.context
}

Provision Datadog monitors, Datadog roles with defined permissions, and assign roles to monitors:

module "monitor_configs" {
source = "cloudposse/config/yaml"
version = "1.0.2"

map_config_local_base_path = path.module
map_config_paths = var.monitor_paths

context = module.this.context
}

module "role_configs" {
source = "cloudposse/config/yaml"
version = "1.0.2"

map_config_local_base_path = path.module
map_config_paths = var.role_paths

context = module.this.context
}

locals {
monitors_write_role_name = module.datadog_roles.datadog_roles["monitors-write"].name
monitors_downtime_role_name = module.datadog_roles.datadog_roles["monitors-downtime"].name

monitors_roles_map = {
aurora-replica-lag = [local.monitors_write_role_name, local.monitors_downtime_role_name]
ec2-failed-status-check = [local.monitors_write_role_name, local.monitors_downtime_role_name]
redshift-health-status = [local.monitors_downtime_role_name]
k8s-deployment-replica-pod-down = [local.monitors_write_role_name]
}
}

module "datadog_roles" {
source = "cloudposse/platform/datadog//modules/roles"
# version = "x.x.x"

datadog_roles = module.role_configs.map_configs

context = module.this.context
}

module "datadog_monitors" {
source = "cloudposse/platform/datadog//modules/monitors"
# version = "x.x.x"

datadog_monitors = module.monitor_configs.map_configs
alert_tags = var.alert_tags
alert_tags_separator = var.alert_tags_separator
restricted_roles_map = local.monitors_roles_map

context = module.this.context
}

Provision a Datadog child organization:

module "datadog_child_organization" {
source = "cloudposse/platform/datadog//modules/child_organization"
# version = "x.x.x"

organization_name = "test"
saml_enabled = false # Note that Free and Trial organizations cannot enable SAML
saml_autocreate_users_domains = []
saml_autocreate_users_enabled = false
saml_idp_initiated_login_enabled = true
saml_strict_mode_enabled = false
private_widget_share = false
saml_autocreate_access_role = "ro"

context = module.this.context
}

Examples

Review the examples folder to see how to use the Datadog modules.

Also checkout our terraform-aws-components repository for more examples of how to use a mixture of modules to enhance monitors, slos, and synthetics with inheritence and templating!