CMP-7Recommended
Map every store that holds personal data
Keep a data map in the repository of every place personal data is stored or sent. Give each its region, its owner and the kinds of data in it.
How to do it
Include databases, file buckets, caches, search indexes, queues, logs, backups, analytics, the email service, the support desk and every AI provider. Give each store a stable ID that the other registers refer to. Generate the list of stores from your infrastructure code, such as Terraform state, and compare it with the map in the build. The personal data columns rule lists the columns inside each database.
Examples
YAML example
- id: orders-db
kind: database
provider: hosting-eu
region: eu-north-1
data: [name, email, address, order history]
subjects: [customers]
owner: maria.lind
- id: support-desk
kind: processor
provider: helpdesk-us
region: us-east
data: [name, email, message text]
subjects: [customers, prospects]
owner: jonas.berg
JavaScript example
import { readFileSync } from 'node:fs';
import { parse } from 'yaml';
const mapped = new Set(parse(readFileSync('compliance/data-map.yaml', 'utf8')).map(store => store.id));
const state = JSON.parse(readFileSync('terraform-show.json', 'utf8'));
const STORE_TYPES = ['aws_db_instance', 'aws_s3_bucket', 'aws_elasticache_cluster', 'aws_opensearch_domain'];
const unmapped = state.values.root_module.resources
.filter(resource => STORE_TYPES.includes(resource.type))
.map(resource => resource.values.tags?.data_map_id ?? resource.address)
.filter(id => !mapped.has(id));
if (unmapped.length) { console.error(`Stores missing from the data map: ${unmapped.join(', ')}`); process.exit(1); }
Python example
import json, sys, yaml
mapped = {store["id"] for store in yaml.safe_load(open("compliance/data-map.yaml"))}
state = json.load(open("terraform-show.json"))
STORE_TYPES = {"aws_db_instance", "aws_s3_bucket", "aws_elasticache_cluster", "aws_opensearch_domain"}
unmapped = [
(r["values"].get("tags") or {}).get("data_map_id", r["address"])
for r in state["values"]["root_module"]["resources"] if r["type"] in STORE_TYPES
]
missing = [store_id for store_id in unmapped if store_id not in mapped]
sys.exit(f"Stores missing from the data map: {', '.join(missing)}" if missing else None)
How to check
The build compares the stores defined in infrastructure code and the external hostnames the app calls with the data map. It fails on any store or host missing from the map.
Sources
Related rules
- DAT-35 Erase retired databases and every copy in Data and databases
- INF-65 Choose regions from users and data rules in Infrastructure and environments
- AIF-51 Erase a person's data from every AI store in AI features
- DAT-30 Store only the personal data you need in Data and databases
- CMP-80 Use Swedish personal identity numbers only when clearly justified in Compliance and governance
- CMP-78 Process California deletion requests from DROP every 45 days in Compliance and governance
- MOB-27 Fill in the store privacy forms from an SDK list in Mobile apps
- DEN-19 Record lineage from the code in Data engineering
- DEN-23 Copy only the personal columns an analysis needs in Data engineering
- IOT-31 List every sensor and every field that leaves the device in Connected devices
- ANA-17 Name the lawful basis for every experiment in Product analytics and experiments
- SRH-6 Index only the fields people search in Search
- SRH-8 Remove erased records from every index in Search
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/compliance/records-and-data-map/data-map">Agent Wranglers compliance and governance playbook</a>. In code you write, add a comment next to it with the same link.