Skip to content
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

Silence config block not recognizing variable #159

Closed
masonbivens opened this issue Mar 5, 2019 · 1 comment
Closed

Silence config block not recognizing variable #159

masonbivens opened this issue Mar 5, 2019 · 1 comment

Comments

@masonbivens
Copy link

masonbivens commented Mar 5, 2019

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.10.8

Affected Resource(s)

Please list the resources as a list, for example:

  • datadog_monitor (silenced config block)

Terraform Configuration Files

resource "datadog_monitor" "lambda_throttled_invocations" {
  name = "[${upper(var.env)}] Lambda Throttled Invocations - {{functionname.name}}"
  type = "metric alert"

  query = "sum(last_30m):avg:aws.lambda.throttles{awsenv:${var.env}} by {functionname,product,team}.as_count() > 300"

  notify_no_data = false
  include_tags   = true
  locked         = true

  evaluation_delay = 900

  thresholds {
    warning           = 100
    warning_recovery  = 50
    critical          = 300
    critical_recovery = 200
  }

  message = <<EOM
${var.datadog_managed_by}

{{#is_alert}}Current Throttle Rate {{value}} has crossed the threshold {{threshold}}. Please investigate the issue{{/is_alert}}
{{#is_warning}}Current Throttle Rate {{value}} has crossed the warning threshold {{warn_threshold}}{{/is_warning}}
${var.datadog_alert_footer}
@slack-aws-alerts
EOM

  silenced {
    "functionname:app-report-generator-${var.env}" = 0
  }

  tags = ["service:lambda", "env:${var.env}", "managed_by:terraform"]
}

Expected Behavior

The silenced functionname should be rendered like "functionname:app-report-generator-dev" = 0

Actual Behavior

The silenced functionname is rendered as "functionname:app-report-generator-${var.env}" = 0

Important Factoids

We are currently generating environment isolated monitors. The variables are rendered everywhere else in the resource, but they don't appear to work in the silenced block.

@bkabrda
Copy link
Contributor

bkabrda commented Apr 10, 2019

The issue here is not with the datadog provider, but with HCL, which doesn't support interpolation in key values [1]. A workaround for this is using the map function, so you'd need to do something like silenced = ${map("functionname:app-report-generator-${var.env}", 0)}.

I'll see if there's a good place in the provider documentation where this could be added as a note.

[1] hashicorp/terraform#2042

nmuesch added a commit that referenced this issue Apr 17, 2019
Document HCL limitation of key interpolation. Fixes #159
jbenais pushed a commit to jbenais/terraform-provider-datadog that referenced this issue Aug 20, 2019
jbenais pushed a commit to jbenais/terraform-provider-datadog that referenced this issue Aug 20, 2019
Document HCL limitation of key interpolation. Fixes DataDog#159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants