title: Define: Terraform - AWS - aws_instance - user_data
body: <p>I'm working with Terraform, launching an ECS cluster.</p>
  
  <p>I'm using a script that was written by someone else.  I understand most of the launch configuration script, other than this one point:</p>
  
  <p>I'm trying to find the link between the autoscaling group and the ECS cluster.</p>
  
  <p>I have an <code>aws_autoscaling_group</code> which uses an <code>aws_launch_configuration</code> (see below).
  The <code>aws_launch_configuration</code> has a <code>user_data</code> parameter.  This is the only link between the autoscaling group and the cluster that I can find.</p>
  
  <p>Looking at the links (bottom) to the documentation, it's not giving a very good explanation of 'what' <code>user_data</code> is.  Can someone please help me understand "how" the <code>user_data</code> links the autoscaling group with the cluster, and if at all possible give some example or link to what it's normally used for and how it's normally used.</p>
  
  <pre><code>...
  resource "aws_launch_configuration" "ecs_host" {
    ...
  
    user_data = &lt;&lt;EOF
  #!/bin/bash
  echo ECS_CLUSTER=${var.cluster_name} &gt;&gt; /etc/ecs/ecs.config
  EOF
  }
  ...
  </code></pre>
  
  <p>terraform apply outputs:</p>
  
  <pre><code>  ...
    + aws_launch_configuration.ecs_host
        ...
        user_data: "4e27e8feea0896af43ada0c647877da3766f5dcb"
    ...
  </code></pre>
  
  <p><a href="https://www.terraform.io/docs/providers/aws/r/instance.html#user_data" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/aws/r/instance.html#user_data</a>
  <a href="https://www.terraform.io/docs/providers/aws/r/launch_configuration.html#user_data" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/aws/r/launch_configuration.html#user_data</a></p>