使用 Python 向 AWS Elasticsearch 发出签名的 HTTP 请求 [英] Making a signed HTTP request to AWS Elasticsearch in Python

查看:21
本文介绍了使用 Python 向 AWS Elasticsearch 发出签名的 HTTP 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的 Python Lambda,用于制作我们 Elasticsearch 数据库的快照.这是通过 Elasticsearch 的 REST API 使用简单的HTTP 请求.

I'm trying to make a simple Python Lambda that makes snapshots of our Elasticsearch database. This is done through Elasticsearch's REST API using simple HTTP requests.

但是,对于 AWS,我必须签署这些请求.我有一种感觉,它可以通过 boto3 的低级客户端实现,可能使用 generate_presigned_url,但我一生都无法弄清楚如何正确调用此函数.例如,有效的 ClientMethod 是什么?我试过 ESHttpGet 但无济于事.

However, for AWS, I have to sign these requests. I have a feeling it can be achieved through boto3's low-level clients probably with generate_presigned_url, but I cannot for the life of me figure out how to invoke this function correctly. For example, what are the valid ClientMethods? I've tried ESHttpGet but to no avail.

谁能指出我正确的方向?

Can anyone point me in the right direction?

推荐答案

requests 库有多个 Python 扩展,可以为您执行 SigV4 签名.我用过这个,效果很好.

There are several Python extensions to the requests library that will perform the SigV4 signing for you. I have used this one and it works well.

这篇关于使用 Python 向 AWS Elasticsearch 发出签名的 HTTP 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆