I have my elastic search with cognito authentication enabled for kibana. This is working fine as expected.
In my python script I connect to elasticsearch by providing username/password in http_auth(), while creating the connection object. But when I attempt to check if an indices exist, am getting authentication error? Can someone please help. Heres the sample piece of code for your simulation please.
from __future__ import print_function
import json
import time
import urllib
import re
import sys
import requests
import base64
import time
from elasticsearch import Elasticsearch
from datetime import datetime
esEndpoint = ""
uname
pwd
indexName = 'index_1'
mappings_rds = {
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"mappings": {
"properties" : {
"tableName": {
"type": "keyword"
},
"tableRows": {
"type": "integer"
},
"updatedTime": {
"type": "date",
"format":"date_optional_time||yyyy-MM-dd'T'HH:mm:ss"
},
"created_timestamp":{
"type": "date",
"format":"date_optional_time||yyyy-MM-dd'T'HH:mm:ss"
}
}
}
}
esClient = Elasticsearch([esEndPoint],http_auth=(uname,pwd))
try:
res = esClient.indices.exists(indexName)
print(res)
if res is False:
r = esClient.indices.create(indexName, body=mapping_rds, ignore=400)
return 1
except Exception as E:
print("Unable to Create Index {0}".format(indexName))