Designing data processing systems · Topic 1 of 5
IAM, Encryption Keys and PII Protection
Data engineer security design on Google Cloud: IAM roles and organization policies, CMEK with Cloud KMS, AEAD crypto shredding and Cloud DLP for PII.
- 5 min
- Querying needs Job User on a project plus Data Viewer on the data.
- Grant roles to groups and dedicated service accounts at the narrowest level.
- Organization policies enforce locations, domains and CMEK across many projects.
What it is
Security design for a data platform answers three questions. Who may run jobs and read data (IAM and organization policies), how data is protected at rest and in transit (encryption and key management), and what happens to personal data such as names, emails and card numbers (privacy controls).
How it works
IAM for data services
Grant roles to groups and service accounts, never to individuals one by one. Grant at the narrowest level that works: table or dataset before project.
| Need | BigQuery role | Granted on |
|---|---|---|
| Run queries and pay for them | BigQuery Job User (roles/bigquery.jobUser) | The project that runs the jobs |
| Read table data | BigQuery Data Viewer (roles/bigquery.dataViewer) | Dataset or table |
| Create and change tables | BigQuery Data Editor (roles/bigquery.dataEditor) | Dataset |
| See schemas but not data | BigQuery Metadata Viewer | Dataset or project |
| Full control including sharing | BigQuery Data Owner or BigQuery Admin | Dataset or project |
Querying needs two things: permission to create jobs in a project, and permission to read the data. An analyst with Data Viewer alone gets "does not have bigquery.jobs.create permission".
Pipelines run as service accounts. A Dataflow job uses a worker service account; give it only the roles its sources and sinks need, such as Dataflow Worker, Pub/Sub Subscriber and BigQuery Data Editor on one dataset.
Organization policies
Organization policies are guardrails set on the organization, a folder or a project. They apply whatever IAM says.
| Constraint | Effect |
|---|---|
gcp.resourceLocations | Resources can be created only in allowed locations |
iam.allowedPolicyMemberDomains | Domain restricted sharing: IAM grants only to your own domains |
gcp.restrictNonCmekServices | Listed services must use customer managed keys |
Encryption and key management
All data is encrypted at rest and in transit by default. The design choice is who controls the keys.
| Option | Key holder | Choose it when |
|---|---|---|
| Google default encryption | No key requirement in the stem | |
| CMEK in Cloud KMS | You, in Cloud KMS | You must rotate, disable or audit key use |
| Cloud HSM | You, with keys in Google-operated hardware security modules | Keys must be protected by hardware |
| Cloud EKM | You, in an external key manager | Keys must stay outside Google |
BigQuery, Cloud Storage, Pub/Sub, Dataflow, Dataproc and Cloud SQL all support CMEK. Each service's service agent needs the Cloud KMS CryptoKey Encrypter/Decrypter role on the key. The key ring must be in a location compatible with the data.
Customer supplied encryption keys (CSEK) work only with Cloud Storage and Compute Engine. A question that needs your own keys for BigQuery means CMEK.
Privacy and PII strategies
| Strategy | Tool |
|---|---|
| Find PII across tables and buckets | Cloud DLP (now Sensitive Data Protection) discovery and inspection |
| Replace values before storage | Cloud DLP de-identification: masking, redaction, bucketing, date shifting |
| Keep values joinable but hidden | Deterministic encryption or format preserving encryption tokens |
| Hide columns from most readers | BigQuery policy tags and data masking |
| Delete one person's data everywhere | Crypto shredding: destroy that person's key |
Tokenization lets analysts count and join on a customer without seeing the real value. Only holders of the key can re-identify.
A worked example
A retailer must let analysts study purchase history but honour erasure requests. The engineer encrypts the email column in BigQuery with a separate keyset per customer, stored in a protected key table.
-- one keyset per customer, kept in a restricted dataset
CREATE TABLE secure.customer_keys AS
SELECT customer_id, KEYS.NEW_KEYSET('AEAD_AES_GCM_256') AS keyset
FROM raw.customers;
-- store encrypted email in the analytics table
SELECT c.customer_id,
AEAD.ENCRYPT(k.keyset, c.email, CAST(c.customer_id AS STRING)) AS email_enc
FROM raw.customers AS c
JOIN secure.customer_keys AS k USING (customer_id);
To erase a customer, delete their row from secure.customer_keys. Once the key table's time travel and fail-safe periods pass, the ciphertext in every table and copy is unreadable, which is far easier than finding every copy.
How the exam asks about this
- "Analysts can see the dataset but every query fails with a jobs.create error." Grant BigQuery Job User on the project they query from.
- "No IAM grant may ever be made to accounts outside the company." Domain restricted sharing organization policy.
- "The security team must be able to revoke access to BigQuery data by disabling a key." CMEK with Cloud KMS.
What to remember for the exam
- Querying needs Job User on a project plus Data Viewer on the data.
- Grant roles to groups and dedicated service accounts at the narrowest level.
- Organization policies enforce locations, domains and CMEK across many projects.
- CMEK for control, Cloud HSM for hardware, Cloud EKM for keys outside Google.
- Cloud DLP finds and de-identifies PII; crypto shredding handles erasure.
Basic (formerly primitive) roles such as Owner, Editor and Viewer on a project are almost never the right answer. They grant far more than any data task needs.
Common mistakes
Granting dataViewer on the whole project. Every dataset in it becomes readable, including ones added later.
Choosing CSEK for BigQuery. BigQuery supports CMEK, not customer supplied keys.
Masking PII by copying tables. Copies drift and multiply the data you must protect; mask in place with policy tags or de-identify once at ingestion.
Check yourself
Which two permissions does an analyst need to query a BigQuery table?
Permission to create jobs in a project (BigQuery Job User) and permission to read the table (BigQuery Data Viewer on the dataset or table).
Which key option keeps encryption keys outside Google's infrastructure?
Cloud EKM, used as CMEK for the services that store the data.
How does crypto shredding satisfy an erasure request?
Each person's data is encrypted with their own key, so destroying that key makes every copy of their data unreadable.
Topic 1 of 5 in Designing data processing systems
Test yourself on Designing data processing systems
The full Google Cloud Professional Data Engineer question bank has 733 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Google Cloud. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.