terraform-provider-datadog icon indicating copy to clipboard operation
terraform-provider-datadog copied to clipboard

Clarify downtime start and end attributes

Open Apollorion opened this issue 3 years ago • 4 comments

Terraform Version

1.0.10

Affected Resource(s)

  • datadog_downtime

In the docs within both github and the terraform registry here, the start and end attributes as documented are a tad confusing.

The start attribute for example is documented as start (Number) Specify when this downtime should start. I assumed the value here is an epoch timestamp, but I dont know what timezone to use. I assume UTC, but the documented example appears to be EST.

According to the the example:

# Example: downtime for a specific monitor
# Create a new daily 1700-0900 Datadog downtime for a specific monitor id
resource "datadog_downtime" "foo" {
  scope      = ["*"]
  start      = 1483308000
  end        = 1483365600
...

Focusing on the start attribute purely (but this is also effecting the end attribute):

  • 1483308000 in UTC is Sunday January 01, 2017 22:00:00 (pm), which aligns with most conventions accounting for times in an API but not the example.
  • 1483308000 in EST is Sunday January 01, 2017 17:00:00 (pm) which is what the example says, but is outside convention.

So my questions here, is start/end expecting an epoch timestamp in UTC or EST? Should I provide 1483290000 which is 1700 UTC or 1483308000 which is 1700 EST?

Apollorion avatar Nov 12 '21 20:11 Apollorion

Looking further into this, only adds a bit more confusion. It looks like theres a timezone attribute that appears to default to UTC, but thats not being used in the example. So maybe the example is just wrong?

Apollorion avatar Nov 12 '21 20:11 Apollorion

Further than that, TF is really bad in handling timestamp in number (epoch) format. It'd be much more useful to be an RFC3339 string. Like start_date and end_date parameters are already.

ZsoltPath avatar May 03 '22 08:05 ZsoltPath

Yes, it's really not intuitive. Resorted to creating a downtime manually in the UI, and checking the browser console to see which values are correct.

orlandothoeny avatar Aug 05 '22 08:08 orlandothoeny

I create a downtime like this, it's not the best but it works:

resource "datadog_downtime" "downtime_cet_11pm-9am" {
  count     = var.enabled[terraform.workspace] ? 1 : 0
  scope      = ["*"]
  // downtime is named after start and end hour, if you change the hour, change the name!
  // this might not be compatible with daylight saving - during summer CET is UTC +2
  start_date = formatdate("YYYY-MM-DD'T'23:00:00+01:00",timestamp())
  // downtime is named after start and end hour, if you change the hour, change the name!
  end_date   = formatdate("YYYY-MM-DD'T'09:00:00+01:00",timeadd(timestamp(), "24h"))
  timezone   = "CET"
  message    = "Downtime for tags(just for documentation): ${join(", ",local.provisioned_tags)}"

  //we match monitors via this tag
  monitor_tags = ["downtime_cet_11pm-9am"]

  //we never update the dates as it would result in a change every day someone runs terraform apply
  lifecycle {
    ignore_changes = [
      start_date, end_date
    ]
  }

  recurrence {
    type   = "days"
    period = 1
  }
}

falkorichter avatar Dec 06 '22 11:12 falkorichter