title: Commands in user_data are not executed in terraform
body: <p>Hi EC2 instance is created, but commands as part of userdata.sh are not  gettingexecuted. When I manually connect to EC2 via putty, i found that nginx is not installed in EC2 instance. To verify if the script is getting executed or not I added echo message, but no output is display in command prompt when i run terraform apply. How can i verify if the user-data is getting executed or not?</p>
  
  <p>I have installed Terraform in C drive and below script are present in same folder C:/Terraform/userdata.sh, C:/Terraform/main.tf, i tried giving path as ${file("./userdata.sh")}" but still it does not work.</p>
  
  <p>Please advice as I am just learning terraform. Thanks.</p>
  
  <pre><code>#!/bin/bash -v
  echo "userdata-start"
  sudo apt-get update -y
  sudo apt-get install -y nginx &gt; /tmp/nginx.log
  sudo service nginx start
  echo "userdata-end"
  </code></pre>
  
  <p>This is been called in my terraform program [main.tf] as below:</p>
  
  <pre><code># resource "template_file" "user_data" {
  #    template = "userdata.sh"
  # }
  
  data "template_file" "user_data" {
  template = "${file("userdata.sh")}"
  }
  
  resource "aws_instance" "web" {
  instance_type = "t2.micro"
  
  ami = "ami-5e8bb23b"
  
  key_name = "sptest"
  
  vpc_security_group_ids = ["${aws_security_group.default.id}"]
  subnet_id              = "${aws_subnet.tf_test_subnet.id}"
  
  user_data               = "${data.template_file.user_data.template}"
  #user_data              = "${template_file.user_data.rendered}"
  #user_data              = "${file("userdata.sh")}"
  #user_data              = "${file("./userdata.sh")}"
  
  
  tags {
  Name = "tf-example-ec2"
  }
  } 
  </code></pre>