Skip to content

Unable to associate synthetic test with an SLO #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matt-canty-dragon opened this issue Mar 17, 2020 · 3 comments
Closed

Unable to associate synthetic test with an SLO #449

matt-canty-dragon opened this issue Mar 17, 2020 · 3 comments

Comments

@matt-canty-dragon
Copy link

matt-canty-dragon commented Mar 17, 2020

Terraform Version

v0.12.18

Affected Resource(s)

Please list the resources as a list, for example:

  • datadog_service_level_objective
  • datadog_synthetics_test

Terraform Configuration Files

resource "datadog_synthetics_test" "example" {
  type    = "api"
  subtype = "http"
  request = {
    method = "GET"
    url    = "https://github.com/status"
  }
  request_headers = {
    Content-Type = "application/json"
  }
  assertions = [
    {
      type     = "statusCode"
      operator = "is"
      target   = "200"
    },
    {
      type     = "body"
      operator = "contains"
      target   = "GitHub lives!"
    }
  ]
  locations = ["aws:ap-southeast-1"]
  options = {
    tick_every = 300
  }
  tags    = []
  name    = "Test"
  message = "Test"
  status  = "live"
}

resource "datadog_service_level_objective" "example" {
  name        = "Test SLO"
  type        = "monitor"
  description = "Testing SLO with Terraform."
  monitor_ids = [datadog_synthetics_test.example.id]

  thresholds {
    timeframe = "7d"
    target    = "99"
    warning   = "99.5"
  }
}

Debug Output

➜ terraform apply --auto-approve  
datadog_synthetics_test.example: Creating...
datadog_synthetics_test.example: Creation complete after 1s [id=nvr-sz3-gyy]

Error: Incorrect attribute value type

  on test.tf line 37, in resource "datadog_service_level_objective" "example":
  37:   monitor_ids = [datadog_synthetics_test.example.id]

Inappropriate value for attribute "monitor_ids": a number is required.

Expected Behavior

It should create an SLO with a synthetic test as one of the attributed monitors.

Actual Behavior

It fails because the SLO expects a list of numbers, but the synthetic test outputs it's ID as a string in the new format.

Steps to Reproduce

terraform apply --auto-approve

References

@nmuesch
Copy link
Contributor

nmuesch commented Mar 17, 2020

Hey @matt-canty-dragon Thanks for the issue report. The synthetics resource includes a monitor_id element that should be able to be used in the SLO resource - https://www.terraform.io/docs/providers/datadog/r/synthetics.html#monitor_id

Could you try referencing the monitor_id field and see if that addresses your use case?

@nmuesch nmuesch self-assigned this Mar 17, 2020
@matt-canty-dragon
Copy link
Author

Thanks. I did not realise this. + it is in the docs!

It is working as expected.

@nmuesch
Copy link
Contributor

nmuesch commented Mar 18, 2020

No problem, glad to hear things are working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants