mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
909 stars 187 forks source link

Cannot authenticate using AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from aws-elasticbeanstalk-ec2-role #125

Closed slhender closed 2 years ago

slhender commented 3 years ago

My team and I have ran into an issue whereby we are not able to authenticate and get access to our AWS ElasticSearch instance.

With other AWS services, we have been able to rely on the credentials passed through via the aws-elasticbeanstalk-ec2-role. However with the implementation of this package, this does not work. We have found that we must define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY values in the list of environment variables, in order to use ElasticSearch.

We have confirmed that the aws-elasticbeanstalk-ec2-role has the required permissions via the AmazonESFullAccess policy.

Our environment setup is as follows; Laravel 5.8.35 PHP 7.2 cviebrock/laravel-elasticsearch 3.6.0 aws/aws-sdk-php 3.112.4 Elasticsearch 7.1

As part of the code base, we check that an index exists, if it doesn't we create it before indexing the record. It looks like it is failing to authenticate when it is checking for the existence of the index.

if(Elasticsearch::indices()->exists(['index' => Thread::ELASTIC_INDEX]) == false) {
        Elasticsearch::indices()->create(['index' => Thread::ELASTIC_INDEX]);
}

Elasticsearch\Common\Exceptions\Forbidden403Exception …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php626 91 Elasticsearch\Connections\Connection process4xxError …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php295 90 Elasticsearch\Connections\Connection Elasticsearch\Connections{closure} …/vendor/react/promise/src/FulfilledPromise.php25 89 React\Promise\FulfilledPromise then …/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php55 88 GuzzleHttp\Ring\Future\CompletedFutureValue then …/vendor/guzzlehttp/ringphp/src/Core.php341 87 GuzzleHttp\Ring\Core proxy …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php315 86 Elasticsearch\Connections\Connection Elasticsearch\Connections{closure} …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php187 85 Elasticsearch\Connections\Connection performRequest …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php112 84 Elasticsearch\Transport performRequest …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/BooleanRequestWrapper.php40 83 Elasticsearch\Namespaces\BooleanRequestWrapper performRequest …/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php40 82 Elasticsearch\Namespaces\IndicesNamespace exists …/app/Listeners/IndexThreadListener.php55

Do you have any advice on why this might be the case and how it may be resolved?

cviebrock commented 2 years ago

Closing old tickets as I'm abandoning this package. Sorry.

gmarineau commented 2 years ago

@Aggrom do you have found a solution ?