title: How to use null with a different value in place of default value
body: <p>I know that null can be used like this to set default behavior if var not specified:</p>
  <pre><code>variable &quot;override_private_ip&quot; {
    type    = string
    default = null
  }
  
  resource &quot;aws_instance&quot; &quot;example&quot; {
    # ... (other aws_instance arguments) ...
    private_ip = var.override_private_ip
  }
  </code></pre>
  <p>But I want to set my own default behavior if its not specified.</p>
  <p>I'm doing this:</p>
  <pre><code>#### if user sets an id use that but if not get id from data source
  resource &quot;aws_instance&quot; &quot;myserver&quot; {
    ami = var.ami_id != null ? var.ami_id : data.aws_ami.getami.id
  </code></pre>
  <p>this seems to work but is this the correct way? I want to make sure I'm not missing a feature for this. I tried just <code>var.ami_id ? var.ami_id : data.aws_ami.getami.id</code> but null is not converted to a bool so did not work.</p>