- Newest
- Most votes
- Most comments
This error occurs because your EC2 instance doesn't have the proper authorization to access your OpenSearch domain, even though both are in the same VPC. There are several ways to resolve this issue:
-
Resource-based policy: You need to create a resource-based policy for your OpenSearch domain that allows access from your EC2 instance. The policy should grant the necessary permissions (like es:ESHttpGet) to the IAM role or user that your EC2 instance is using.
-
IAM role for EC2: Ensure your EC2 instance has an IAM role attached with permissions for OpenSearch operations (es:ESHttpGet and potentially es:ESHttpPost if you'll be using features like the Discover page).
-
IP-based access control: If you're using a proxy server between your application and OpenSearch, you can set up an IP-based access policy that allows requests from the proxy's IP address.
-
Fine-Grained Access Control (FGAC): For more granular control, you can enable FGAC on your OpenSearch domain and create roles that allow specific access to indices and operations.
For your specific error, you need to create a resource-based policy that allows the EC2 instance's IAM role to perform es:ESHttpGet actions on your OpenSearch domain. Here's what a sample policy might look like:
{ "Version": "2012-10-17", "Statement": [ { "Resource": "arn:aws:es:region:account-id:domain/domain-name/*", "Principal": { "AWS": "arn:aws:iam::account-id:role/your-ec2-role" }, "Action": [ "es:ESHttpGet", "es:ESHttpPost" ], "Effect": "Allow" } ] }
Note that for using OpenSearch Dashboards' Discover page, you'll need to include es:ESHttpPost permission as well, since the Discover page uses POST requests even for read-only operations.
Sources
Using OpenSearch Dashboards with Amazon OpenSearch Service - Amazon OpenSearch Service
OpenSearch UI dashboard's Discover page requires ESHttpPost permission even when you only want to grant read access | AWS re:Post
answered a year ago
Relevant content
asked 5 years ago
