From 46de53254c9e8189b8c25ba6d8877397644d339b Mon Sep 17 00:00:00 2001 From: Yurii Pyvovarov Date: Mon, 28 Jan 2019 17:24:42 +0200 Subject: [PATCH 1/3] In request were missing Content-Type header and Logstash responced with 406 error. Due to http://docs.python-requests.org/en/master/user/quickstart/\#more-complicated-post-requests json will be encoded automatically. --- aws_config_to_es/elastic.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/aws_config_to_es/elastic.py b/aws_config_to_es/elastic.py index 0ea8346..b9d9fe6 100644 --- a/aws_config_to_es/elastic.py +++ b/aws_config_to_es/elastic.py @@ -35,18 +35,16 @@ def add( json_message_dict["addedIso"] = datetime.datetime.now().isoformat() json_message_dict["updatedIso"] = json_message_dict["addedIso"] - json_message = json.dumps(json_message_dict) - self.log.info("adding item into ES: " + str(json_message_dict)) if index_id: response = requests.put(self.connections + "/" + index_name + "/" + doc_type + "/" + - index_id, data=json_message) + index_id, json=json_message_dict) else: response = requests.post(self.connections + "/" + index_name + "/" + - doc_type, data=json_message) + doc_type, json=json_message_dict) self.log.info( "response: " + str( From be00ef307568639cd04614f970abe89d7ad8c542 Mon Sep 17 00:00:00 2001 From: Yurii Pyvovarov Date: Mon, 28 Jan 2019 17:28:35 +0200 Subject: [PATCH 2/3] pip is not able to find the modules in PyPE. They are inbuilt. --- requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9e66dd6..3f61b89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ boto3 botocore requests -gzip -json argparse From f89e3e1fe6a4c8461f35f03fc42093f9f2fa7a88 Mon Sep 17 00:00:00 2001 From: Yurii Pyvovarov Date: Tue, 29 Jan 2019 15:42:02 +0200 Subject: [PATCH 3/3] add pipenv support --- .gitignore | 1 + Pipfile | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Pipfile diff --git a/.gitignore b/.gitignore index 77eaf11..07a0c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea *pyc *.out +*.lock diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..78953e2 --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +boto3 = "*" +botocore = "*" +requests = "*" +argparse = "*" + +[requires] +python_version = "2.7"