Design, migrate, and run scalable, highly available databases on Google Cloud across relational and NoSQL services, and track your readiness for the Professional Cloud Database Engineer exam.
Prepare and test your skills
Prepare and test your skills
Manage Encryption and Key Lifecycle is the practice of protecting stored database data with customer-controlled keys and moving data with encrypted connections. Customer-Managed Encryption Keys (CMEK) stored in Cloud Key Management Service (KMS) (opens in a new tab) let the customer own the keys that encrypt data at rest, while Google operates the database service that depends on those keys. Mandatory Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protect traffic between applications and databases, so encryption covers both stored data and data in transit.
Protecting data at rest with CMEK means stored data is encrypted with a key in the customer's Cloud KMS key ring instead of a Google-managed key alone. The database service depends on Cloud KMS for every encrypt and decrypt operation, so if the key is disabled, destroyed, or its permission is revoked, the database cannot read its own stored data. Enforcement checks that resource metadata references the customer key, which creates an ownership boundary where the customer controls access and the database controls use.
CMEK is applied at creation time to specific data scopes. The following resources each have a different enforcement point:
| Database resource | What CMEK protects | Enforcement point |
|---|---|---|
| AlloyDB cluster | Cluster data at rest | Cluster configuration must reference a Cloud KMS key |
| Cloud SQL instance | Data written to databases, including standard and enhanced backups | kmsKeyName field in the diskEncryptionKey object in instance metadata |
| Database Migration Service migration | Data written to the destination database during homogeneous and heterogeneous migrations | Destination database must be created with CMEK |
A Cloud SQL instance cannot be switched to CMEK after creation. To add CMEK, first create a new instance with CMEK enabled, then move the data over, and only after that delete the original instance.
Managing the Cloud KMS key lifecycle means controlling how each key is generated, shared, stored, used, and retired under policy. Key-management policies require strong generation with an approved algorithm and protection level, secure distribution to services that need the key, and restricted access to the fewest custodians necessary. The system must also track all cryptographic material in compatible database services (opens in a new tab) and report changes in key status over time.
The lifecycle moves through ordered states:
Secret and private keys must remain in protected form at all times:
Exam tip: A Cloud SQL instance cannot gain CMEK after creation — create a new CMEK-enabled instance and migrate data — while SSL for connections can be enforced on an existing instance.
Enforcing SSL and TLS for data in transit means every application-to-database connection must negotiate an encrypted session before data flows. Traffic flows from the database client across the network boundary to the database server, and the server accepts the connection only when both sides agree on a secure protocol version and valid credentials. Controls for AlloyDB and other databases require SSL encryption on the instance and enforce SSL for all incoming database connections.
The in-transit policy requires TLS 1.2 or higher and blocks fallback to insecure versions, algorithms, key sizes, or implementations. Only trusted keys and certificates are accepted, and each certificate must be confirmed as valid with no expiration or revocation. Restricting legacy TLS versions and insecure SSL policies keeps the trust boundary strong, so account data and other sensitive fields stay protected while moving over open or public networks.
Private connectivity and network isolation means giving a Cloud SQL (opens in a new tab) instance a private IP address inside a Virtual Private Cloud (VPC) so traffic stays on Google's internal network. Private Service Access (opens in a new tab) connects the customer's VPC network to Google's managed service network for Cloud SQL. The result is internal-only communication where applications and databases reach each other by private address, even across regions, with reduced public exposure.
Private Service Access is a private connection that relies on VPC Network Peering implemented internally by Google Cloud. The customer does not create the peering explicitly, but after the connection is created its underlying peering appears on the VPC Network Peering page. Traffic flows from resources in the customer VPC network to internal IP addresses of Cloud SQL resources in the Google-managed VPC network, and the boundary sits between those two peered networks. Private IP connections work across regions, but they do not work from legacy networks because legacy networks do not support VPC Network Peering or Private Service Access.
Setting up a new project for private IP requires an ordered network foundation before instance creation, otherwise creation fails with SERVICE_NETWORKING_NOT_ENABLED or NETWORK_NOT_PEERED:
sqladmin.googleapis.com, compute.googleapis.com, and servicenetworking.googleapis.com in the project.VPC_PEERING, commonly with --prefix-length=16, on the selected VPC network.servicenetworking.googleapis.com using the allocated range.If Cloud SQL allocates the private range automatically, addresses for later instances in the same VPC network come from the same range. Each project has an internal limit on network-region combinations that can use Private Service Access, so reusing existing available networks helps avoid that limit.
Multiple-VPC connectivity is the problem of reaching one private Cloud SQL instance from more than one VPC network despite non-transitive peering. VPC Network Peering is not transitive, so routes are only shared between the two directly peered VPCs and a third VPC cannot use the original VPC's connection to reach Cloud SQL. The connection allows internal addresses to cross two VPC networks whether they belong to the same project or organization, but that trust does not extend further.
To connect a Cloud SQL instance to multiple VPCs with private addresses, use one of these documented patterns:
Shared VPC extends the same private model across host and service projects in an organization. A new Cloud SQL instance can be created with a private IP address in a Shared VPC network, where the service project owns the instance and the host project owns the network. However, an existing Cloud SQL instance cannot later be assigned a private IP address in a Shared VPC network.
Private IP lifecycle rules define what can and cannot change after private connectivity is enabled on a Cloud SQL instance. A Cloud SQL instance can be configured for private IP at creation time or added to an existing instance, and public IP and private IP can be enabled together without affecting each other. Configuring an existing instance for private IP, or changing its connected network, restarts the instance and causes a few minutes of downtime.
Long-term operation is controlled by the following constraints:
Secure connection paths describe where the database client must run so private traffic never leaves the VPC boundary. Direct private connections and proxy-based connections both depend on the client having access to the same VPC network as the Cloud SQL instance. Serverless VPC Access provides a separate serverless path where supported serverless sources reach the instance directly without the proxy.
| Connection path | Where the client runs | Requirement to stay private |
|---|---|---|
| Direct private IP | Compute resource inside the same peered VPC network | Client uses the instance private IP within the VPC boundary |
| Cloud SQL Auth Proxy | Proxy process on a resource with access to the same VPC network as the instance | Start the proxy with -ip_address_types=PRIVATE when both public and private IP are enabled |
| Serverless VPC Access | App Engine standard environment, Cloud Run, or Cloud Run functions | Application connects directly through Serverless VPC Access without the Cloud SQL Auth Proxy |
The Cloud SQL Auth Proxy path depends on placement and address selection because the proxy defaults to public IP when an instance has both IP types. Traffic flows from the application to the local proxy, then from the proxy to the instance private IP inside the peered VPC network, but only when the proxy host can reach that VPC and the private-only flag is supplied.
Exam tip: When a Cloud SQL instance has both public and private IP, the Cloud SQL Auth Proxy defaults to public IP unless it is started with -ip_address_types=PRIVATE.
Enforce identity and perimeter security means combining who can act with where data can move. Identity and Access Management (IAM) (opens in a new tab) controls which users and service accounts can use database resources, while VPC Service Controls (opens in a new tab) and firewall rules define network boundaries that keep data from leaving trusted projects. Together these controls apply least privilege and mitigate data exfiltration for cloud databases.
Identity and Access Management (IAM) is the system that governs who can access resources inside a security boundary, even when the request already comes from inside the perimeter. Least privilege means granting only the roles a user or service account needs to complete a task, at the smallest scope such as a project, instance, or dataset. Administrators setting up perimeters need specific IAM roles for administering VPC Service Controls, and all database users should have unused or excessive roles removed through role recommendations.
Strong credential practices support least privilege by reducing what a compromised identity can do. Organization policy constraints constraints/iam.disableServiceAccountKeyCreation and constraints/iam.disableServiceAccountKeyUpload block creation and upload of long-lived service account keys, with preference for short-lived credentials and more secure authentication alternatives. For remote server access, OS Login with 2-Step Verification requires SSH to Compute Engine to reauthenticate with a password or security key, so an attacker with stolen OAuth tokens but without the second factor is blocked before reaching database hosts.
VPC Service Controls is a resource-centric control that creates a service perimeter around explicitly specified Google Cloud projects and services to mitigate data exfiltration. Once a database project is inside a perimeter, its protected APIs will deny requests that cross the perimeter boundary unless an explicit exception allows them. The control applies to all user identities and service account identities, which makes it different from user-only controls that evaluate device or user conditions.
Securing a database project with VPC Service Controls follows an ordered workflow:
Restricted services are the APIs protected by a service perimeter, and data flows from the database to those services only when the services are inside the same boundary. To mitigate exfiltration from Database Center, the perimeter must restrict the Database Center API, Compute Engine API, Cloud Storage API, Container Registry API, Certificate Authority Service API, and Cloud KMS API. Adding databasecenter.googleapis.com as a restricted service protects the Database Center API, and the same principle applies to analytics services where both the API and its data sources must be protected. For example, protecting the Conversational Analytics API requires protecting geminidataanalytics.googleapis.com plus its sources such as bigquery.googleapis.com in the same perimeter.
Access levels are optional exceptions that permit external access to protected resources inside a perimeter when specific conditions are met. An access level applies only to requests for protected resources coming from outside the service perimeter, such as an administrator connecting from an approved network or device. A request that uses compromised credentials but does not meet the defined IP, device, or certificate conditions is rejected at the boundary. User-centric controls such as Chrome Enterprise Premium complement this model by evaluating attributes like IP-based access or certificate-based mutual TLS on every API request for user identities.
Exam tip: Access levels allow requests from outside a perimeter to reach protected resources inside, but they cannot give resources or VMs inside the perimeter permission to access data outside.
Firewall rules (opens in a new tab) are network controls that allow or deny traffic to database servers and ports, and they form the first line of defense alongside intrusion detection and prevention. Firewalls enforce default-deny as the initial posture, so only explicitly allowed traffic can reach the system and unintentional access or leakage is prevented. Inside isolated environments, physically separate networks further divide duties, with an out-of-band management network for hardware administration accessible only to infrastructure operators and a data plane network for workload traffic. Private Google Access through restricted.googleapis.com keeps API traffic to Google services on the private path instead of the public internet.
With data exfiltration protection enabled, default policies deny broad movement by design:
When protection is disabled, outbound traffic to all destinations is allowed, so explicit egress policies are required to restrict it. Database hardening extends this approach to individual ports by blocking generic access from all IP addresses to database ports for MySQL, PostgreSQL, Oracle Database, MongoDB, Cassandra, and Redis, to access ports for SSH, RDP, Telnet, FTP, SMTP, POP3, HTTP, DNS, LDAP, and directory services, and to overly permissive firewall rules and external IP access on Compute Engine VM instances.
-ip_address_types=PRIVATE.Last updated