title: How can a process started using terraform user_data on an aws_instance continue to run beyond terraform apply finishing?
body: <p>I have a terraform file which creates an aws_instance and calls a process foo on that instance which should run for 10 mins. This process simulates some traffic which I can monitor elsewhere. I can manually ssh to the instance and run the process and it behaves as expected.</p>
  <p>The problem is it seems the process stops running once terraform apply has completed setting everything up (this is my assumption judging by when I stop seeing traffic and see terraform apply finish).</p>
  <p>If my assumption is correct is there a way to start the process in such a way that it will outlive terraform finishing?</p>
  <p>My terraform file creates the aws_instance like so, where foo has been previously uploaded to another bucket:</p>
  <pre><code>resource &quot;aws_instance&quot; &quot;example&quot; {
    ami           = &quot;ami-0c55b159cbfafe1f0&quot;
    instance_type = &quot;t2.micro&quot;
    user_data = &lt;&lt;-EOF
                #!/bin/bash
                  aws s3 cp s3://foobar-bucket/foo ./
                  chmod +x foo
                  sudo ./foo
                EOF
    tags = {
      Name = &quot;terraform-example&quot;
    }
  }
  
  </code></pre>