This repository was archived by the owner on May 23, 2025. It is now read-only.

Description
Description:
I tried to use IAM-Role authentication, and I think you missed the part of
session = boto3.Session() credentials = session.get_credentials()
before the initialization of
aws_region = os.getenv("AWS_REGION", "") aws_access_key = os.getenv("AWS_ACCESS_KEY", "") aws_secret_access_key = os.getenv("AWS_SECRET_ACCESS_KEY", "") aws_session_token = os.getenv("AWS_SESSION_TOKEN", "")
It seems like the code "forces" you to put the variables as ENV variables rather than pulling them from the role itself.
This is how I implemented it to make it work with role-based auth:
session = boto3.Session() credentials = session.get_credentials() opensearch_url = "https://xxx.amazon.com" aws_region = "eu-west-1" aws_access_key = credentials.access_key aws_secret_access_key = credentials.secret_key aws_session_token = credentials.token