How do i add a custom HTTP header using the python client?


(Danaronson) #1

I'm currently looking thought the code, but haven't found a way to do it yet. I want to add a constant custom header to each of the HTTP requests. I'm using RequestsHttpConnection.

My use case is that i am trying to talk to an AWS ES server from an amazon lamda which uses a temporary credential in a header. The header is X-Amz-Security-Token (see: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html#RequestWithSTS)


(Danaronson) #2

Figured it out:

   es.transport.connection_pool.connection.session.headers.update({'x-amz-security-token': os.environ['AWS_SESSION_TOKEN']})

(system) #3