Cloud Key Management Service in Google Cloud
A friendly, complete guide to creating, guarding, and controlling the keys that lock your data. Learn how encryption works, how Cloud KMS organises keys, how to rotate and protect them, and how to avoid the mistakes that lock you out.
Think about the key to your front door. The lock on the door is public: anyone can see it and even buy the same model in a shop. What keeps your home safe is not the secrecy of the lock but the safety of the key. If you lose the key, you are locked out. If a stranger copies it, your home is no longer safe. So you keep your key in a safe place, you give copies to only a few trusted people, and you change the lock if a key goes missing.
Data is protected the same way. Strong encryption is public knowledge, and everyone uses the same famous methods. What really matters is who holds the keys, how they are stored, who may use them, and what happens when they must be changed or destroyed. Cloud Key Management Service, usually called Cloud KMS, is Google Cloud’s managed place to create, store, use, rotate, and retire cryptographic keys. In this guide you will learn encryption from the very beginning, how Cloud KMS is organised, how it protects other Google Cloud services, how to keep it secure, and how to avoid costly mistakes.
Algorithm lists, protection levels, limits, default settings, new features such as automatic key creation, and prices change from time to time. This guide explains the ideas that stay stable. Before you design a real system, especially one with legal or compliance duties, confirm the current details in the official Google Cloud documentation.
1What Is Cloud KMS?
Start with the big picture before we meet the details.
The simple definition
Cloud KMS is a managed service for cryptographic keys. It lets you create keys, control who may use them, use them to lock and unlock data or to sign and verify messages, change them on a schedule, and destroy them safely. The key material, which is the secret numbers inside a key, is kept inside protected systems, and you ask the service to do the work. In most cases you never see the secret itself.
Think of a bank vault with a very careful clerk. You do not take the master key home. Instead, you hand the clerk a box and say “lock this” or “unlock that”. The clerk checks your identity and permission, does the job inside the vault, and gives the result back. Cloud KMS is that vault and that clerk.
Why it exists
Keys are the most sensitive pieces of any security system. If keys are stored in code, in spreadsheets, or on servers next to the data they protect, one leak exposes everything. Building your own key vault is hard, expensive, and easy to get wrong. Cloud KMS gives you strong storage, strict access control, complete audit records, and automatic scale, without building any of it.
Where it is used
Teams use it to protect data stored in Google Cloud with their own keys, to sign software and documents, to protect small secrets, to meet rules that demand control over encryption keys, and to ensure that only chosen people and programs can decrypt sensitive information.
2Encryption Basics You Must Know
A few simple ideas make everything else easy. Take your time here.
Plaintext and ciphertext
Plaintext is readable data. Ciphertext is the scrambled version that looks like random noise to anyone without the key.
Encryption and decryption
Encryption scrambles data using a key. Decryption unscrambles it using the right key.
Symmetric key
One shared secret key does both locking and unlocking. Fast and used for most data.
Asymmetric keys
A pair of keys: a public key that anyone may have and a private key that only the owner keeps.
Digital signature
A proof, made with a private key, that a message came from its owner and was not changed.
MAC and hash
A hash is a short fingerprint of data. A MAC is a fingerprint made with a secret key, proving both integrity and knowledge of the key.
Symmetric versus asymmetric
With symmetric encryption, one key does both jobs. It is very fast, so it is used to protect large amounts of data such as disks and databases. With asymmetric encryption, the public key locks and the private key unlocks, or the private key signs and the public key verifies. It is slower, but you can share the public key freely without sharing the secret.
A symmetric key is like a house key: the same key locks and unlocks, so you must hand copies only to people you trust. An asymmetric pair is like a postbox: anyone can drop a letter in through the slot, which is the public key, but only the owner with the private key can open the box and read it.
Data at rest, in transit, and in use
- At rest. Data stored on disks, in databases, or in buckets. Google Cloud encrypts this by default.
- In transit. Data travelling over networks, protected by secure connection protocols.
- In use. Data being processed in memory. Special confidential computing options exist for this.
Cloud KMS mainly deals with data at rest, but it also supports signing and key management that other protections rely on.
Why key control matters
Encryption turns the problem of protecting big data into the problem of protecting one small key. If you control the key, you control who can read the data, even if someone obtains the stored bytes. This idea is the base of every key management service.
3Architecture and Resource Hierarchy
Cloud KMS organises keys in a neat set of containers. Learning this structure is essential.
flowchart TD
A["Google Cloud project"] --> B["Location such as asia-south1, a region or multi-region"]
B --> C["Key ring named payments-keys"]
C --> D["Key named customer-data-key"]
C --> E["Key named signing-key"]
D --> F["Key version 1 disabled"]
D --> G["Key version 2 enabled"]
D --> H["Key version 3 primary"]
E --> I["Key version 1 enabled"]
The levels, one by one
Project
The Google Cloud project that owns the keys, sets billing, and applies permissions.
Location
Where the keys live and are used. It can be one region, a multi-region, or global. A key must be in a location that matches the resources it protects, in most cases.
Key ring
A named group of keys in one location. Key rings help you organise keys and apply permissions to groups. A key ring cannot be deleted once created.
Key
A named key with a purpose, an algorithm, a protection level, and a rotation setting. A key itself cannot be deleted, only its versions can be destroyed.
Key version
The actual secret material at one point in time. Each rotation creates a new version.
Names last forever
Key rings and keys cannot be removed, so their names stay in the project for good, even after all versions are destroyed. Choose clear, consistent names from the start, such as team, environment, and purpose. Careless names become permanent clutter.
Imagine a building with floors, rooms, and key cabinets. The floor is the location, the room is the key ring, the cabinet is the key, and the individual metal keys that get replaced from time to time are the key versions. The building plan is permanent, but the metal keys inside can be swapped.
Choosing a location
Pick a location that follows your data rules and sits near the services using the key. Using keys in the same region as the data reduces delay and avoids confusion. Some services require the key location to match the resource location, and some allow a global key. Check the requirements for each service.
4Key Purposes, Algorithms, and Protection Levels
Every key is created for one job and one level of protection.
Key purposes
| Purpose | What it does | Typical use |
|---|---|---|
| Symmetric encrypt and decrypt | Locks and unlocks data with one key | Protecting stored data and wrapping other keys |
| Asymmetric decrypt | Unlocks data that was locked with the public key | Receiving secrets from outside parties |
| Asymmetric sign | Creates a digital signature with the private key | Signing software, documents, and tokens |
| MAC sign and verify | Creates and checks a keyed fingerprint | Proving messages were not changed |
| Raw encrypt and decrypt | Provides low-level operations for special needs | Compatibility with existing systems |
Algorithms in plain words
The service supports well-known standard algorithms. For symmetric keys, a strong standard called AES is used. For asymmetric keys, the families are RSA and elliptic curve methods, with several key sizes. Newer algorithms designed to resist future quantum computers have also started to appear, in stages of preview or availability that change over time. Choose standard, current algorithms and key sizes, and avoid inventing your own. Check the current list in the documentation.
Protection levels
The protection level says where the key material lives and how well it is guarded. It is chosen when the key is created.
Software keys
Key operations run in Google’s secured software systems. The simplest and cheapest choice for most needs.
Cloud HSM keys
Keys live inside special tamper-resistant hardware security modules, validated to recognised standards. Chosen when rules demand hardware protection.
Cloud EKM keys
The key stays outside Google Cloud, in a partner system you control. Google asks that system to do each operation.
Autokey
A feature that creates keys and key rings for you, on demand, following good practice, so teams get protection without waiting for a security team.
Software keys are like a strong safe inside a well-guarded office. HSM keys are like a bank vault built into the foundation, with alarms and tamper detection. External keys are like keeping the master key in your own building across town, so the bank must phone you each time it needs to open the box.
The protection level and purpose of a key cannot be changed after creation. If you pick the wrong one, you must create a new key and move your data. Decide carefully, and test with a harmless key first.
5Envelope Encryption: How It Really Works
This idea sits behind almost every Google Cloud service that uses Cloud KMS.
sequenceDiagram
participant App as Service or Application
participant K as Cloud KMS
participant S as Storage
App->>App: Create a fresh data key
App->>App: Encrypt the data with the data key
App->>K: Please wrap the data key with my key
K-->>App: Return the wrapped data key
App->>S: Store encrypted data with the wrapped data key
Note over App,S: Plain data key is thrown away from memory
App->>S: Later, read data and wrapped key
App->>K: Please unwrap this data key
K->>K: Check permission and record the use
K-->>App: Return the data key
App->>App: Decrypt the data
The two layers of keys
In envelope encryption, there are two levels of keys. A data encryption key, or DEK, is a fresh key used to encrypt the actual data. A key encryption key, or KEK, is the stronger key in Cloud KMS that encrypts, or “wraps”, the DEK. The wrapped DEK is stored next to the data. To read the data, the service asks Cloud KMS to unwrap the DEK, and then uses it.
Why not use the KMS key on the data directly?
- Speed. Sending large files over the network to KMS would be slow. Only the tiny DEK travels.
- Size limits. Direct encryption calls only accept small amounts of data, in the order of tens of kilobytes.
- Easy rotation. To change the KEK, you only need to re-wrap small DEKs and not re-encrypt all the data.
- Control. If you disable the KEK, every DEK wrapped by it becomes unusable, and so does all the data.
- Lower load and cost. Only a few KMS calls are needed for a great deal of data.
Imagine each document is locked in its own small box with its own small key. All those small keys are then placed in one master safe. To open a box you must first get its small key from the safe. If the safe is closed, no box can be opened, even though the boxes themselves are scattered across many rooms.
Why this gives you power
Because every use of the KEK passes through Cloud KMS, you can see each use in audit logs, you can control it with permissions, and you can switch it off in an emergency. That power over a single key controls access to an enormous amount of data.
6Customer-Managed Encryption Keys (CMEK)
The most common reason to use Cloud KMS is to protect other Google Cloud services with keys you control.
Three ways to encrypt at rest
| Option | Who manages the key | Control you get |
|---|---|---|
| Google-managed encryption | Google, automatically | Lowest effort. On by default for stored data. No key choices for you. |
| Customer-managed keys, CMEK | You, in Cloud KMS | You control rotation, access, and disabling. Google services use your key to protect the data. |
| Customer-supplied keys, CSEK | You supply the raw key with each request | Maximum control, but available for only a few services, and losing the key loses the data. |
flowchart LR
A["Your key in Cloud KMS"] --> B["Cloud Storage buckets"]
A --> C["BigQuery datasets"]
A --> D["Compute Engine disks"]
A --> E["Cloud SQL databases"]
A --> F["Google Kubernetes Engine secrets"]
A --> G["Pub/Sub topics"]
A --> H["Many other services"]
I["Service agent identity of each service"] -->|"Needs encrypter and decrypter role"| A
How CMEK is set up
Create the key
Create a key ring and key in the right location, with the right protection level and a rotation schedule.
Find the service agent
Each Google Cloud service uses a special identity, the service agent, to act on your behalf. Find the one for the service you want to protect.
Grant permission
Give that service agent the role that allows it to encrypt and decrypt with your key, and only your key.
Point the resource at the key
When you create a bucket, dataset, or disk, choose your key as its encryption key.
Monitor and maintain
Watch audit logs and key health, and keep access tidy.
Autokey and organisation policies
Autokey reduces effort by creating keys and key rings automatically when a team creates a protected resource, using sensible names and settings. Organisation policies let a security team enforce rules across the company, such as “new resources in these services must use a customer-managed key” or “keys may only come from this central project”. Together they turn good practice into the default.
Keep keys in a separate, locked-down project, owned by a security team, and let application projects use them without owning them. Then the people who build applications cannot change or destroy the keys that protect them.
7Key Versions and Rotation
Good keys are changed regularly. Rotation limits the harm if a key is ever exposed.
What rotation means
When you rotate a key, Cloud KMS creates a new version and makes it the primary version. New encryption uses the primary version. Older versions stay available for decrypting data that was locked with them, until you disable or destroy them. Data does not need to be re-encrypted immediately, because each piece of data remembers which version protected it.
flowchart LR
A["Version 1 enabled primary"] -->|"Rotation"| B["Version 2 primary"]
A --> C["Version 1 still decrypts old data"]
B -->|"Rotation"| D["Version 3 primary"]
C -->|"No longer needed"| E["Disable version 1"]
E -->|"Confirmed safe"| F["Schedule destruction"]
F -->|"Waiting period ends"| G["Destroyed"]
E -->|"Mistake noticed"| C
F -->|"Cancel during waiting period"| E
Version states
| State | Meaning | Can it decrypt? |
|---|---|---|
| Pending generation | The version is still being created | Not yet |
| Enabled | Active and ready to use | Yes |
| Disabled | Switched off temporarily and reversible | No |
| Scheduled for destruction | Waiting out a safety period before final removal | No, but can be restored |
| Destroyed | The key material is permanently gone | Never again |
Automatic and manual rotation
- Automatic rotation. For symmetric keys you can set a schedule, for example every ninety days. It is simple and reliable.
- Manual rotation. You create a new version yourself. This is needed for asymmetric keys, since their public keys must be shared and updated with other people.
- Emergency rotation. If you suspect exposure, rotate at once, and re-encrypt the most sensitive data with the new version.
- Choose a sensible period. Follow your company policy or standards. Very frequent rotation adds work with little benefit, and very rare rotation increases risk.
The safety wait before destruction
Destroying a key version is permanent and unrecoverable. To protect you from mistakes, destruction is scheduled with a waiting period, during which you can still restore the version. The length of the wait is set when the key is created, and the default has been long, around a month. During this time the version cannot be used, which also helps you discover any hidden dependency before it is too late.
Destroying a key version that still protects data makes that data unreadable forever, and nobody, including Google, can bring it back. This is sometimes done on purpose and called crypto-shredding, but it is a disaster when done by accident. Always disable first, wait, check logs for any use, and only then schedule destruction.
8Data Flow and Lifecycle of a Key
Every key has a life story. Plan every stage before the first key is created.
Plan
Decide purpose, algorithm, protection level, location, owner, rotation period, and who may use it.
Create
Generate the key inside the service, or import your own key material in special cases.
Grant access
Give narrow roles to exactly the identities that need to use the key.
Use
Services and applications encrypt, decrypt, sign, or verify with the key.
Rotate
New versions are created on schedule or on demand.
Monitor and audit
Watch use, review access, and respond to unusual activity.
Disable and destroy
Retire old versions in stages, with waiting periods and checks, when data no longer depends on them.
Importing your own key material
Sometimes rules or existing systems require that the key was created elsewhere. Cloud KMS supports importing keys through a controlled process in which the key material is wrapped for transport and unwrapped only inside the protected service. Imported keys bring extra duties: you must keep your own secure copy if you may need it, you must manage its rotation, and you must make sure the original is handled properly. Most teams are better served by keys generated inside the service.
Backups of keys
Cloud KMS keys are stored durably by the service. You cannot export the material of a standard key. You protect yourself from loss through careful permissions, no hurried destruction, and good audit records, not through downloading secrets.
9Access Control and Separation of Duties
The right people should manage keys. The right programs should use them. These should almost never be the same.
Roles that matter
| Role | What it allows | Who should have it |
|---|---|---|
| KMS admin | Create and manage keys, set rotation, grant access. Cannot use the key to encrypt or decrypt data. | A small security team |
| Encrypter and decrypter | Use the key to encrypt and decrypt data. Cannot manage the key. | Service agents and application identities that need it |
| Encrypter only or decrypter only | Only the one half of the operation | Programs that only write or only read |
| Signer and verifier | Sign messages or verify signatures | Build systems and services that sign or check |
| Public key viewer | Read the public part of an asymmetric key | Anyone who needs to encrypt to you or verify your signatures |
| Viewer | See key metadata, not use it | Auditors and operations staff |
Why separation matters
Notice that the admin role cannot decrypt and the user role cannot manage. This is separation of duties. The person who controls the lock is different from the person who uses it, so no single mistake or dishonest person can both change the rules and read the secrets.
In a bank, the manager decides who gets a key to the cash drawer, but the manager does not handle the cash. The cashier handles the cash, but cannot give out new keys. Each side checks the other.
Good access habits
- Grant at the lowest level. Give permissions on a single key whenever possible, not on the whole project.
- Use groups for people. And service accounts for programs.
- Avoid broad primitive roles. Project owner and editor roles can give wide power. Avoid relying on them for key control.
- Use conditions. IAM conditions can limit access by time, resource name, or other factors.
- Review regularly. Remove access that is no longer needed.
- Protect the keys project. Keep it separate, with very few people allowed in.
10Advantages, Disadvantages, and Trade-offs
An honest view of what you gain and what you give up.
Advantages
- Strong, managed key storage without building your own vault.
- Fine-grained access control and separation of duties.
- Full audit records of key use.
- Automatic rotation for symmetric keys.
- Works with many Google Cloud services through CMEK.
- Hardware-backed and external options for strict rules.
- Ability to disable a key to cut off access in an emergency.
Disadvantages
- More to manage than default Google-managed encryption.
- Your data depends on the key. A lost, disabled, or destroyed key means unreadable data.
- Each use adds a small delay and a request, and quotas apply.
- Key location must match service rules, which constrains design.
- HSM and external keys cost more, and external keys add dependence on another system.
- Key rings and keys cannot be deleted, so naming mistakes stay.
The big trade-offs
Control versus responsibility. With your own keys, you gain power to control and revoke. You also gain the duty to protect, rotate, and never lose them. For many workloads, default encryption is enough. Use CMEK where policy, regulation, or risk demands it.
Availability versus control. If a service needs your key for each operation, then your key being disabled or unreachable can stop the service. This is the point of control, but it also adds a dependency. External keys add a second dependency outside Google Cloud.
Security versus convenience. Tight separation of duties and a locked keys project are safer, but add steps when teams need keys. Autokey and policies help to reduce friction.
Software versus hardware versus external. Stronger protection levels give stronger assurance and cost more. Match the level to the actual risk and rules.
11Security Practices in Depth
Key management is a security service, so using it securely is the whole point.
Core protections
- Least privilege. Narrow roles on specific keys.
- Separate projects. Keys in a central protected project, data in application projects.
- No keys in code. Never place key material or long-lived credentials in source, images, or configuration files.
- Private connectivity and perimeters. Use private access and VPC Service Controls, where supported, so key calls stay inside your boundary.
- Organisation policies. Enforce that sensitive services use approved keys, and limit which projects may supply keys.
- Rotation. Schedule regular rotation and rehearse emergency rotation.
- Deletion protection. Restrict who can schedule destruction, and keep waiting periods long.
- Audit. Turn on data access logs for key operations, where the volume and cost are acceptable, and route logs to a protected location.
- Alerts. Notify the security team when keys are disabled, destroyed, or when permissions change.
- Test recovery. Practise what happens when a key is disabled, to know which services and teams are affected.
Key Access Justifications and external control
With external keys, you can require that each request comes with a stated reason, such as a customer support case or a system action, and you can configure your external system to approve or deny based on that reason. This gives a very strict level of control for highly regulated data. It also means you must run and maintain that external system reliably, since an outage there can block access to the protected data.
Threats to think about
| Threat | Example | Defence |
|---|---|---|
| Stolen credentials | An attacker gets a service account token | Narrow roles, short-lived credentials, and alerts on unusual key use |
| Insider misuse | An admin tries to read data | Separation of duties and audit logs |
| Accidental destruction | Someone destroys a needed key version | Waiting periods, restricted roles, and approval steps |
| Key sprawl | Hundreds of unnamed, unowned keys | Naming rules, labels, Autokey, and inventory reviews |
| Quota exhaustion | A busy service exceeds key request limits and fails | Cache data keys, spread keys, and request higher quotas ahead of time |
| Wrong location | A key in one region used by data in another | Plan locations and use policies |
Cloud KMS is for keys, not for storing general secrets such as passwords or tokens. For those, use Secret Manager, which stores secrets and can itself be protected with your Cloud KMS key. Using each service for its proper job keeps designs clean and safe.
12Monitoring, Logging, and Metrics
Because keys guard everything else, watching them closely is part of good security.
Admin Activity logs
Always on. Record who created, changed, rotated, disabled, or destroyed keys, and who changed permissions.
Data Access logs
Optional. Record each use of a key to encrypt, decrypt, sign, or verify. Valuable but can be high in volume.
Key usage tracking
Shows which Google Cloud resources are protected by a key, so you know the impact before you disable or rotate it.
Cloud Monitoring
Charts and alerts for request rates, errors, and quota use for key operations.
What to watch
- Changes to permissions. New admins or broad roles should trigger review.
- Disabled or scheduled-for-destruction versions. Always alert, and confirm they are intended.
- Unusual decrypt activity. A sudden spike, or access at odd hours or from odd identities, may signal misuse.
- Permission errors. A rise in denied calls may mean a broken policy or an attempted attack.
- Quota use. Heavy services can approach request limits and need more capacity.
- Key inventory. Regularly list keys, owners, protection levels, rotation settings, and protected resources.
- External key health. If you use external keys, monitor the availability of your key manager.
Plan before you disable. Use key usage tracking to see what depends on a key. Then notify owners, schedule a change window, and watch error rates after the change. A quick, informed disable is a powerful emergency tool. A hurried, uninformed one can cause an outage across many services.
13Performance, Quotas, and Cost Planning
Key calls are fast, but they are still network calls with limits and a price.
Performance points
- Envelope encryption keeps calls rare. Services cache or reuse data keys, so Cloud KMS is not called for every byte.
- Location matters. Use keys in the same region as the workload to reduce delay.
- Software versus HSM versus external. Software is usually fastest, HSM adds a little, and external adds the most because a call leaves Google Cloud.
- Quotas. There are limits on cryptographic operations and management requests per minute. Heavy workloads should check quotas early and request increases before launch.
- Retries. Use waiting and retry logic for temporary errors, and avoid flooding the service.
What you pay for
Prices change and differ by protection level and region, so check the current pricing page. In general, the parts are:
| Cost area | What it depends on | How to reduce it |
|---|---|---|
| Active key versions | Number of enabled versions and their protection level | Disable and destroy old versions when safe, and avoid needless keys |
| Cryptographic operations | Number of encrypt, decrypt, sign, and verify calls | Use envelope encryption and caching |
| HSM keys | Higher price than software keys | Use only where rules need hardware protection |
| External keys | Price of the service plus the cost of your external key manager | Use only for the most sensitive data |
| Audit logging | Volume of data access logs stored | Enable where needed, set retention, and export wisely |
| People time | Effort to manage and review keys | Use Autokey, policies, and naming standards |
One key for each purpose and environment is usually enough. Creating a unique key for every tiny resource multiplies cost and effort without much gain. Group resources that share the same owner, sensitivity, and rotation needs under one key.
14Design Patterns and Anti-patterns
Helpful habits and harmful habits seen again and again in real projects.
Helpful patterns
Central key project
Keep all keys in one or a few tightly controlled projects owned by security. Application teams get permission to use keys, not to manage them.
One key per environment and sensitivity
Separate keys for production and testing, and for different data classes, so a problem in one cannot touch another.
Automatic rotation with monitoring
Rotate on a schedule, and monitor so that rotation failures or unusual changes are noticed.
Staged retirement
Disable, wait, check logs, and only then schedule destruction, with approval from the data owner.
Signing in the build pipeline
Use an asymmetric signing key to sign software releases. Only the build system may sign, and anyone can verify with the public key.
Anti-patterns to avoid
What it looks like
A team that owns a database also owns, and can destroy, the key that protects it, with no waiting period and no second approval.
Why it hurts
One mistake or one dishonest person can make all data unreadable forever. There is no separation of duties and no safety net.
Better approach
Keep keys in a separate project owned by security, restrict destruction rights, use long waiting periods, and require approval.
What it looks like
An application downloads or hard-codes secret key material, uses its own home-made encryption, and stores the key beside the data.
Why it hurts
Anyone who copies the data also copies the key. There is no audit, no rotation, and no way to cut off access.
Better approach
Use envelope encryption with Cloud KMS, so keys stay in the service and every use is controlled and logged.
More things to steer clear of
- Giving the admin role to applications. Applications only need to use keys.
- Disabling keys without checking dependencies. Causes sudden outages.
- Mismatched locations. A key in the wrong place blocks creation of protected resources.
- No rotation. Old keys carry old risk.
- Using KMS to store passwords. Use Secret Manager for secrets.
- Forgetting to monitor key changes. Silent permission changes can open a door.
15Best Practices and Common Mistakes
A checklist of habits that experienced security teams rely on.
Habits that work
- Start from requirements. Decide whether default encryption is enough or whether policy demands customer-managed keys.
- Choose names carefully. They are permanent.
- Pick protection level deliberately. Software, HSM, or external, by actual need.
- Separate duties between key managers and key users.
- Keep keys in a protected project.
- Rotate automatically where possible, and rehearse emergency rotation.
- Use long destruction waiting periods and staged retirement.
- Turn on audit logs and alerts for key changes and unusual use.
- Use organisation policies to enforce good practice.
- Use Autokey to reduce friction and sprawl where suitable.
- Plan for quotas and place keys near workloads.
- Document ownership and review key inventory regularly.
Mistakes beginners often make
| Mistake | What goes wrong | Fix |
|---|---|---|
| Forgetting to grant the service agent access | Creating an encrypted resource fails with a permission error | Grant the encrypter and decrypter role on the key to the right service agent |
| Key in the wrong location | The service refuses to use the key | Create the key in a location that matches the resource |
| Disabling a key in use | Reads and writes fail across services | Check key usage first and warn owners |
| Destroying a version too soon | Data lost permanently | Disable, wait, verify, then destroy |
| Wrong protection level chosen | Needs a new key and a data migration | Decide with compliance staff before creating |
| Giving broad roles to developers | Anyone can change or destroy keys | Use narrow roles and groups |
| Expecting auto rotation for asymmetric keys | Keys never rotate | Plan manual rotation and public key distribution |
| Using KMS for general secrets | Awkward design and limits | Use Secret Manager, protected with a KMS key if needed |
16Real-World Usage Examples
Common ways teams use Cloud KMS. These are typical scenarios, not claims about any particular company.
Healthcare records in storage
A hospital group stores scanned records in Cloud Storage and tables in BigQuery, all protected with keys it controls. Its security team holds the admin role in a separate project, and developers can use the data but never manage the keys.
Bank with strict rules
A bank uses hardware-protected keys for customer data and requires organisation policies so that new databases cannot be created without an approved key. Auditors read key logs each month.
Software signing
A software company signs every release with an asymmetric key that only the build system can use. Customers verify the signature with the public key, and the private key never leaves the service.
Customer-specific keys
A software-as-a-service provider gives each large customer a separate key for their data. If a customer leaves, the provider can disable and later destroy that customer’s key, making the data unreadable.
Strict control with external keys
A government agency keeps the master keys in its own approved key manager and uses external keys, so that Google Cloud must ask the agency’s system for every operation, and the agency can cut access instantly.
Protecting application secrets
A team stores passwords and tokens in Secret Manager and protects that service with a Cloud KMS key, so access to secrets is controlled both by secret permissions and by key permissions.
Data retirement by key destruction
After a retention period ends, a company destroys the key for an old archive in a controlled, approved process, rendering the archived data unreadable without having to erase every copy.
17Choosing the Right Approach
Not every workload needs the same level of control. Here is how to choose.
flowchart TD
A["Protect data at rest"] --> B{"Do rules or risk require you to control keys"}
B -->|"No"| C["Default Google-managed encryption"]
B -->|"Yes"| D{"Must key material stay outside Google Cloud"}
D -->|"Yes"| E["Cloud EKM external keys"]
D -->|"No"| F{"Do rules require hardware protection"}
F -->|"Yes"| G["Cloud HSM keys with CMEK"]
F -->|"No"| H["Software keys with CMEK"]
H --> I{"Many teams and resources"}
G --> I
I -->|"Yes"| J["Use Autokey and organisation policies"]
I -->|"No"| K["Create and manage keys directly"]
| Service or option | Best for | Remember |
|---|---|---|
| Default encryption | Most workloads with no special rules | Automatic, but you do not control the keys |
| Cloud KMS with CMEK | Control over rotation, access, and revocation | You carry the duty to protect and never lose the key |
| Cloud HSM | Rules that need validated hardware | Higher cost |
| Cloud EKM | Keys that must stay outside Google Cloud | Extra dependency and delay |
| Secret Manager | Passwords, tokens, and other secrets | Not a key manager, but can use KMS keys |
| Customer-supplied keys | A few services that support it, with raw keys given on each request | Easy to lose, so used rarely |
A simple rule of thumb: begin with default encryption, and add customer-managed keys where a regulation, contract, or risk assessment calls for control. Increase the protection level only as far as the requirement goes. Each step adds assurance and also adds cost and responsibility.
18Frequently Asked Questions
19Summary and Key Takeaways
What to remember
- Cloud KMS is a managed service for cryptographic keys. It creates, stores, uses, rotates, and retires keys, and the secret material stays inside protected systems while you ask the service to do the work.
- Learn the hierarchy. Projects hold key rings in a location, key rings hold keys, and keys hold versions. Names are permanent, so choose them well and place keys in the right location.
- Envelope encryption does the heavy lifting. A small data key locks the data, and your Cloud KMS key locks the data key, so you gain control, audit, and easy rotation with few calls.
- Choose the control you need. Default encryption for most work, CMEK with software keys for control, HSM where hardware protection is required, and EKM when keys must stay outside Google Cloud.
- Separate duties. Key administrators manage keys without using them, applications use keys without managing them, and keys sit in a protected, separate project.
- Rotate and retire with care. Use automatic rotation for symmetric keys, plan manual rotation for asymmetric keys, and retire versions in stages with long waiting periods, because destruction is permanent.
- Watch and plan. Alert on key changes, review usage and quotas, and keep documentation and inventory current. Use Secret Manager for passwords and Cloud KMS for keys, and check the documentation often as features and limits change.