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

resource 'monitoring_alert_policy' field 'documentation'.'content' not support variable #11742

Closed
desireezhu opened this issue May 21, 2022 · 2 comments

Comments

@desireezhu
Copy link

desireezhu commented May 21, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform V1.2.0

Affected Resource(s)

  • google_monitoring_alert_policy

Terraform Configuration Files

resource "google_monitoring_alert_policy" "dlp_api_see_errors" {
  project      = PROJECT_NAME
  display_name = "API is seeing errors"
  combiner     = "OR"
  
  conditions {
    display_name = "API is seeing errors"

    condition_threshold {
      filter          = "metric.type=\"kubernetes.io/container/restart_count\" AND resource.type=\"k8s_container\" AND resource.label.\"namespace_name\"=\"test\""
      duration        = "60s"
      comparison      = "COMPARISON_GT"
      aggregations {
        alignment_period     = "60s"
        per_series_aligner   = "ALIGN_SUM"
        cross_series_reducer = "REDUCE_SUM"
      }

      trigger {
        count   = 1
      }
    }
  }

notification_channels = "${concat(google_monitoring_notification_channel.ndw_alerting_email.*.id, google_monitoring_notification_channel.ndw_alerting_phone.*.id)}"

  documentation {
    mime_type = "text/markdown"
    content   = "Pod: \"${resource.label.pod_name}\" Container: \"${resource.label.container_name}\""
  }
}

Debug Output

Error: Variables not allowed
  on .... line 81:

  81:   "Pod: \"${resource.label.pod_name}\" Container: \"${resource.label.container_name}\""

Variables may not be used here.

Panic Output

Expected Behavior

  documentation {
    mime_type = "text/markdown"
    content   = "Pod: \"${resource.label.pod_name}\" Container: \"${resource.label.container_name}\""
  }

Variables should be supported in the Documentation field for GCP monitoring_alert_policy as describe https://cloud.google.com/monitoring/alerts/doc-variables.

Actual Behavior

It reports 'Error: Variables not allowed' if variable is put in documentation content filed in terraform

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • b/275110306
@melinath
Copy link
Collaborator

This is a Terraform syntax error. One possible issue is that the cloud alerting variable syntax is the same as the Terraform interpolation syntax - you need to escape with $${.

See hashicorp/terraform#24391 for other potential causes.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants