Prepare and test your skills
Prepare and test your skills
Manage Cryptographic Key Lifecycles and Access Control is the practice of creating, rotating, and destroying encryption keys in Cloud Key Management Service while giving identities access to only the keys they need. Cloud Key Management Service holds the customer-managed encryption key separately from the service that stores the data, so a service such as Cloud Storage stores only encrypted data while Cloud Key Management Service performs encrypt and decrypt operations. The lifecycle moves in order from project setup to ring and key creation to access grants to rotation and eventual destruction.
Key hierarchy in Cloud Key Management Service organizes keys inside a key ring that lives in a specific location. A key ring groups keys for the same location and application, and each crypto key inside the ring defines its purpose, such as encryption, and its protection level, such as hsm or hsm_single_tenant. The key resource name connects the data service to Cloud Key Management Service because traffic flows from the data service to Cloud Key Management Service for cryptographic operations. Using a dedicated project that holds only keys creates a clear trust boundary between key administrators and workload owners and simplifies billing.
Creation follows a fixed dependency order where the project and API must exist before the ring and key can exist:
gcloud kms keyrings create.gcloud kms keys create, setting purpose, protection level, and rotation schedule.Automated rotation in Cloud Key Management Service replaces the active key version on a schedule so one key version does not protect data forever. Rotation is set at creation with --rotation-period, for example 7d, and --next-rotation-time, for example 2024-03-20T01:00:00, and Cloud Key Management Service can continue rotating automatically after that time. A best practice is to rotate after enabling a new protection, such as application-layer secrets encryption for Google Kubernetes Engine, so existing data is re-protected under the managed schedule. Retirement ends the lifecycle when a key is no longer needed, and destroying the key makes data encrypted with it no longer decryptable.
Cloud Key Management Service supports four lifecycle actions for sensitive data such as stored account data: generate, use, rotate, and destroy cryptographic keys. Cloud Key Management Service does not directly store secrets such as cardholder data, but services call it to encrypt that data before storage. Because Google Cloud encrypts customer content at rest by default, customer-managed keys add control over the key lifecycle without replacing that default protection.
Least-privilege access control with Identity and Access Management in Cloud Key Management Service means granting only the encrypt and decrypt permissions a workload needs on only the keys it needs. Permissions can attach at the key level for narrow scope or at the ring or project level for broader scope, so key-level grants limit the impact if an identity is compromised. The console flow selects the key ring, selects the checkbox for the desired key, and adds the member in the Permissions tab, while the command-line flow uses gcloud kms keys add-iam-policy-binding with --member, --role, and --project.
The workload role is CryptoKey Encrypter/Decrypter (roles/cloudkms.cryptoKeyEncrypterDecrypter), which allows a service account to encrypt and decrypt with a specific key. In the Google Kubernetes Engine pattern, the Google Kubernetes Engine service account receives this role on the application-layer encryption key, so requests flow from the Google Kubernetes Engine control plane to Cloud Key Management Service for secret encryption. Another pattern grants the CHGWS key Service Agent role (roles/cloudkmskacls.serviceAgent) to the Cloud HSM for Google Workspace (opens in a new tab) service identity in the key project.
Exam tip: Grant roles/cloudkms.cryptoKeyEncrypterDecrypter on the specific key for workloads such as GKE, rather than a broad project role, to enforce least privilege at the key level.
Hardware protection in Cloud Hardware Security Module (Cloud HSM) (opens in a new tab) means generating keys and performing cryptographic operations inside FIPS 140-2 Level 3 certified hardware security modules. Cloud Hardware Security Module is part of the Cloud Key Management Service architecture and uses Marvell LiquidSecurity HSMs, models CNL3560-NFBE-2.0-G and CNL3560-NFBE-3.0-G with firmware 3.4 build 09 and 10. Google owns and manages the hardware, including deployment, configuration, monitoring, patching, and maintenance, while customer data stays isolated from other tenants and services. Applications reach the hardware through the Cloud Key Management Service data plane API instead of managing HSM clusters directly.
| Option | Tenancy | Management and cost |
|---|---|---|
| Multi-tenant Cloud HSM | Keys housed on HSM clusters that serve multiple Google Cloud customers | Fully managed by Google with automatic scaling, global availability, and support for Cloud KMS Autokey |
| Single-tenant Cloud HSM | Keys housed in dedicated partitions where each partition serves only one customer | Jointly managed between customer instance administrators and Google, with additional cost and availability in a subset of multi-tenant regions |
Hardware keys carry practical limits that affect design. User-provided plaintext and ciphertext, including additional authenticated data, is limited to 8 KiB for Cloud HSM keys compared to 64 KiB for software keys. If a Cloud HSM key is used with customer-managed encryption key integrations in other services, the service location must match the key location exactly across regional, dual-regional, and multi-regional locations. Asymmetric operations in Cloud HSM may have noticeably greater latency than software keys, and Cloud HSM keys depend on sufficient key quota in the key project to avoid service disruption.
Key Access Justifications (opens in a new tab) is the control that attaches a justification code to every cryptographic operation involving an enrolled Cloud Key Management Service key. Key Access Justifications works alongside Access Approval, which lets customers authorize requests from Google personnel to access Customer Data, and Access Transparency, which records when Customer Data is accessed. Key Access Justifications provides key access control for at-rest Customer Data encrypted by a customer-managed key, including visibility when data changes state from at-rest to in-use. Together, Access Approval, Access Transparency, and Key Access Justifications let the customer deny Google the ability to decrypt data.
Available behavior depends on the Assured Workloads control package and key type, which may include Cloud External Key Manager keys, Cloud HSM keys, and Cloud Key Management Service software keys. For select regional packages, Key Access Transparency logs justification codes in Cloud Key Management Service audit logs. For select regional, regulatory, or sovereign packages, customers can set a policy on keys to approve or deny access based on the justification code. For select sovereign packages with supported external key managers, the policy can be configured outside Google Cloud and enforced exclusively by the external key manager rather than by Cloud Key Management Service.
Evaluate Encryption Strategies for Data at Rest and in Transit means choosing the right key-management control for stored data and the right encryption control for moving data. Data at rest is always encrypted by default with layered mechanisms, while customer-managed options add lifecycle control for compliance needs. Data in transit is also encrypted by default inside Google's network, with extra controls available for internet traffic, application traffic, and hybrid connections.
Default encryption at rest (opens in a new tab) means Google Cloud encrypts all customer content stored at rest without any action required from the customer. Customer content is data you provide or generate, such as objects in Cloud Storage buckets, Persistent Disk volumes, and Compute Engine snapshots, while customer metadata such as project numbers, timestamps, and machine types is protected separately for operations. Encryption at rest helps because stolen disks or chunks remain unreadable without keys, trust is removed from lower hardware and software layers, and access can be enforced and audited at one central chokepoint.
The benefits of centrally managed encryption at rest include:
Choose default encryption when there are no special requirements for how data is encrypted or how keys are managed, and when a fully managed service is preferred over the cost of managing keys.
Infrastructure encryption in Google Cloud uses multiple layers that apply redundant protection at the storage system and at the storage device. Data uploaded to Google's infrastructure is broken into logical chunks up to several gigabytes in size, each chunk is encrypted at the storage level with its own data encryption key (DEK) using AES-256, and each chunk is then distributed and replicated in encrypted form for backup and disaster recovery. If a chunk is updated, the storage system encrypts it with a new DEK rather than reusing the old key, so compromise of one DEK affects only that chunk. Storage device encryption adds a second layer with a separate device-level key using AES-256 for hard disk drives and solid-state drives, with the exception of a small number of Persistent Disks created before 2015 and legacy disks that use AES-128.
Envelope encryption is the key-management pattern where DEKs stored near the data they encrypt are wrapped by a key encryption key (KEK) stored centrally in Keystore. Each DEK has a unique chunk identifier, and access control lists allow decryption only by Google services operating with authorized roles granted only at that point in time. The KEKs are not specific to customers; one or more KEKs exist for each service and are held in Keystore, a repository built specifically for storing keys. An attacker would therefore need both all storage chunks for the data and all corresponding encryption keys to recover customer content. Google uses a FIPS 140-2 validated encryption module, certificate 4407, in production for data at rest.
Key-management choice determines who controls key lifecycle, separation, and auditability for storage and compute resources. Cloud Key Management Service (Cloud KMS) (opens in a new tab) lets customers create customer-managed encryption keys (CMEK) that wrap DEKs for supported services, while customer-supplied encryption keys (CSEK) are keys supplied directly by the customer for limited operations such as Compute Engine Persistent Disks. A logical chunk can contain data from multiple customers under default encryption, so logical separation through encryption requires Cloud Key Management Service.
| Option | Who manages keys | Control and compliance difference | Service and enforcement difference |
|---|---|---|---|
| Google-owned and Google-managed keys | Google manages DEKs and KEKs with no configuration | Included at no extra key-management cost; sufficient when there is no requirement to manage key lifecycle | Applies to all services that store customer data |
| Customer-managed encryption keys (CMEK) | Customer manages keys in Cloud KMS, with options for Cloud HSM and Cloud External Key Manager (Cloud EKM) | Supports lifecycle control, rotation reporting for auditors, FIPS 140-2 Level 3 HSM generation, and storing key material outside Google Cloud | Supports broad storage, database, and compute integrations; security teams can block non-compliant resources with CMEK organization policies |
| Customer-supplied encryption keys (CSEK) | Customer supplies and holds keys outside Cloud KMS | Provides direct customer control per operation but without centralized lifecycle, rotation, and policy enforcement | Supports fewer services and lower availability than Cloud EKM |
Choose CMEK when there is a requirement to manage key lifecycle, to generate key material in a FIPS 140-2 Level 3 certified hardware security module, or to store key material outside Google Cloud using Cloud EKM. Avoid CMEK when there are no key-management requirements and a managed service is preferred, because added pipelines increase cost, latency, and complexity. Application-layer tokenization with Sensitive Data Protection is a separate option for highly sensitive fields that must not persist in raw form, such as tokenizing personally identifiable information before writing to BigQuery.
Exam tip: CSEK is not recommended; scenarios historically addressed by CSEK are now better addressed by Cloud EKM because Cloud EKM supports more services and higher availability.
Encryption in transit in Google Cloud protects authenticity, integrity, and privacy when data moves outside physical boundaries controlled by Google. VM-to-VM traffic within a Virtual Private Cloud (VPC) network and between peered VPC networks inside Google's production network is integrity-protected and encrypted. Traffic from the internet to Google services and from a VPC network to Google services terminates at the Google Front End (GFE), which provides distributed denial-of-service countermeasures and routes and load-balances traffic, and traffic then flows from the GFE to Google Cloud services and between Google Cloud services using ALTS for authentication, integrity, and encryption.
Add Layer 7 encryption when customer applications need HTTPS or SSL between components, for example by placing an external Application Load Balancer with Google-managed SSL certificates in front of services behind a single IP address or by using Cloud Service Mesh for containerized traffic and TLS and mutual TLS in Apigee. Add network-layer encryption for hybrid paths because traffic over Cloud Interconnect is not encrypted by default; use MACsec for encryption over Cloud Interconnect and IPsec for encryption over Cloud VPN. Data is not encrypted by default while in use in memory, so use Confidential Computing with a trusted execution environment when workloads handle confidential data in system memory.
Secure Application Secrets and Sensitive Metadata means storing API keys, passwords, and certificates outside application code and controlling how applications fetch them. Secret Manager (opens in a new tab) is the Google Cloud service for centralizing those secrets, where each named secret holds one or more versions of secret material. Applications fetch the decrypted value at runtime through programmatic access based on Identity and Access Management permissions, which decouples sensitive configuration from code while providing versioning, access control, and an audit trail.
Secret Manager decouples sensitive configuration from application source code by storing credentials as named secrets that are fetched at runtime. Teams remove API keys and other sensitive values from source code, .env files, and container build configurations and store them in Secret Manager instead. At runtime the application retrieves the decrypted value using Google Cloud client libraries, Google Kubernetes Engine Secret Store CSI drivers, or Cloud Run secret bindings, so the secret never lives permanently in the codebase or image.
This runtime-fetch model limits the blast radius if code or images leak. When a secret value changes, the team adds a new secret version in Secret Manager rather than rebuilding and redeploying code with a new embedded value. Interactions with Secret Manager also create an audit trail that records version creation, destruction, and payload access.
Access to the Secret Manager API is protected by Identity and Access Management, and permissions should follow the principle of least privilege. The Secret Manager Secret Accessor role (roles/secretmanager.secretAccessor) should be granted directly on individual secrets, so each microservice can access only the specific secrets it requires. When many services share one project, secret-level Identity and Access Management bindings or Identity and Access Management Conditions limit access to the necessary subset of secrets.
Stronger isolation comes from resource structure and role choice:
Exam tip: Grant roles/secretmanager.secretAccessor on the specific secret a workload needs, not broadly at the project level.
Applications authenticate to the Secret Manager API with Application Default Credentials, and client libraries discover those credentials automatically. Local developers use gcloud auth application-default login, which creates a credential file that client libraries pick up. On Compute Engine and other Google Cloud compute platforms such as Cloud Run functions, client libraries obtain credentials through the instance metadata server, while on Google Kubernetes Engine workload identity provides credentials through a metadata service.
For workloads outside Google Cloud, such as Amazon Web Services or Microsoft Azure, workload identity federation uses the existing identity mechanism to authenticate to Google Cloud APIs. All of these methods are preferred to exporting a service account key because they avoid creating an additional secret that must be stored and protected outside the Secret Manager API.
Secret Manager coding best practice is to call the Secret Manager API directly with a client library, REST, or gRPC, and to avoid passing secrets through the file system or environment variables. A secret on the file system raises the severity of vulnerabilities such as directory traversal attacks, because an attacker who can read files may gain secret material. A secret in environment variables can leak through misconfigurations such as enabled debug endpoints or dependencies that log process environment details.
Syncing secret material to another datastore such as Kubernetes Secrets requires extra review of that datastore. The review must ask whether the datastore expands access to the secret, whether access to the secret can be audited, and whether the datastore meets data-at-rest encryption and regionalization requirements. Serverless product integrations are an exception where passing secrets through the file system or environment variables may be used through supported integrations such as Cloud Run secret bindings.
Secret Manager administration starts with choosing a replication policy when each secret is created. The automatic replication policy is the default choice because it provides high availability and disaster recovery across regions, and it should be used unless the workload has specific location requirements enforceable with the constraints/gcp.resourceLocations organization policy constraint. High-value secrets gain extra protection from customer-managed encryption keys in Cloud Key Management Service, which control, rotate, or revoke the keys that wrap secret payloads.
Data integrity checksums maintain and verify the integrity of secret data when adding and accessing secret versions, so corruption or tampering can be detected when a version is written or read. Customer-managed encryption keys add lifecycle control over the wrapping keys, while checksums protect the payload itself during write and read operations. Together, replication choice, customer-managed encryption, and checksums determine availability, control, and trustworthiness of stored secrets.
Secret Manager supports secure versioning through automated rotation schedules and audited access. When a rotation interval starts, Secret Manager publishes a SECRET_ROTATE notification to a designated Pub/Sub topic, which drives an ordered workflow:
SECRET_ROTATE message to Pub/Sub.Cloud Audit Logs on Secret Manager tracks secret version creation, destruction, and payload access events. Those logs can be routed to Google SecOps to alert on suspicious access, such as a compromised service account accessing secrets outside standard operational hours or attempting to read unapproved secret resources.
roles/cloudkms.cryptoKeyEncrypterDecrypter on the specific Cloud Key Management Service key for workloads such as Google Kubernetes Engine to enforce least privilege at the key level.Google-owned and Google-managed keys require no configuration and apply to all services that store customer data, while customer-managed encryption keys add lifecycle control, rotation reporting, hardware security module generation, and storage of key material outside Google Cloud with broad storage, database, and compute integrations. Customer-supplied encryption keys are supplied directly by the customer for limited operations such as Compute Engine Persistent Disks, but they lack centralized lifecycle, rotation, and policy enforcement, support fewer services with lower availability than Cloud External Key Manager, and are not recommended compared to Cloud External Key Manager.
Creation follows a fixed dependency order where the project and Cloud Key Management Service API must exist before the key ring and key can exist. Create a dedicated Google Cloud project with billing and the API enabled, create the key ring in a supported regional or multi-regional location, create the key inside that ring with purpose, protection level, and rotation schedule, grant Identity and Access Management roles only to identities that need cryptographic operations, and configure the data service such as Cloud Storage, BigQuery, Cloud SQL, or Google Kubernetes Engine to use the key resource name.
Grant the CryptoKey Encrypter/Decrypter role on the specific Cloud Key Management Service key for workloads such as Google Kubernetes Engine, rather than a broad project role, to enforce least privilege at the key level. Permissions can attach at the key level for narrow scope or at the ring or project level for broader scope, so key-level grants limit the impact if an identity is compromised, and in the Google Kubernetes Engine pattern the service account receives this role on the application-layer encryption key so requests flow from the control plane to Cloud Key Management Service for secret encryption.
Secret Manager stores application credentials as named secrets holding one or more versions of secret material that applications fetch at runtime through programmatic access based on Identity and Access Management permissions. When a rotation interval starts, Secret Manager publishes a SECRET_ROTATE notification to a designated Pub/Sub topic, a Cloud Run functions instance or Cloud Run service generates a new value and adds the new version and destroys the retired version after replacement, while Cloud Audit Logs tracks version creation, destruction, and payload access and can be routed to Google SecOps to alert on suspicious access.
An enterprise is designing a centralized Customer-Managed Encryption Key (CMEK) strategy in Google Cloud to protect sensitive datasets across several workload projects.
The security architecture must adhere to the following operational and compliance requirements:
Which architectural approach should you implement in Cloud Key Management Service (Cloud KMS)?
Last updated