首页 > 解决方案 > 如何在terraform中多行字符串

问题描述

我正在尝试以下示例

resource "google_logging_metric" "my_metric" { 
  description = "Check for logs of some cron job\t" 
  name        = "mycj-logs" 
  filter      = "resource.type=\"k8s_container\" AND resource.labels.cluster_name=\"${local.k8s_name}\" AND resource.labels.namespace_name=\"workable\" AND resource.labels.container_name=\"mycontainer-cronjob\" \nresource.labels.pod_name:\"my-pod\"" 
  project     = "${data.terraform_remote_state.gke_k8s_env.project_id}" 
 
  metric_descriptor { 
    metric_kind = "DELTA" 
    value_type  = "INT64" 
  } 
}

有没有办法使过滤器字段多行?

标签: terraform

解决方案


在 Google 中快速搜索会将您发送到文档:https ://www.terraform.io/docs/language/expressions/strings.html#heredoc-strings

你只需要写一些像

<<EOT
hello
world
EOT

推荐阅读