title: terraform copy/upload files to aws ec2 instance
body: <p>We have cronjob and shell script which we want to copy or upload to aws ec2 instance while creating instance using terraform. </p>
  
  <p>we tried</p>
  
  <ol>
  <li>file provisioner : 
  but its not wokring , and read this option does not work with all terraform version</li>
  </ol>
  
  <pre><code>      provisioner "file" {
          source      = "abc.sh"
          destination = "/home/ec2-user/basic2.sh"
        }
  </code></pre>
  
  <ol start="2">
  <li>tried data template file option </li>
  </ol>
  
  <pre><code>    data "template_file" "userdata_line" {
        template = &lt;&lt;EOF
      #!/bin/bash
      mkdir /home/ec2-user/files2
      cd /home/ec2-user/files2
      sudo touch basic2.sh
      sudo chmod 777 basic2.sh
      base64 basic.sh |base64 -d &gt;basic2.sh
      EOF
      }
  </code></pre>
  
  <p>tried all option but none of them working.<br>
  could u please help or advise .<br>
  I am new to terraform so struggling on this from long time.</p>