question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making signed requests to Elasticsearch

See original GitHub issue

Hi,

I’m writing a python lambda function to process incoming ELB logs and put them into an Elasticsearch domain. So far the boto3 library has been great, but I’m struggling to find out how to either make my bulk index post through the client or how to sign a direct rest api call.

I thought the generate_presigned_url call might be what I want, but I can’t find out what is a valid ClientMethod

Is there an easy way to sign an outgoing request through the boto3 library using assumed iam role credentials?

Thanks, Alex

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:16
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

67reactions
alexruddcommented, Oct 17, 2016

Thanks!

For anyone else who comes across this problem, here’s what I ended up doing:

import boto3
from aws_requests_auth.aws_auth import AWSRequestsAuth
from elasticsearch import Elasticsearch, RequestsHttpConnection

session = boto3.session.Session()
credentials = session.get_credentials().get_frozen_credentials()

es_host = 'search-my-es-domain.eu-west-1.es.amazonaws.com'
awsauth = AWSRequestsAuth(
    aws_access_key=credentials.access_key,
    aws_secret_access_key=credentials.secret_key,
    aws_token=credentials.token,
    aws_host=es_host,
    aws_region=session.region_name,
    aws_service='es'
)

# use the requests connection_class and pass in our custom auth class
es = Elasticsearch(
    hosts=[{'host': es_host, 'port': 443}],
    http_auth=awsauth,
    use_ssl=True,
    verify_certs=True,
    connection_class=RequestsHttpConnection
)

print(es.info())
Read more comments on GitHub >

github_iconTop Results From Across the Web

Signing HTTP requests to Amazon OpenSearch Service
This section includes examples of how to send signed HTTP requests to Amazon OpenSearch Service using Elasticsearch and OpenSearch clients and other common ......
Read more >
Making signed requests to AWS Elasticsearch Service with ...
Here is my implementation for Elasticsearch client compatible with Amazon Elasticsearch AWS4 signed requests:
Read more >
Sign Requests to AWS Elasticsearch Service with Instance ...
AWS Elasticsearch Tutorial : What is Elasticsearch and How to Create it and Use it. dotsway. dotsway. •. •. 112K views 5 years...
Read more >
How to send signed AWS Elasticsearch request? · Issue #2099
Describe the issue with documentation How to send signed AWS Elasticsearch request? I've come with up the below solution.
Read more >
Signing requests to Amazon Elasticsearch service - ElastAlert
Currently, there is no way to secure your Elasticsearch using network firewall rules, so the only way is to signing the requests using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found