title: Why is userdata not working in my Terraform code?
body: <p>I am working with Terraform and trying to execute bash script using user date. Below is my code:</p>
  <pre><code>    resource &quot;aws_instance&quot; &quot;web_server&quot; {
    ami           = var.centos
    instance_type = var.instance-type
    subnet_id     = aws_subnet.private.id
    private_ip    = var.web-private-ip
    associate_public_ip_address = true
  
    user_data = &lt;&lt;-EOF
            #!/bin/bash 
            yum install httpd -y
            echo &quot;hello world&quot; &gt; /var/www/html/index.html
            yum update -y
            systemctl start httpd
            firewall-cmd --zone=public --permanent --add-service=http
            firewall-cmd --zone=public --permanent --add-service=https
            firewall-cmd --reload
            EOF
  }
  </code></pre>
  <p>However, when I navigate to the public IP I do not see the &quot;hello world&quot; message and also do not get a response fron the server. Is there something I am missing here? I've tried going straight through the aws console and user data is unsuccesful there to.</p>