title: Set environment variables in an AWS instance
body: <p>I create an <strong>AMI in EC2 with terraform</strong> with this resource:</p>
  
  <pre><code>resource "aws_instance" "devops-demo" {
    ami           = "jnkdjsndjsnfsdj"
    instance_type = "t2.micro"
    key_name      = "demo-devops"
    user_data     = "${file("ops_setup.sh")}"
  }
  </code></pre>
  
  <p>The user data executes a <strong>shell script</strong> that install Java JRE:</p>
  
  <pre><code>  sudo yum remove java-1.7.0-openjdk -y
    sudo wget -O /opt/server-jre-8u172-linux-x64.tar.gz --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/server-jre-8u172-linux-x64.tar.gz"
    sudo tar xzf /opt/server-jre-8u172-linux-x64.tar.gz
    export JAVA_HOME=/jdk1.8.0_172
    export JRE_HOME=/jdk1.8.0_171/jre
    export PATH=$JAVA_HOME/bin:$PATH
  </code></pre>
  
  <p>But none of the environment variables work. However, if I connect by ssh to the instance and I execute the export command, it works fine.</p>
  
  <p>Is there any way to define the environment variables with terraform?</p>