
## Set up AlloyDB for PostgreSQL

URL: https://docs.atlan.com/apps/connectors/database/alloydb/postgresql/how-tos/set-up-alloydb-postgresql

> Configure authentication and connection settings for AlloyDB for PostgreSQL connector

Configure authentication and connection settings for your AlloyDB (PostgreSQL) cluster to enable Atlan to crawl metadata and establish a secure connection.

## Prerequisites

Before you begin, make sure you have:
* AlloyDB for PostgreSQL cluster and instance running in Google Cloud
* Database administrator access to create users and grant permissions
* Ability to run setup statements for each database and schema you want to crawl

## Configure authentication

Choose the authentication method that best fits your security requirements and infrastructure setup.

### Built-in authentication

Create a username and password as described in the [AlloyDB documentation for managing users and roles](https://docs.cloud.google.com/alloydb/docs/database-users/manage-roles).

### Identity and access management (IAM) authentication

To use IAM database authentication (supported via the AlloyDB Auth Proxy or connectors):

1. [Enable IAM database authentication](https://docs.cloud.google.com/alloydb/docs/database-users/manage-iam-auth#enable) for your AlloyDB instance.
2. Add an IAM user or service account and provide necessary roles (for example, roles that permit generating database auth tokens) as described in the [AlloyDB IAM authentication documentation](https://docs.cloud.google.com/alloydb/docs/database-users/manage-iam-auth).

## Create database role

Create a dedicated role for Atlan and grant the necessary permissions to crawl metadata from your AlloyDB instance.

1. Connect to your database instance (for example, using `psql` through the AlloyDB connectors or proxy) and run the following command to create the role:

 ```sql
 CREATE ROLE atlan_user_role;
 ```
2. To crawl metadata from AlloyDB (PostgreSQL), Atlan requires `USAGE` privileges on the schemas. This permission enables Atlan to access schema objects and fetch technical metadata from the `INFORMATION_SCHEMA`.

 ```sql
 GRANT USAGE ON SCHEMA <schema> TO atlan_user_role;
 ```
 - Replace `<schema>` with the schema name to grant access. Repeat the `GRANT` statement for each additional schema you want Atlan to crawl.

3. To preview and query data within Atlan's Data Exploration module, grant `SELECT` privilege:

 ```sql
 GRANT SELECT, REFERENCES ON ALL TABLES IN SCHEMA schema_name TO atlan_user_role;
 ```

 - Replace `schema_name` with the name of the schema you want Atlan to access.
 - Replace `atlan_user_role` with the role assigned to Atlan in your database.

## Assign role to users

After you create the user (built-in or IAM-based) and the database role, assign the role to the user:

```sql
GRANT atlan_user_role TO <username>;
```

- Replace `<username>` with the username you want to assign roles to.

## Next steps

* [Crawl AlloyDB for PostgreSQL assets](https://docs.atlan.com/llms/connectors/alloydb-postgresql/crawl-alloydb-postgresql/llms.txt): Extract metadata from your AlloyDB for PostgreSQL database and establish a connection between Atlan and your database

---
