[PR #18963] feat: add AWS Managed IAM auth for OpenSearch vector DB #29046

Closed
opened 2026-02-21 20:44:46 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/18963

State: closed
Merged: Yes


Summary

This PR introduces support for connecting to AWS Managed OpenSearch clusters and OpenSearch Serverless (AOSS) using AWS Identity and Access Management (IAM) authentication.

This implementation leverages the AWS SigV4 signing process provided by the opensearch-py library (Urllib3AWSV4SignerAuth), allowing users to configure OpenSearch vector databases without relying on basic username/password authentication, and instead use AWS IAM roles and policies for secure access.

Key changes include:

  • Addition of new configuration options: OPENSEARCH_AUTH_METHOD, OPENSEARCH_AWS_REGION, and OPENSEARCH_AWS_SERVICE.
  • Integration of AWS SigV4 authentication logic in the OpenSearch client initialization.
  • Specific handling for AWS OpenSearch Serverless (AOSS) when adding documents, as it does not support user-provided document IDs during bulk indexing.
  • Updates to environment variable examples (.env.example) and docker-compose.yaml.
  • Addition of a test case for the new AWS IAM authentication method.

Closes #14886
Closes #14849

Implemented based on the official guide: https://github.com/opensearch-project/opensearch-py/blob/main/guides/auth.md

Screenshots

image image image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/18963 **State:** closed **Merged:** Yes --- # Summary This PR introduces support for connecting to AWS Managed OpenSearch clusters and OpenSearch Serverless (AOSS) using AWS Identity and Access Management (IAM) authentication. This implementation leverages the AWS SigV4 signing process provided by the `opensearch-py` library (`Urllib3AWSV4SignerAuth`), allowing users to configure OpenSearch vector databases without relying on basic username/password authentication, and instead use AWS IAM roles and policies for secure access. Key changes include: - Addition of new configuration options: `OPENSEARCH_AUTH_METHOD`, `OPENSEARCH_AWS_REGION`, and `OPENSEARCH_AWS_SERVICE`. - Integration of AWS SigV4 authentication logic in the OpenSearch client initialization. - Specific handling for AWS OpenSearch Serverless (AOSS) when adding documents, as it does not support user-provided document IDs during bulk indexing. - Updates to environment variable examples (`.env.example`) and `docker-compose.yaml`. - Addition of a test case for the new AWS IAM authentication method. Closes #14886 Closes #14849 Implemented based on the official guide: https://github.com/opensearch-project/opensearch-py/blob/main/guides/auth.md # Screenshots <img width="649" alt="image" src="https://github.com/user-attachments/assets/15f5b06d-084b-4e99-8f52-236d5ed5c7d0" /> <img width="831" alt="image" src="https://github.com/user-attachments/assets/48270cd3-706d-4fca-ba1e-a46c658ed14d" /> <img width="1660" alt="image" src="https://github.com/user-attachments/assets/2be45546-23d0-44bb-a8a2-eaf5b2b6c0d7" /> # Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [ ] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:44:46 -05:00
yindo closed this issue 2026-02-21 20:44:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#29046