使用 cURL --aws-sigv4 调用 AWS Elasticsearch Service API

call AWS Elasticsearch Service API with cURL --aws-sigv4

当我执行

curl --request GET "https://${ES_DOMAIN_ENDPOINT}/my_index_pattern-*/my_type/_mapping" \
--user $AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY \
--aws-sigv4 "aws:amz:ap-southeast-2:es"

其中 $ES_DOMAIN_ENDPOINT 是我的 AWS Elasticsearch 端点,我收到以下响应:

{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}

我确信我的 $AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY 是正确的。

但是,当我使用 AWS 身份验证和上述参数发送相同的邮递员请求时,响应正在通过。我比较了两个请求的详细输出,它们有非常小的差异,例如时间戳和签名。

我想知道,--aws-sigv4 配置有什么问题?

此问题是由于路径中的 * 字符引起的。 curl 存储库中有一个错误报告可以解决此问题 https://github.com/curl/curl/issues/7559

同时,为了减轻错误,您应该从路径中删除 * 或从分支 https://github.com/outscale-mgo/curl-appimage/tree/http_aws_sigv4_encoding.

构建 curl