

# Connecting to OpenSearch Service in AWS Glue Studio
<a name="connecting-to-data-opensearch"></a>

 AWS Glue provides built-in support for Amazon OpenSearch Service. AWS Glue Studio provides a visual interface to connect to Amazon OpenSearch Service, author data integration jobs, and run them on the AWS Glue Studio serverless Spark runtime. This feature is not compatible with OpenSearch Service serverless. 

 AWS Glue Studio creates a unified connection for Amazon OpenSearch Service. For more information, see [Considerations](using-connectors-unified-connections.md#using-connectors-unified-connections-considerations). 

**Topics**
+ [Creating a OpenSearch Service connection](creating-opensearch-connection.md)
+ [Creating a OpenSearch Service source node](creating-opensearch-source-node.md)
+ [Creating a OpenSearch Service target node](creating-opensearch-target-node.md)
+ [Advanced options](#creating-opensearch-connection-advanced-options)

# Creating a OpenSearch Service connection
<a name="creating-opensearch-connection"></a>

**Prerequisites**:
+ Identify the domain endpoint, *aosEndpoint* and port, *aosPort* you would like to read from, or create the resource by following instructions in the Amazon OpenSearch Service documentation. For more information on creating a domain, see [Creating and managing Amazon OpenSearch Service domains](https://docs.aws.amazon.com//opensearch-service/latest/developerguide/createupdatedomains.html) in the Amazon OpenSearch Service documentation.

  An Amazon OpenSearch Service domain endpoint will have the following default form, https://search-*domainName*-*unstructuredIdContent*.*region*.es.amazonaws.com. For more information on identifying your domain endpoint, see [Creating and managing Amazon OpenSearch Service domains](https://docs.aws.amazon.com//opensearch-service/latest/developerguide/createupdatedomains.html) in the Amazon OpenSearch Service documentation. 

  Identify or generate HTTP basic authentication credentials, *aosUser* and *aosPassword* for your domain.

**To configure a connection to OpenSearch Service:**

1. In AWS Secrets Manager, create a secret using your OpenSearch Service credentials. To create a secret in Secrets Manager, follow the tutorial available in [ Create an AWS Secrets Manager secret ](https://docs.aws.amazon.com//secretsmanager/latest/userguide/create_secret.html) in the AWS Secrets Manager documentation. After creating the secret, keep the Secret name, *secretName* for the next step. 
   + When selecting **Key/value pairs**, create a pair for the key `USERNAME` with the value *aosUser*.
   + When selecting **Key/value pairs**, create a pair for the key `PASSWORD` with the value *aosPassword*.

1. In the AWS Glue console, create a connection by following the steps in [Adding an AWS Glue connection](console-connections.md). After creating the connection, keep the connection name, *connectionName*, for future use in AWS Glue. 
   + When selecting a **Connection type**, select OpenSearch Service.
   + When selecting a Domain endpoint, provide *aosEndpoint*.
   + When selecting a port, provide *aosPort*.
   + When selecting an **AWS Secret**, provide *secretName*.

# Creating a OpenSearch Service source node
<a name="creating-opensearch-source-node"></a>

## Prerequisites needed
<a name="creating-opensearch-source-node-prerequisites"></a>
+ A AWS Glue OpenSearch Service connection, configured with an AWS Secrets Manager secret, as described in the previous section, [Creating a OpenSearch Service connection](creating-opensearch-connection.md).
+ Appropriate permissions on your job to read the secret used by the connection.
+ A OpenSearch Service index you would like to read from, *aosIndex*.

## Adding a OpenSearch Service data source
<a name="creating-opensearch-source-node-add"></a>

**To add a **Data source – OpenSearch Service** node:**

1.  Choose the connection for your OpenSearch Service data source. Since you have created it, it should be available in the dropdown. If you need to create a connection, choose **Create OpenSearch Service connection**. For more information see the previous section, [Creating a OpenSearch Service connection](creating-opensearch-connection.md). 

    Once you have chosen a connection, you can view the connection properties by clicking **View properties**. 

1. Provide **Index**, the index you would like to read.

1. Optionally, provide **Query**, an OpenSearch query to deliver more specific results. For more information about writing OpenSearch queries, consult [Reading from OpenSearch Service indexes](aws-glue-programming-etl-connect-opensearch-home.md#aws-glue-programming-etl-connect-opensearch-read).

1.  In **Custom OpenSearch Service properties**, enter parameters and values as needed. 

# Creating a OpenSearch Service target node
<a name="creating-opensearch-target-node"></a>

## Prerequisites needed
<a name="creating-opensearch-target-node-prerequisites"></a>
+ A AWS Glue OpenSearch Service connection, configured with an AWS Secrets Manager secret, as described in the previous section, [Creating a OpenSearch Service connection](creating-opensearch-connection.md).
+ Appropriate permissions on your job to read the secret used by the connection.
+ A OpenSearch Service index you would like to write to, *aosIndex*.

## Adding a OpenSearch Service data target
<a name="creating-opensearch-target-node-add"></a>

**To add a **Data target – OpenSearch Service** node:**

1.  Choose the connection for your OpenSearch Service data source. Since you have created it, it should be available in the dropdown. If you need to create a connection, choose **Create OpenSearch Service connection**. For more information see the previous section, [Creating a OpenSearch Service connection](creating-opensearch-connection.md). 

    Once you have chosen a connection, you can view the connection properties by clicking **View properties**. 

1. Provide **Index**, the index you would like to read.

1.  In **Custom OpenSearch Service properties**, enter parameters and values as needed. 

## Advanced options
<a name="creating-opensearch-connection-advanced-options"></a>

You can provide advanced options when creating a OpenSearch Service node. These options are the same as those available when programming AWS Glue for Spark scripts.

See [OpenSearch Service connections](aws-glue-programming-etl-connect-opensearch-home.md). 