def is_ec2_instance():
<EOL>global IS_EC2_INSTANCE<EOL>if IS_EC2_INSTANCE != -<NUM_LIT:1>:<EOL><INDENT>return IS_EC2_INSTANCE<EOL><DEDENT>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<EOL>s.settimeout(<NUM_LIT>)<EOL>try:<EOL><INDENT>s.connect(("<STR_LIT>", <NUM_LIT>))<EOL>IS_EC2_INSTANCE = <NUM_LIT:1><EOL>return True<EOL><DEDENT>except socket.timeout:<EOL><INDENT>IS_EC2_INSTANCE = <NUM_LIT:0><EOL>return False<EOL><DEDENT>except socket.error:<EOL><INDENT>IS_EC2_INSTANCE = <NUM_LIT:0><EOL>return False<EOL><DEDENT>
Try fetching instance metadata at 'curl http://169.254.169.254/latest/meta-data/'
    to see if host is on an ec2 instance