|
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 | """ |
4 | 4 | This AWS Lambda function allowed to delete the old Elasticsearch index |
| 5 | +
|
| 6 | +THIS FILE IS NOT EXACTLY THE ORIGINAL FILE DISTRIBUTED BY Cloudreach Europe Limited |
| 7 | +IT HAS BEEN MODIFIED BY Cloud Posse, LLC |
5 | 8 | """ |
6 | 9 |
|
7 | 10 | from __future__ import print_function |
|
14 | 17 | from botocore.auth import SigV4Auth |
15 | 18 | from botocore.awsrequest import AWSRequest |
16 | 19 | from botocore.credentials import create_credential_resolver |
| 20 | +from botocore.httpsession import URLLib3Session |
17 | 21 | from botocore.session import get_session |
18 | | -from botocore.vendored.requests import Session |
19 | 22 | import sys |
20 | 23 | if sys.version_info[0] == 3: |
21 | 24 | from urllib.request import quote |
@@ -117,7 +120,7 @@ def send_to_es(self, path, method="GET", payload={}): |
117 | 120 |
|
118 | 121 | try: |
119 | 122 | preq = req.prepare() |
120 | | - session = Session() |
| 123 | + session = URLLib3Session() |
121 | 124 | res = session.send(preq) |
122 | 125 | if res.status_code >= 200 and res.status_code <= 299: |
123 | 126 | # print("%s %s" % (res.status_code, res.content)) |
@@ -186,9 +189,9 @@ def lambda_handler(event, context): |
186 | 189 | earliest_to_keep = datetime.date.today() - datetime.timedelta( |
187 | 190 | days=int(es.cfg["delete_after"])) |
188 | 191 | for index in es.get_indices(): |
189 | | - if index["index"] == ".kibana": |
| 192 | + if index["index"] == ".kibana" or index["index"] == ".kibana_1": |
190 | 193 | # ignore .kibana index |
191 | | - print("Found .kibana index - ignoring") |
| 194 | + print("Found Kibana index: %s - ignoring" % index["index"]) |
192 | 195 | continue |
193 | 196 |
|
194 | 197 | idx_name = '-'.join(word for word in index["index"].split("-")[:-1]) |
|
0 commit comments