code: def getAWSAccountID():
    '''
    Print an instance's AWS account number or 0 when not in EC2
    '''
    link = "http://169.254.169.254/latest/dynamic/instance-identity/document"
    try:
      conn = urllib2.urlopen(url=link, timeout=5)
    except urllib2.URLError:
      return '0'
    jsonData = json.loads(conn.read())
    return jsonData['accountId'f getAWSAccountID():
    '''
    Print an instance's AWS account number or 0 when not in EC2
    '''
    link = "http://169.254.169.254/latest/dynamic/instance-identity/document"
    try:
      conn = urllib2.urlopen(url=link, timeout=5)
    except urllib2.URLError:
      return '0'
    jsonData = json.loads(conn.read())
    return jsonData['accountId']
docs: Print an instance's AWS account number or 0 when not in EC2