Question

Difficulty: MediumDeploying and Configuring Managed Database Instances

You need to provision a secure Cloud SQL for PostgreSQL instance that communicates exclusively via Private IP within an existing custom Virtual Private Cloud (VPC) network named `prod-vpc`. Sequence the following deployment steps in the correct chronological order from first to last.

  1. 1Reserve an internal IP address range in `prod-vpc` for service producer networking using `gcloud compute addresses create`.
  2. 2Establish a Private Service Access connection between `prod-vpc` and `servicenetworking.googleapis.com` using `gcloud services vpc-peerings connect`.
  3. 3Deploy the Cloud SQL instance using `gcloud sql instances create` with `--network=prod-vpc` and `--no-assign-ip`.
  4. 4Configure initial database user accounts on the instance using `gcloud sql users create`.

Answer

The correct sequence is: 1. Reserve internal IP address range in prod-vpc -> 2. Establish Private Service Access connection -> 3. Deploy Cloud SQL instance with --network=prod-vpc and --no-assign-ip -> 4. Configure database user accounts.
Provisioning a Private IP Cloud SQL instance requires a specific prerequisite chain: first allocating an internal IP range in the VPC network (`gcloud compute addresses create`), second establishing a Private Service Access peering connection (`gcloud services vpc-peerings connect`), third creating the instance linked to the VPC network with public IP disabled (`gcloud sql instances create`), and finally setting up database users on the running instance (`gcloud sql users create`).

Step-by-Step Solution

1
Allocate an IP range for Private Service Access
A named IP range is reserved within the VPC for Google service producer peering.
Cloud SQL Private IP relies on Private Service Access, which requires a pre-allocated IP range.
2
Create VPC Peering connection
The customer VPC network is peered with Google's Service Networking tenant network.
Without active VPC Peering to servicenetworking.googleapis.com, Cloud SQL cannot attach internal IP endpoints.
3
Create Cloud SQL instance attached to VPC
The instance is provisioned with a private IP address and no public IP assigned.
The flags --network=prod-vpc and --no-assign-ip enforce private network attachment and prevent public Internet exposure.
4
Create database user accounts
Application user accounts are initialized on the running instance.
Database user configuration requires an active, running Cloud SQL instance target.

Key Concept

Sequence of setup tasks for Cloud SQL Private IP provisioning via Private Service Access
Rate this question