I have an elastic search service behind a CNAME and when I try to access it through my command line using curl command, I am able to get the correct response with HTTP 200 OK response.
However, when I try connecting to the service using Java API's Rest High Level Client, I get a 403 error.
The access policy of my elastic search is configured with * as AWS Principal.
The error log is like this:
[DEBUG] org.elasticsearch.client.RestClient: request [POST http://ES_ENDPOINT/INDEX_NAME/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true] returned [HTTP/1.1 403 Forbidden]
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}
What could the possible reasons behind this be? This issue only occurs for CNAME and not the actual elastic search domain name.