0

I'm using Elastic-Beanstalk to deploy my web server to multiple instances. I configured an endpoint /version which I'd like the server to tell me which version it runs and hopefully from which instance I was handled (to validate that the LB works as expected for instance).

I would like something like this to work:

app.get('/version', function (req, res) {
  var instance = getInstanceInfo();
  res.end(instance + 'v0.0.2');
});

How would getInstanceInfo() look like?

Thanks

johni
  • 5,342
  • 6
  • 42
  • 70
  • Possible duplicate of [Find out the instance id from within an ec2 machine](http://stackoverflow.com/questions/625644/find-out-the-instance-id-from-within-an-ec2-machine) – Anthony Neace Apr 24 '16 at 02:12

1 Answers1

0

You could hit the EC2 metadata service directly at: http://169.254.169.254/latest/meta-data/

Or you could use the metadata service in the SDK: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MetadataService.html

Mark B
  • 183,023
  • 24
  • 297
  • 295