In this page, you learn how to use the Database Migration Service API to manage connection profiles for a PostgreSQL source database and a PostgreSQL destination.
There are two ways that you can use the Database Migration Service API. You can make REST API calls or you can use the Google Cloud CLI (CLI).
To see high-level information about using gcloud to manage Database Migration Serviceconnection profiles, click here.
Create a connection profile for a PostgreSQL source database
The following shows a request to create a connection profile for a PostgreSQL source database.
REST
Before using any of the request data, make the following replacements:
project-id: The project ID
region: The project region
connection-profile-id: The connection profile ID
connection-profile-display-name: The connection profile display name
host-ip-address: The source IP address
username: The database user name
password: The database user password
client-key: The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with the Client Certificate. If this field is used then the clientCertificate field is mandatory.
client-certificate: The x509 PEM-encoded certificate that will be used by the replica to authenticate against the source database server.If this field is used then the clientKey field is mandatory.
ca-certificate: Required. The x509 PEM-encoded certificate of the CA that signed the source database server's certificate. The replica will use this certificate to verify it's connecting to the right host.
HTTP method and URL:
POST https://datamigration.googleapis.com/v1/projects/project-id/locations/region/connectionProfiles?connectionProfileId=connection-profile-id
For more information on using gcloud to retrieve information about your connection profile, click here.
Create a connection profile for a Cloud SQL for PostgreSQL source database
The following shows a request to create a connection profile for a Cloud SQL for PostgreSQL source database. This example uses a PostgreSQL connection profile because it connects to the PostgreSQL database engine, and not the Cloud SQL management layer.
To create the pairing between the source and replica using Cloud SQL, you must provide the instance ID for your Cloud SQL database. You can find the instance ID value by using the databases/list method of the Cloud SQL Admin API.
REST
Before using any of the request data, make the following replacements:
project-id: The project ID
region: The project region
connection-profile-id: The connection profile ID
connection-profile-display-name: The connection profile display name
host-ip-address: The source IP address
username: The database user name
password: The database user password
cloud-sql-instance-id: The Cloud SQL instance ID
HTTP method and URL:
POST https://datamigration.googleapis.com/v1/projects/project-id/locations/region/connectionProfiles?connectionProfileId=connection-profile-id
To see high-level information about using gcloud to create Database Migration Service connection profiles, click here.
For more information on using gcloud to create a connection profile for a Cloud SQL for PostgreSQL source database, click here.
Create a connection profile for Cloud SQL for PostgreSQL destination
The following shows a request to create a connection profile for a Cloud SQL for PostgreSQL destination. Database Migration Service uses the information in this request to create a new Cloud SQL for PostgreSQL instance.
REST
Before using any of the request data, make the following replacements:
project-id: The project ID
region: The project region
connection-profile-id: The connection profile ID
connection-profile-display-name: The connection profile display name
database-version: The database version. For example, POSTGRES_12.
tier: The machine type. For example, db-custom-1-4096.
data-disk-type: The data disk type. For example, PD_SSD.
data-disk-size-gb: The data disk size, in Gb. For example, 20.
zone: The zone in the project region
cmek_key_name: Optional: The full path and name of a customer-managed encryption key (CMEK). For example, "projects/project-id/locations/location/keyRings/ring/cryptoKeys/customer-managed-encryption-key".
All data stored within Google Cloud is encrypted at rest using the same hardened key management systems that we use for our own encrypted data. These key-management systems provide strict key access controls and auditing, and encrypt user data at rest using AES-256 encryption standards. No setup, configuration, or management is required. Google Cloud's default encryption at rest is the best choice for users who don't have specific requirements related to compliance or locality of cryptographic material.
If you need more control over the keys used to encrypt data at rest within a Google Cloud project, then Database Migration Service offers the ability to protect your data using encryption keys managed by you within Cloud Key Management Service (KMS). These encryption keys are called customer-managed encryption keys (CMEK). When you protect data in Database Migration Service with CMEK, the CMEK is within your control.
The cmek_key_name parameter is associated with having a CMEK that Database Migration Service can use to encrypt data that's migrated from the source to the destination. The CMEK is represented by the customer-managed-encryption-key placeholder.
The ring placeholder represents the key ring for your CMEK. A key ring organizes keys in a specific Google Cloud location and allows you to manage access control on groups of keys. A key ring's name doesn't need to be unique across a Google Cloud project, but must be unique within a given location. For more information about key rings, see Cloud KMS resources.
As part of creating the connection profile, Database Migration Service will verify that the CMEK exists, and that Database Migration Service has permissions to use the key.
If either of these conditions aren't met, then the following error message will be returned:
CMEK_DOES_NOT_EXIST_OR_MISSING_PERMISSIONS
To resolve this issue, verify that the key that you provided exists, and that the Database Migration Service service account has the cloudkms.cryptoKeys.get permission for the key.
If you prefer to use Google Cloud's internal key management system instead of a CMEK to encrypt your data, then don't include the cmek_key_name parameter and value in your API request.
HTTP method and URL:
POST https://datamigration.googleapis.com/v1/projects/project-id/locations/region/connectionProfiles?connectionProfileId=connection-profile-id
For more information on using gcloud to retrieve information about your connection profile, click here.
List connection profiles
The following shows a request to retrieve information about all of your connection profiles.
REST
Before using any of the request data, make the following replacements:
project-id: The project ID
region: The project region
You can also filter the list of connection profiles that Database Migration Service retrieves, as follows:
orderBy: Use this filter to retrieve a listing of all connection profiles for a particular region in alphabetical order. For example, the orderBy=name filter returns all connection profiles, alphabetically, by name.
pageSize: Use this filter to specify the maximum number of connection profiles that Database Migration Service retrieves and displays on a page. For example, by setting pageSize=10, Database Migration Service will return up to 10 connection profiles for a page.
If there are more than 10 connection profiles, then they appear on other pages. At the end of each page, a nextPageToken parameter and unique identifier appear. Use the identifier to retrieve the listing of the connection profiles for the following page.
HTTP method and URL:
GET https://datamigration.googleapis.com/v1/projects/project-id/locations/region/connectionProfiles
To send your request, expand one of these options:
For more information on using gcloud to retrieve information about all of your connection profiles, click here.
Update a connection profile
The following shows a request to update the username and password fields of an existing connection profile. By using the updateMask parameter in the request, only these fields need to be included in the request body.
REST
Before using any of the request data, make the following replacements:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-17 UTC."],[[["This page explains how to manage connection profiles for PostgreSQL source and destination databases using the Database Migration Service API, which can be done via REST API calls or the Google Cloud CLI."],["You can create connection profiles for a PostgreSQL source database, including those on Cloud SQL, by providing necessary details such as project ID, region, IP address, username, and password, along with optional SSL settings or the Cloud SQL instance ID."],["Creating a connection profile for a Cloud SQL for PostgreSQL destination involves specifying database version, machine type, disk type and size, zone, and optionally, customer-managed encryption key (CMEK) information."],["You can retrieve information about a single connection profile or list all connection profiles within a specified project and region, with options to filter and order the results."],["Existing connection profiles can be updated, such as changing the username and password, or they can be deleted, provided no active migration jobs are associated with them, and you can also force delete the connection profile, along with the associated Cloud SQL instance."]]],[]]