How can I check which platform my app runs, AWS EC2 instance, Azure Role instance and non-cloud system? now I do that like this:
if(isAzure()) { //run in
I think your original idea is pretty good, but no need to make the web request. Simply try to see if the name resolves (in python):
def is_ec2(): import socket try: socket.gethostbyname('instance-data.ec2.internal.') return True except socket.gaierror: return False