title: How to use format function inside google_logging_metric resource
body: <p>My requirement is to variabilise cluster_name and namespace, and use in google_logging_metric resource</p>
  <p><em>my tfvars file :</em></p>
  <pre><code>log_based_metrics = [
    {
      name = &quot;name1&quot;,
      filter = &quot;resource.type=\&quot;k8s_pod\&quot;\njsonPayload.kind=\&quot;Event\&quot;\nresource.labels.cluster_name=\&quot;%s\&quot;\njsonPayload.message:\&quot;something\&quot;\njsonPayload.involvedObject.namespace=\&quot;%s\&quot;&quot;,   &lt;&lt; here I used %s for cluster name and namespace within filter&gt;&gt;
      metric_kind = &quot;DELTA&quot;,
      value_type = &quot;INT64&quot;
    }
  ]
  </code></pre>
  <p><em>My resource file :</em></p>
  <pre><code>    resource &quot;google_logging_metric&quot; &quot;logging_metric&quot; {
        for_each = { for inst in var.log_based_metrics : inst.name =&gt; inst }
        name = each.value.name
        filter = &quot;${format(&quot;${each.value.filter}&quot;,var.cluster_name,var.namespace)}&quot;      
   *&lt;&lt; here when I am using each.value.filter inside format ,it is giving error , instead if I am replacing it with actual value from tfvars file it is not giving any error &gt;&gt;*    
        metric_descriptor {
          metric_kind = each.value.metric_kind
          value_type = each.value.value_type
          dynamic &quot;labels&quot; {
            for_each = each.value.labels
            content {
              key = labels.value[&quot;label_key&quot;]
              value_type = labels.value[&quot;label_value_type&quot;]
              description = labels.value[&quot;label_description&quot;]
            }
          }
  </code></pre>
  <pre><code>Error: Invalid function argument
  
    on log_based_metrics.tf line 4, in resource &quot;google_logging_metric&quot; &quot;logging_metric&quot;:
     4:   filter = &quot;${format(&quot;${each.value.filter}&quot;,var.cluster_name,var.namespace)}&quot;
      |----------------
      | var.cluster_name is &quot;cluster-5&quot;
  
  Invalid value for &quot;args&quot; parameter: too many arguments; no verbs in format
  string.
  </code></pre>
  <p><em>when I use value of <em>each.value.filter</em> within format that is
  &quot;resource.type=&quot;k8s_pod&quot;\njsonPayload.kind=&quot;Event&quot;\nresource.labels.cluster_name=&quot;%s&quot;\njsonPayload.message:&quot;something&quot;\njsonPayload.involvedObject.namespace=&quot;%s&quot;
  it was not giving any error
  How can I use a variable from tfvars file in format function ??</em></p>