A cloud engineer is provisioning a high-availability Cloud SQL for MySQL instance named `prod-mysql-db` within a Virtual Private Cloud (VPC) network named `corporate-vpc`. Corporate security guidelines dictate that the database instance must not have a public IP address, must be accessible exclusively via private IP within the VPC, must provide regional high availability, and must encrypt data at rest using a Customer-Managed Encryption Key (CMEK). Which TWO tasks must be performed to successfully deploy this database configuration?
- Reserve an IP address range in `corporate-vpc` for private service access and establish a VPC peering connection using the Service Networking API.Answer
- Execute `gcloud sql instances create prod-mysql-db --network=corporate-vpc --no-assign-ip --availability-type=REGIONAL --kms-key-name=projects/MY_PROJECT/locations/LOCATION/keyRings/RING/cryptoKeys/KEY`.Answer
- CExecute `gcloud sql instances create prod-mysql-db --assign-ip --authorized-networks=0.0.0.0/0 --availability-type=ZONAL` to establish a secure multi-zone connection.
- DAssign the primitive `roles/owner` role to the default Compute Engine service account to grant Cloud SQL automatic authorization to decrypt the Customer-Managed Encryption Key.
Answer
The correct steps are reserving an internal IP address range in `corporate-vpc` to establish a Private Services Access connection, and running `gcloud sql instances create prod-mysql-db` with `--network=corporate-vpc`, `--no-assign-ip`, `--availability-type=REGIONAL`, and `--kms-key-name`.
To deploy a Cloud SQL instance with Private IP connectivity, you must first create a Private Services Access connection in the target VPC network using the Service Networking API. When creating the Cloud SQL instance via the gcloud CLI, setting `--no-assign-ip` prevents public IP allocation, `--network` binds the instance to the peered VPC, `--availability-type=REGIONAL` configures automatic failover across zones, and `--kms-key-name` specifies the Cloud KMS key for CMEK encryption.
Step-by-Step Solution
Key Concept
Cloud SQL Private IP, High Availability, and Customer-Managed Encryption Keys (CMEK) Configuration