9
What's the fastest way, in terms of execution time, for a Java JVM to determine if it's running on an AWS EC2 instance?
My current method is to do an http fetch to http://169.254.169.254/latest/instance-id, but that takes several seconds to time out when I'm not running on AWS.
Update:
My solution was to look at the Java system property "user.name" and see if it contained "ec2". We always run our app under the "ec2-user" user name so this method is fast and reliable.