'get instance id from amazon meta data server'

def get_instance_id(self, instance_id=None):

    self.instance_id = instance_id
    if (self.instance_id is None):
        try:
            conn = HTTPConnection('169.254.169.254')
            conn.request('GET', '/latest/meta-data/instance-id')
        except Exception:
            raise CloudWatchException("Can't    connect    Amazon    meta    data    server    to    get    InstanceID    :    (%s)")
        self.instance_id = conn.getresponse().read()
    return self
