awswrangler.opensearch.connect(host: str, port: int | None = 443, boto3_session: Session | None = None, region: str | None = None, username: str | None = None, password: str | None = None, service: str | None = None, timeout: int = 30, max_retries: int = 5, retry_on_timeout: bool = True, retry_on_status: Sequence[int] | None = None) opensearchpy.OpenSearch

Create a secure connection to the specified Amazon OpenSearch domain.


We use opensearch-py, an OpenSearch python client.

The username and password are mandatory if the OS Cluster uses Fine Grained Access Control. If fine grained access control is disabled, session access key and secret keys are used.

  • host (str) – Amazon OpenSearch domain, for example:

  • port (int) – OpenSearch Service only accepts connections over port 80 (HTTP) or 443 (HTTPS)

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 Session will be used if boto3_session receive None.

  • region (str, optional) – AWS region of the Amazon OS domain. If not provided will be extracted from boto3_session.

  • username (str, optional) – Fine-grained access control username. Mandatory if OS Cluster uses Fine Grained Access Control.

  • password (str, optional) – Fine-grained access control password. Mandatory if OS Cluster uses Fine Grained Access Control.

  • service (str, optional) – Service id. Supported values are es, corresponding to opensearch cluster, and aoss for serverless opensearch. By default, service will be parsed from the host URI.

  • timeout (int) – Operation timeout. 30 by default.

  • max_retries (int) – Maximum number of retries before an exception is propagated. 10 by default.

  • retry_on_timeout (bool) – Should timeout trigger a retry on different node. True by default.

  • retry_on_status (List[int], optional) – Set of HTTP status codes on which we should retry on a different node. Defaults to [500, 502, 503, 504].


OpenSearch low-level client.

Return type: