title: How to "override" some of the resource parameters when using terraform modules?
body: <p>i am trying to develop generic terraform modules to support data-dog monitors and let the user of the modules to append resources and/or override resources in side generic modules.</p>
  
  <p>terraform <a href="https://www.terraform.io/docs/configuration/override.html" rel="nofollow noreferrer">overrides</a> feature works fine without modules, But not working when using modules.</p>
  
  <p>how to override some of the resource parameters inside modules? </p>
  
  <p><strong>Requirements:</strong> </p>
  
  <ol>
  <li><p><em>/modules/datadog/monitors.tf</em> contains list of resources, each resource represents a generic datadog monitor with default parameter values. Each <strong>individual application may choose to override one or more parameters inside each resource</strong>.</p></li>
  <li><p><em>/application-1/monitors.tf</em> contains module with source as <strong>/modules/datadog/</strong> , some more monitors that are not covered in generic monitors and some variables.</p></li>
  </ol>
  
  <p>/application-1/monitors.tf</p>
  
  <pre><code>module "datadog" {
    source  = "/modules/datadog/"
  }
  </code></pre>
  
  <p>/modules/datadog/monitors.tf</p>
  
  <pre><code># Generic Datadog monitor to monitor cpu 
  resource "datadog_monitor" "foo" {
    name               = "Name for monitor foo"
    type               = "metric alert"
    message            = "Monitor triggered. Notify: @hipchat-channel"
    escalation_message = "Escalation message @pagerduty"
  
    query = "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} &gt; 4"
  
    thresholds {
      ok                = 0
      warning           = 2
      warning_recovery  = 1
      critical          = 4
      critical_recovery = 3
    }
  
    notify_no_data    = false
    renotify_interval = 60
  
    notify_audit = false
    timeout_h    = 60
    include_tags = true
  
    silenced {
      "*" = 0
    }
  
    tags = ["foo:bar", "baz"]
  }
  </code></pre>
  
  <p><strong>Solution 1</strong>: Add overrides.tf to <strong>/modules/datadog</strong> Directory. terraform <a href="https://www.terraform.io/docs/configuration/override.html" rel="nofollow noreferrer">override feature</a> merges content in overrides.tf to 
   configuration defined in monitors.tf.<br>
   But the problem with this solution is each application specific overrides.tf needs to be copied over to /modules/datadog Directory before running apply command. </p>
  
  <p>overrides.tf</p>
  
  <pre><code>resource "datadog_monitor" "foo" {
        escalation_message = "Escalation message @pagerduty1"
  
        thresholds {
          ok                = 0
          warning           = 20
          warning_recovery  = 10
          critical          = 40
          critical_recovery = 35
        }
  
        notify_no_data    = false
  
      }
  </code></pre>
  
  <p><strong>Solution 2</strong>: can i use overrides with modules? i tried to override resource parameters by copying overrides.tf to /application-1/ Directory, But terraform is not overriding resources, instead it is considering both as different resources.</p>