Skip to content

SLO tags with uppercase letters cause duplicate planned tags #3638

@nguyenanhducs

Description

@nguyenanhducs

Datadog Terraform Provider Version

v4.3.0

Terraform Version

v1.14.7

What resources or data sources are affected?

datadog_service_level_objective

Terraform Configuration Files

terraform {
  required_providers {
    datadog = {
      source  = "DataDog/datadog"
      version = "4.3.0"
    }
  }
}

provider "datadog" {}

resource "datadog_service_level_objective" "bar" {
  name        = "Example Metric SLO"
  type        = "metric"
  description = "My custom metric SLO"
  query {
    numerator   = "sum:my.custom.count.metric{type:good_events}.as_count()"
    denominator = "sum:my.custom.count.metric{*}.as_count()"
  }

  thresholds {
    timeframe = "7d"
    target    = 99.9
    warning   = 99.99
  }

  thresholds {
    timeframe = "30d"
    target    = 99.9
    warning   = 99.99
  }

  timeframe         = "30d"
  target_threshold  = 99.9
  warning_threshold = 99.99

  tags = [
    "foo:bar",
    "baz",
    "env:prod",
    "team:platform",
    "Service:API",
    "Owner:devops",
    "CostCenter:engineering",
    "Application:monitor",
    "Region:us-east-1",
    "Environment:production",
    "Project:slo",
    "Tier:critical",
    "Datacenter:aws",
    "Compliance:soc2",
    "Version:v1.0",
    "ManagedBy:terraform",
    "Department:infrastructure",
    "Stage:prod",
    "Backup:daily"
  ]
}

Relevant debug or panic output

No response

Expected Behavior

Tag comparison for datadog_service_level_objective.tags should be case-insensitive and consistent with Datadog's normalization behavior.

If Datadog normalizes tags to lowercase, the provider should not treat mixed-case and lowercase variants as different set elements, and a second terraform apply with no configuration changes should be a no-op.

Actual Behavior

The provider sends both mixed-case and lowercase variants of each mixed-case tag in a single API request:

  • 15 mixed-case tags get sent as both mixed-case AND normalized-to-lowercase = 30 tag instances
  • 3 lowercase tags sent once = 3 tag instances
  • Total = 33 tags sent in one request

The Datadog API rejects this with:

Error: error creating service level objective: 400 Bad Request: {"errors":["Invalid payload: Maximum number of elements in parameter 'tags' should be 32"]}

Debug info

[DEBUG] provider.terraform-provider-datadog_v4.3.0: {
    "description": "My custom metric SLO",
    "id": "4963fe390f0254e6aed704a3dc7a097d",
    "name": "Example Metric SLO",
    "query": {
        "denominator": "sum:my.custom.count.metric{*}.as_count()",
        "numerator": "sum:my.custom.count.metric{type:good_events}.as_count()"
    },
    "tags": [
        "department:infrastructure",
        "Version:v1.0",
        "ManagedBy:terraform",
        "tier:critical",
        "Application:monitor",
        "Stage:prod",
        "backup:daily",
        "application:monitor",
        "owner:devops",
        "region:us-east-1",
        "foo:bar",
        "Environment:production",
        "environment:production",
        "service:api",
        "Region:us-east-1",
        "Service:API",
        "Tier:critical",
        "datacenter:aws",
        "baz",
        "Department:infrastructure",
        "costcenter:engineering",
        "env:prod",
        "stage:prod",
        "managedby:terraform",
        "Backup:daily",
        "Owner:devops",
        "team:platform",
        "CostCenter:engineering",
        "version:v1.0",
        "Datacenter:aws",
        "project:slo",
        "compliance:soc2",
        "Compliance:soc2",
        "Project:slo"
    ],
    "target_threshold": 99.9,
    "thresholds": [
        {
            "target": 99.9,
            "timeframe": "7d",
            "warning": 99.99
        },
        {
            "target": 99.9,
            "timeframe": "30d",
            "warning": 99.99
        }
    ],
    "timeframe": "30d",
    "type": "metric",
    "warning_threshold": 99.99
}

Steps to Reproduce

  1. Define a SLO with mixed-case tags (15 mixed-case + 3 lowercase = 18 tags).
  2. Run terraform apply

Important Factoids

The SLO API silently normalizes all tags to lowercase, while other Datadog APIs do not, e.g., datadog_monitor

References

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions