Skip to main content

Set up a PostgreSQL database on GCP

This guide explains how to configure a PostgreSQL database on GCP for use with an Ascend Instance.

Prerequisites​

Before you begin, ensure you have:

Create a PostgreSQL instance on GCP​

  1. Set your project and enable required APIs:

    export PROJECT_ID=<YOUR-PROJECT-ID>
    gcloud config set project $PROJECT_ID
    gcloud services enable sqladmin.googleapis.com
  2. Create a Cloud SQL PostgreSQL instance:

    gcloud sql instances create ascend-instance \
    --database-version=POSTGRES_15 \
    --tier=db-f1-micro \
    --region=us-central1 \
    --storage-type=SSD \
    --storage-size=10GB \
    --storage-auto-increase \
    --backup-start-time=03:00 \
    --maintenance-window-day=SUN \
    --maintenance-window-hour=04 \
    --edition=ENTERPRISE
    info

    This command creates a Cloud SQL Enterprise edition instance running PostgreSQL 15. The creation process typically takes 3-5 minutes, so don't worry if the command appears to hang.

    The instance receives a public IP address by default but has no authorized networks, making it inaccessible from the internet until you configure access in a later step.

    Since Instance Stores handle minimal query loads, we recommend starting with the smallest compute size (db-f1-micro). This tier uses shared CPU resources, making it cost-effective for light workloads, though performance may vary. You can scale up to dedicated CPU tiers later if needed.

  3. Set a password for the default postgres user:

    gcloud sql users set-password postgres \
    --instance=ascend-instance \
    --password=<YOUR-SECURE-PASSWORD>
  4. Configure network access by adding Ascend's egress IP addresses to your PostgreSQL instance's authorized networks:

    gcloud sql instances patch ascend-instance \
    --authorized-networks=52.205.57.63,44.217.175.189,44.217.47.213,54.173.192.81,3.227.46.125
  5. Retrieve the hostname IP for your Instance Store configuration:

    echo "=== Instance Host IP Address ==="
    INSTANCE_IP=$(gcloud sql instances describe ascend-instance --format='value(ipAddresses[0].ipAddress)')
    echo $INSTANCE_IP

🎉 Congratulations! You've successfully set up a PostgreSQL instance on GCP!

Next steps​

Set up your Instance Store to connect your Ascend Instance to PostgreSQL.