- Newest
- Most votes
- Most comments
Hello Halim,
To answer your question directly - You need to add the Lambda role in the "all_access" role or create another role with least privileges and map the lambda role to this newly created role in order for the lambda function to send requests to the domain.
[+] https://opensearch.org/docs/latest/security/access-control/users-roles/
Please note mapping users/roles to the backend pre-defined roles of the Opensearch cluster is not possible via CDK. However you can make Lambda role as the master role
FGAC auth and the error explanation
- After a resource-based access policy allows a request to reach a domain endpoint, fine-grained access control evaluates the user credentials and either authenticates the user or denies the request. If fine-grained access control authenticates the user, it fetches all roles mapped to that user and uses the complete set of permissions to determine how to handle the request.
[+] https://docs.aws.amazon.com/opensearch-service/latest/developerguide/fgac.html#fgac-access-policies [+] https://docs.aws.amazon.com/opensearch-service/latest/developerguide/search-example.html#search-example-perms
-
Currently using Cognito access you have allowed the cognito.masterUserRole access to the cluster, which maps this IAM role to "all_access" and "security_manager" predefined role in the backend.
-
Even though your Lambda role has the necessary permissions to access the Opensearch domain. This role is not mapped to any backend predefined roles.
-
Hence when your Lambda function makes a request to the cluster, fine-grained access control evaluates the user credentials and authenticates the user(since the role has permission to access the opensearch), however when it fetches all roles[predefined roles] mapped to that user, it observes the user does not have any permissions mapped and hence denies the API request, returning security exception.
Hope the above information clarifies why you needed to add the Lambda role in the "all_access" role and how the authentication takes place in AWS Opensearch.
