Update:
I also tried this:
from elasticsearch import Elasticsearch
es = Elasticsearch([HOST],
http_auth = (str(USERNAME), str(PASSWORD)),
scheme = "https", port=443, use_ssl=True,
verify_certs=True, # no verify SSL certificates
ssl_show_warn=False) # don't show warnings about ssl certs verification
It didn't return me any warning, but then when I try to perform a search I get this problem:
query = '{"query": {"bool": {"must": [{"match": {"message": "exception"}}, {"match": {"cloudwatch_logs.log_group": "/aws/lambda/*"}}], "filter": {"range": {"@timestamp": {"from": "now-6h/h", "to": "now"}}}}}}'
index = 'cloudwatch-prod-2019-11'
es.search(index = index, body = query, size = 10000)
Error:
GET <my_url>/cloudwatch-prod-2019-11/_search?size=100 [status:N/A request:0.110s]
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 332, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)