title: Unique custom ID for each instance in AWS autoscaling group using terraform
body: <p>I am creating an AWS autoscaling group dynamically using ruby scripts and shell scripts. After the instances in ASG boot up, I am running a task in them in the <code>user_data</code> scripts. Let's say I have created 10 instances in the auto scaling group. I want to number these instances somehow (may be using tags or environment variables, etc.). So each instance will have an environment variable named "number" with its value being 1, 2, 3...10, unique for each instance.</p>
  
  <p>We can attach the <code>tags</code> with the instances as shown below:</p>
  
  <pre><code>resource "aws_autoscaling_group" "autoscaling_group" {
    name = "${var.asg_name}"
    max_size = "${var.max_size}"
    min_size = "${var.min_size}"
    desired_capacity = "${var.desired_capacity}"
    launch_configuration = "${aws_launch_configuration.launch_configuration.name}"
    vpc_zone_identifier = ["${data.aws_subnet_ids.default.ids}"]
  
    lifecycle {
      create_before_destroy = true
    }
  
    tag {
      key = "Environment"
      value = "production"
      propagate_at_launch = true
    }
  }
  </code></pre>
  
  <p>But I would like to attach a tag "number" with its different value with each instance.</p>
  
  <p>Or we can also send variables in <code>user_data</code> scripts as shown below:</p>
  
  <pre><code>data "template_file" "user_data_client" {
    template = "${file("./user-data-client.sh")}"
  
    vars {
      company_location_job_id   = "${var.company_location_job_id}"
      docker_login_username = "${var.docker_login_username}"
      docker_login_password = "${var.docker_login_password}"
    }
  }
  </code></pre>
  
  <p>But here also, I am not sure how to send incremental numbers for each instance in a variable.</p>
  
  <p>Is it possible to do this using terraform ? Thanks in advance.</p>