Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Elasticsearch and CORS

I'm trialing the AWS Elasticsearch service:

https://aws.amazon.com/elasticsearch-service/

Very easy to setup. Basically just hit deploy. I unfortunately can't get any of the Elasticsearch GUI's to connect (ElasticHQ, Elasticsearch Head) as CORS is not enabled in the AWS build, and there is no way to change the elasticsearch config, or install plugins that I can see.

Does anyone know how to change these options on AWS?

like image 327
Kong Avatar asked Oct 26 '15 01:10

Kong


3 Answers

My workaround while still staying inside of the AWS ecosystem was to create an API using the API Gateway.

I created a new POST end point with the address of my elasticsearch instance, and then followed the following guide: CORS on AWS API Gateway to add CORS to this end point. This allowed my front end code to be able to make requests from a different domain.

like image 127
Le3wood Avatar answered Oct 06 '22 20:10

Le3wood


In case it's useful to anyone else - you can disable CORS for testing purposes using a Chrome plugin.

ElasticHQ and Elasticsearch Head still won't work properly with AWS Elasticsearch though (at the time of writing) as they make calls to /_cluster/state which is not currently one of the supported AWS ElasticSearch operations.

Disabling CORS and performing a GET on /_cluster/state returns

{
    Message: "Your request: '/_cluster/state' is not allowed."
}

Some functionality still works in ElasticHQ but I'm unable to get Elasticsearch Head to work.

like image 33
harryrobbins Avatar answered Oct 06 '22 19:10

harryrobbins


Like @Le3wood said, the workaround could be integrating with AWS ecosystem. Besides API gateway, using AWS Lambda also works.

like image 23
Jason Kang Avatar answered Oct 06 '22 20:10

Jason Kang