An enterprise platform engineering team is setting up an automated Terraform provisioning pipeline for a production Cloud SQL for PostgreSQL database. Security and networking policies require that the database must utilize Customer-Managed Encryption Keys (CMEK), be accessible strictly via private IP over Private Services Access, and enforce IAM database authentication. To ensure an automated execution without resource dependency deadlocks or authorization failures, in what chronological order must these deployment steps be executed?
- 1Create the Cloud KMS KeyRing and CryptoKey in the target region, and grant the Cloud SQL Service Agent identity the Cloud KMS CryptoKey Encrypter/Decrypter IAM role.
- 2Allocate a named internal IP address range in the Virtual Private Cloud (VPC) network and create a Private Services Access connection to Google Managed Services.
- 3Provision the Cloud SQL for PostgreSQL instance configured with private IP networking, the CMEK key reference, and IAM database authentication enabled.
- 4Provision target database schemas and create IAM-authenticated database user accounts within the active instance.
Answer
The correct sequence for provisioning Cloud SQL with CMEK and Private Services Access is: 1) Create the Cloud KMS key and grant the Encrypter/Decrypter role to the Cloud SQL Service Agent; 2) Reserve an IP range and configure Private Services Access in the VPC; 3) Provision the Cloud SQL instance with private IP, CMEK reference, and IAM authentication; 4) Create database schemas and IAM database users.
Provisioning Cloud SQL infrastructure with CMEK and private connectivity requires strict adherence to foundational dependency chains. First, key permissions must be assigned to the Cloud SQL Service Agent (`[email protected]`) so GCP can access the CMEK key. Second, Private Services Access peering must be established in the VPC network so Cloud SQL can allocate internal IP addresses in the producer network. Third, the Cloud SQL instance is provisioned referencing the CMEK key and private network. Finally, database schemas and IAM database users are created inside the initialized database instance.
Step-by-Step Solution
Key Concept
Cloud SQL Provisioning Dependency Sequencing