title: When launching multiple instances, is there a way to assign each EC2 instance a pre-known unique ID?
body: <p>If one launches 5 EC2 instances in a single go, is there a way to uniquely ID each instance with a pre-known ID (e.g. 1, 2, 3, 4, 5) in the User data setting of <strong>Step 3: Configure Instance Details</strong>?</p>
  <p>e.g. User data:</p>
  <pre><code>#!/bin/bash
  for i in {1..5}
  do
     #assign a unique number 1 through 5 to this instance
     echo $id &gt; $dir
  done
  </code></pre>