<br />

Connection profiles capture identifiers and connection credentials for your source databases.
Each connection profile contains the minimum required amount of information Database Migration Service needs
to facilitate data movement between the data source and destination.

To create a source connection profile, follow these steps:

### Console

1. Go to the [Connection Profiles](https://console.cloud.google.com/dbmigration/connection-profiles) page in the Google Cloud console.
2. Click **Create profile**.
3. On the **Create a connection profile** page, from the **Profile role** list, select **Source**.
4. From the **Database engine** list, select your source database engine.

   > [!NOTE]
   > If you select **Cloud SQL for PostgreSQL** from this list, then an **Instance ID** list appears. Select the ID of the Cloud SQL for PostgreSQL instance that you want to migrate.

5. In the **Connection profile name** field, enter a human-readable name for your connection profile. This value is displayed in the connection profile list.
6. Keep the auto-generated **Connection profile ID**.
7. Enter a **Hostname** or **IP address** .
   - The value you use here depends on the connectivity method you
     use for your migration. For example, if the source database is
     hosted in Google Cloud, or if a reverse SSH
     tunnel is used to connect the destination cluster to the source database,
     then specify the private (internal) IP address for the source database.
     For more information, see
     [Network connectivity overview](https://docs.cloud.google.com/database-migration/docs/postgresql-to-alloydb/networking-methods.md.txt).

   - For migrations that connect over the public internet by using an IP allowlist, provide the public IP address of the source database.
8. Enter the **Port** that's used to access the host. The default PostgreSQL port is 5432.
9. Enter a username and password for the source database. The user must have the required replication privileges on your source database. For more information, see [Configure source database](https://docs.cloud.google.com/database-migration/docs/postgresql-to-alloydb/configure-source-database.md.txt).
10. In the **Connection profile region** section of the page, select the region where you want to save the connection profile.

    > [!NOTE]
    > Connection profiles, like all resources, are saved in a region. Region selection doesn't impact which migration jobs can use them, or which regions can connect to the data location itself, but can impact availability in the case of regional downtime.

11. Optional: If the connection is made over a public network
    (by using IP allowlists), then we recommend that you configure SSL/TLS
    encryption for the connection between the source and destination databases.

    In the **Secure your connection** section, select one of the following SSL/TLS configuration options:
    - **None**: The AlloyDB for PostgreSQL destination cluster connects to the source database without encryption.
    - **TLS** authentication: When the AlloyDB for PostgreSQL destination cluster connects to the source database, the cluster authenticates the source, ensuring that the cluster is connecting to the correct host securely. To use TLS authentication, you must provide the x509 PEM-encoded certificate of the CA that signed the source server's certificate.
    - **mTLS** authentication: When the destination cluster connects to the source, the cluster authenticates the source and the source authenticates the cluster. To use mTLS authentication, you must provide:
      - The certificate of the CA that signed the source database server's certificate (the CA certificate).
      - The certificate used by the cluster to authenticate against the source database server (the client certificate).
      - The private key associated with the client certificate (the client key).

    > [!NOTE]
    > For more information about creating certificates and keys for your PostgreSQL server, see [Secure TCP/IP Connections with SSL](https://www.postgresql.org/docs/current/ssl-tcp.html).

12. Click **Create**.

    The **Connection profiles** page appears, and the newly created connection profile is displayed.

### gcloud


This sample uses the optional `--no-async` flag so that all operations
are performed synchronously. This means that some commands might take
a while to complete. You can skip the `--no-async` flag to run commands asynchronously.
If you do, you need to use the
[`gcloud database-migration operations describe`](https://docs.cloud.google.com/sdk/gcloud/reference/database-migration/operations/describe.md.txt) command to verify if your operation
is successful.


Before using any of the command data below,
make the following replacements:

- <var class="edit" scope="SOURCE_CONN_ID" translate="no">SOURCE_CONN_ID</var> with your source connection profile identifier.
- <var class="edit" scope="REGION" translate="no">REGION</var> with the region where you want to save the connection profile.
- <var class="edit" scope="SOURCE_IP_ADDRESS" translate="no">SOURCE_IP_ADDRESS</var> with the IP address of your source database.
- <var class="edit" scope="SOURCE_PORT" translate="no">SOURCE_PORT</var> with the port of your source database (default is 5432).
- <var class="edit" scope="SOURCE_USER" translate="no">SOURCE_USER</var> with the username of the migration user on your source database.
- <var class="edit" scope="SOURCE_PASSWORD" translate="no">SOURCE_PASSWORD</var> with the password of the migration user on your source database.
- Optional: To configure additional source connection profile settings, you can pass the following flags:
  - `--display-name`: A human-readable name for the connection profile.
  - `--cloudsql-instance`: The ID of your source Cloud SQL for PostgreSQL instance, if your source is Cloud SQL for PostgreSQL.
  - `--ssl-type`: The SSL/TLS encryption type for the connection to the source database (`NONE`, `SERVER_ONLY` for TLS authentication with `--ca-certificate`, or `SERVER_CLIENT` for mTLS authentication with `--ca-certificate`, `--client-certificate`, and `--private-key`).


Execute the

following

command:

#### Linux, macOS, or Cloud Shell

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud database-migration connection-profiles create postgresql \
  SOURCE_CONN_ID \
  --region=REGION \
  --role=SOURCE \
  --host=SOURCE_IP_ADDRESS \
  --port=SOURCE_PORT \
  --username=SOURCE_USER \
  --password=SOURCE_PASSWORD \
  --no-async
```

#### Windows (PowerShell)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud database-migration connection-profiles create postgresql `
  SOURCE_CONN_ID `
  --region=REGION `
  --role=SOURCE `
  --host=SOURCE_IP_ADDRESS `
  --port=SOURCE_PORT `
  --username=SOURCE_USER `
  --password=SOURCE_PASSWORD `
  --no-async
```

#### Windows (cmd.exe)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud database-migration connection-profiles create postgresql ^
  SOURCE_CONN_ID ^
  --region=REGION ^
  --role=SOURCE ^
  --host=SOURCE_IP_ADDRESS ^
  --port=SOURCE_PORT ^
  --username=SOURCE_USER ^
  --password=SOURCE_PASSWORD ^
  --no-async
```

You should receive a response similar to the following:

```
Waiting for connection profile [SOURCE_CONN_ID]
to be created with [OPERATION_ID]

Waiting for operation [OPERATION_ID] to complete...done.

Created connection profile SOURCE_CONN_ID [OPERATION_ID]
```

<br />

## What's next

- [Manage connection profiles](https://docs.cloud.google.com/database-migration/docs/postgresql-to-alloydb/manage-connection-profiles.md.txt)