title: AWS Lambda interact with elastic search
body: <p>I'm new in AWS world and try to dev a proof of concept that allow lambda function to interact with elasticSearch (AWS service) and S3 bucket.</p>
  
  <p>I'm not sure to understand really how it works. We have to set an IAM role linked to the Lambda function but no user so first question : </p>
  
  <ul>
  <li>Who is the user running the Lambda function ?</li>
  </ul>
  
  <p>I set my Elastic Search connexion like this (using <a href="https://github.com/DavidMuller/aws-requests-auth" rel="nofollow noreferrer">https://github.com/DavidMuller/aws-requests-auth</a>)  : </p>
  
  <pre><code>def connectES(esEndPoint):
  print ('Connecting to the ES Endpoint {0}'.format(esEndPoint))
  try:
      # let's talk to our AWS Elasticsearch cluster
      auth = BotoAWSRequestsAuth(
                  aws_host='vpc-poc-lambda-3opu7gwdw7bwvtmmazjmdgo7gi.eu-west-3.es.amazonaws.com',
                  aws_region='eu-west-3',
                  aws_service='es')
      esClient = Elasticsearch(
          hosts=[{'host': esEndPoint, 'port': 443}],
          use_ssl=True,
          verify_certs=True,
          connection_class=RequestsHttpConnection,
          http_auth=auth)
      return esClient
  except Exception as E:
      print("Unable to connect to {0}".format(esEndPoint))
      print(E)
      exit(3)
  </code></pre>
  
  <p>It seams to work but I don't understand what credential it use.
  Then I create an index successfully with :</p>
  
  <pre><code>esClient.indices.create('test')
  </code></pre>
  
  <p>But when I try try to index a doc like this I get error :</p>
  
  <pre><code>esClient.index(index='test', doc_type='post', id=123456, body={
              'author': 'John Doe',
              'blog': 'Learning Elasticsearch',
              'title': 'Using Python with Elasticsearch',
              'tags': ['python', 'elasticsearch', 'tips'],
          })
  
  
  [WARNING]   2018-02-15T10:39:28.460Z    7f1cc69d-123c-11e8-be8b-cbbfad79068b    PUT https://vpc-****-****.eu-west-3.es.amazonaws.com:443/test/post/123456 [status:406 request:0.039s]
  Document not indexed
  Error:  string indices must be integers
  </code></pre>
  
  <p>I really don't understant why it won't work and hope there is an easy way to interact with other AWS service from Lambda.</p>
  
  <p>Can you help me ?
  Thanks</p>