title: Get HOSTNAME from a file in cloud-init
body: <p>I've the following file in my <code>cloud-init</code></p>
  
  <pre><code>write_files:
  - path: /opt/data/conf.conf
    owner: root:root
    permissions: '0755'
    content: |
      [default]
      host = $HOSTNAME
  </code></pre>
  
  <p>I need to interpolate properly the variable <code>$HOSTNAME</code> when it is executed in an EC2 instance.</p>
  
  <p>I didn't find anything about that in the documentation but I found EC2 datasource.</p>
  
  <p>Any idea how to properly interpolate that value?</p>
  
  <p>The quick idea I had is to write it inside an executable and interpolate from there. is it the only way?</p>