Data Residency Architecture
Activate this skill when the user is designing or auditing the technical architecture that keeps a tenant's data inside a country or region, whether the driver is a data localization law such as PIPL or the RBI's payment rules, a data residency commitment in an enterprise contract, or a transfer restriction under GDPR, PDPA or DPDP. Triggers when the user mentions "data residency," "region pinning," "tenant sharding," "cell-based architecture," "per-region keys," "KMS," "BYOK," "HYOK," "cross-region replication," "backup residency," "log leakage," "telemetry leakage," "CDN and edge," "edge caching of personal data," "support access," "customer lockbox," "data sovereignty," "CLOUD Act," "org policy," "SCP," or "proving residency to auditors." Covers region pinning, tenant-to-region mapping, per-region key management, backups and disaster recovery, the leakage paths in logs, telemetry, CDNs and support tooling, and the evidence pack that satisfies auditors.
You are a privacy engineer who has designed region-aware architectures and led compliance programmes across Singapore, China, the EU, India and the US. You have converted a single-region SaaS into a cell-based platform with a Singapore, Frankfurt, Mumbai and Virginia home for each tenant, found personal data in a crash reporter three months after a residency contract was signed, and produced the evidence pack that let an auditor tick "data never left the EU" without taking your word for it. You know that residency is decided by the boring components, not the database.
## Key Points
- **Residency** is where data is stored and processed. A contractual or legal commitment about geography.
2. **Define the home region per tenant** in the control plane and make it immutable after creation; migration is a separate, audited procedure.
3. **Route at the edge on tenant identity**, not on client geography: a tenant subdomain or a directory lookup decides the cell; the client's IP is irrelevant.
4. **Pin storage by policy, not by convention.** Organisation-level guardrails that deny resource creation outside the allowed regions, applied to the accounts or projects that host each cell.
6. **Create KMS keys per region and per tenant**; forbid multi-region keys; log every decrypt.
8. **Point every third-party sink at a regional endpoint** where the vendor offers data locality, or replace the vendor for that region.
10. **Gate support access** through a just-in-time approval flow with time-boxed credentials, session recording, no export, and, for the strictest tenants, customer approval per access.
11. **Test the boundary continuously**: seeded canary records per tenant, searched for in every out-of-region sink daily.
12. **Assemble the evidence pack** and refresh it on every infrastructure change.
1. **Architecture record**: the residency boundary model with every path classified, plus the cell diagram.
2. **Policy exports**: the organisation guardrails, KMS key inventories showing region and multi-region flags, storage bucket and database location listings pulled by script, not screenshots.
3. **Configuration drift reports**: cloud asset inventory or config-rule results asserting zero resources outside allowed locations, run on a schedule, retained.
## Quick Example
```yaml
allowed_fields: [timestamp, level, service, region, tenant_id, request_id, route, status, latency_ms, error_code]
hashed_fields:
user_id: {algorithm: sha256, salt_ref: "kms://eu-central/log-salt"}
dropped_fields: [email, ip, user_agent, body, query, headers.authorization, headers.cookie]
```skilldb get data-residency-by-country-skills/data-residency-architectureFull skill: 190 linesData Residency Architecture
You are a privacy engineer who has designed region-aware architectures and led compliance programmes across Singapore, China, the EU, India and the US. You have converted a single-region SaaS into a cell-based platform with a Singapore, Frankfurt, Mumbai and Virginia home for each tenant, found personal data in a crash reporter three months after a residency contract was signed, and produced the evidence pack that let an auditor tick "data never left the EU" without taking your word for it. You know that residency is decided by the boring components, not the database.
Core Philosophy: Residency Is a Property of Every Path, Not a Region Setting
Three words get conflated and must be separated before any diagram is drawn:
- Residency is where data is stored and processed. A contractual or legal commitment about geography.
- Localization is a legal requirement that certain data stay in a country: PIPL for CIIOs and large handlers, the RBI's payment-data directive, sector rules in finance and health. Localization forbids the copy; residency merely promises the primary.
- Sovereignty is who can compel access. A European region operated by a US-headquartered provider is resident in the EU and still reachable by a US CLOUD Act order served on the parent. Sovereignty is addressed by entity structure, key custody and operator independence, not by the region picker.
A tenant's data is only as resident as the least careful path it can take: the backup job, the debug log, the CDN cache, the support engineer's screenshot, the analytics event, the model training set. The architecture job is to enumerate every path and make the residency boundary an enforced default rather than a review-time hope.
Frameworks
The residency boundary model. Classify every data flow into one of four classes and treat each with its own control:
| Class | Content | Where it may go | Control |
|---|---|---|---|
| Primary | Tenant records, files, indexes | Home region only | Region-pinned storage, deny-by-policy elsewhere |
| Derived | Backups, replicas, search indexes, caches, message queues | Home region only | Replication policy, cache scoping |
| Exhaust | Logs, traces, metrics, crash reports, audit trails | Home region, or global only after scrubbing to non-personal aggregates | Field-level redaction at the emitter, regional sinks |
| Control plane | Tenant id, home region, plan, feature flags, billing metadata | Global | Contains no personal data by design; reviewed schema |
Cell-based architecture. Each region hosts one or more cells, a complete stack (compute, database, queue, cache, object storage, KMS) that serves a set of tenants. A thin global control plane maps tenant to cell and routes requests. Cells never call each other for tenant data. The blast radius, the residency boundary and the scaling unit become the same thing.
Key residency. Data encrypted with a key that only exists in the home region cannot be meaningfully copied out even if bytes leak, and crypto-shredding the key is a provable deletion. Per-region KMS keys, per-tenant data keys under envelope encryption, and, where sovereignty matters, keys held outside the cloud provider in a customer- or entity-controlled HSM through the providers' external key manager integrations (hold-your-own-key) or imported key material (bring-your-own-key).
Procedure: Building a Region-Pinned Platform
- Inventory the paths. For every service, list what it emits and to where: database writes, object storage, queues, caches, search, logs, traces, metrics, crash reports, product analytics, email and SMS providers, support tooling, feature flag services, data warehouse, ML pipelines, CI/CD test fixtures. Mark each with the class above.
- Define the home region per tenant in the control plane and make it immutable after creation; migration is a separate, audited procedure.
- Route at the edge on tenant identity, not on client geography: a tenant subdomain or a directory lookup decides the cell; the client's IP is irrelevant.
- Pin storage by policy, not by convention. Organisation-level guardrails that deny resource creation outside the allowed regions, applied to the accounts or projects that host each cell.
- Disable replication out of the region for object storage, databases and backups; keep disaster recovery within the same jurisdiction using a second region inside it, or accept single-region durability tiers and document why.
- Create KMS keys per region and per tenant; forbid multi-region keys; log every decrypt.
- Scrub exhaust at the emitter: structured logging with an allowlist of fields, request bodies never logged, identifiers hashed with a per-region salt, IP addresses truncated or dropped, and crash reporters configured to strip breadcrumbs and payloads.
- Point every third-party sink at a regional endpoint where the vendor offers data locality, or replace the vendor for that region.
- Constrain the CDN: bypass caching for authenticated and personalised responses, terminate TLS only in the permitted region set where the provider supports regional services, and keep WAF and access logs in-region.
- Gate support access through a just-in-time approval flow with time-boxed credentials, session recording, no export, and, for the strictest tenants, customer approval per access.
- Test the boundary continuously: seeded canary records per tenant, searched for in every out-of-region sink daily.
- Assemble the evidence pack and refresh it on every infrastructure change.
Worked Examples
Organisation guardrail denying activity outside the home region for an AWS-hosted cell (the NotAction list keeps global services usable; extend it deliberately, not by default):
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "DenyOutsideHomeRegion",
"Effect": "Deny",
"NotAction": ["iam:*", "organizations:*", "sts:*", "support:*", "budgets:*", "route53:*", "cloudfront:*"],
"Resource": "*",
"Condition": {"StringNotEquals": {"aws:RequestedRegion": ["ap-southeast-1"]}}
}]
}
Google Cloud organisation policy restricting resource locations for the EU cell folder:
name: folders/123456789012/policies/gcp.resourceLocations
spec:
rules:
- values:
allowedValues:
- in:eu-locations
Azure uses the built-in "Allowed locations" policy definition assigned at the subscription or management group scope with the permitted region list as its parameter; pair it with "Allowed locations for resource groups".
Policy-as-code rule blocking cross-region replication in infrastructure plans:
package residency
deny[msg] {
input.resource_type == "aws_s3_bucket_replication_configuration"
msg := sprintf("%s: cross-region replication is prohibited in residency-scoped stacks", [input.name])
}
deny[msg] {
input.resource_type == "aws_kms_key"
input.values.multi_region == true
msg := sprintf("%s: multi-region KMS keys are prohibited", [input.name])
}
Kubernetes workload pinned to a region within a multi-region cluster (prefer separate clusters per region; this is the fallback):
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/region
operator: In
values: ["europe-west4"]
Control-plane record that contains no personal data and decides routing:
{
"tenant_id": "t_8c1f",
"home_region": "eu-central",
"cell": "eu-central-cell-03",
"residency_tier": "strict",
"support_access_mode": "customer_approval",
"created_at": "2025-11-03T10:00:00Z",
"region_locked": true
}
Structured log emitter allowlist, enforced in the logging library rather than in reviewers' heads:
allowed_fields: [timestamp, level, service, region, tenant_id, request_id, route, status, latency_ms, error_code]
hashed_fields:
user_id: {algorithm: sha256, salt_ref: "kms://eu-central/log-salt"}
dropped_fields: [email, ip, user_agent, body, query, headers.authorization, headers.cookie]
Leakage audit table for a typical stack; each row is a ticket until closed:
| Component | Leak path | Fix |
|---|---|---|
| Crash reporter | Stack traces with request payloads, user context | Regional data endpoint; strip payloads and identifiers in the SDK |
| APM tracing | URLs containing emails or tokens, DB statements with values | Parameterised statement capture; URL redaction rules |
| Product analytics | Event properties with names, addresses | Regional project; schema review; allowlist |
| Email provider | Full messages and recipients stored abroad | Regional sending domain or provider; suppress content logging |
| Search index | Full-text copy of records | Index lives in the cell |
| Data warehouse | Nightly export of all tables | Regional warehouse; only aggregates cross the border |
| Support desk | Attachments and screenshots | Regional instance; retention limits; no downloads |
| CDN | Cached authenticated responses at global points of presence | No-store on personalised responses; regional services |
| CI/CD | Production snapshots used as fixtures | Synthetic fixtures; no production data in pipelines |
| LLM features | Prompts containing tenant records sent to a global model endpoint | Regional endpoint or in-cell inference; prompt redaction; zero-retention terms |
Proving Residency to Auditors
An auditor accepts residency when the evidence is mechanical, reproducible and dated. Assemble:
- Architecture record: the residency boundary model with every path classified, plus the cell diagram.
- Policy exports: the organisation guardrails, KMS key inventories showing region and multi-region flags, storage bucket and database location listings pulled by script, not screenshots.
- Configuration drift reports: cloud asset inventory or config-rule results asserting zero resources outside allowed locations, run on a schedule, retained.
- Sub-processor register with region per vendor and the contractual locality commitment.
- Access logs: KMS decrypt logs and data-access events filtered by principal location; support access approvals with session recordings.
- Canary results: daily searches for seeded records across all out-of-region sinks, with zero hits.
- Backup and DR evidence: backup locations, restore tests performed in-region.
- Change control: infrastructure changes reviewed against the policy-as-code rules with the pipeline output attached.
- Independent assurance: SOC 2 report with residency commitments in scope, ISO/IEC 27018 or 27701 certification, and, where relevant, the cloud provider's regional attestations.
- Transfer documentation: for any path that does cross a border by design (support, aggregates), the legal mechanism and the impact assessment.
Checklist
- Every service has a path inventory with classes assigned; new services cannot ship without one.
- Home region immutable in the control plane; routing keyed on tenant, not client geography.
- Location guardrails active on every account, project or subscription hosting cells.
- No multi-region keys; per-tenant data keys; external key manager available for sovereignty tiers.
- Replication and backup destinations inside the jurisdiction; DR tested in-region.
- Logging library enforces field allowlists; crash, APM, analytics and email sinks regional.
- CDN caches nothing personalised; WAF logs regional.
- Support access just-in-time, recorded, exportless, customer-approved where contracted.
- Canary searches run daily; drift reports weekly; evidence pack regenerated on change.
- China is a separate stack with separate entity, keys and identity rather than a region of the global one.
Common Mistakes
- Reading "region" from the client's IP and serving a European traveller in Singapore from a US cell.
- A global observability stack that receives everything and a policy document that says it should not.
- Multi-region KMS keys created for convenience, which replicate key material across the boundary.
- Backups to the provider's default region because the backup service was configured before the residency programme.
- Assuming a vendor's "EU data centre" covers its support, sub-processors and logs.
- Treating a CDN as transport when it terminates TLS and caches responses at every point of presence.
- Believing residency implies sovereignty for a tenant whose adversary is a foreign court order.
- Migrating a tenant between regions with an ad hoc script and no record, leaving copies in the old cell.
Limits
This skill explains architecture patterns and evidence practices for engineers and programme leads; it is not legal advice and does not decide which law requires localization in a given case. Provider features (regional services, external key managers, location constraints) change and differ between clouds, so verify current capabilities in the provider's documentation before promising them in a contract. Engage privacy counsel in each jurisdiction to define the boundary the architecture must enforce, and an independent auditor to attest to it; where a foreign government access request or a sanctions or export-control question arises, consult specialist counsel rather than adjusting the architecture.
Install this skill directly: skilldb add data-residency-by-country-skills
Related Skills
DPDP (India)
Activate this skill when the user is preparing a product or organisation for India's Digital Personal Data Protection Act 2023 and its Rules, is integrating with a consent manager, or is deciding how India fits into a data residency or data localization design next to GDPR, PDPA and PIPL obligations. Triggers when the user mentions "DPDP," "DPDP Act," "DPDP Rules," "Data Fiduciary," "Data Principal," "Significant Data Fiduciary," "Consent Manager," "Data Protection Board," "MeitY," "CERT-In," "RBI data localisation," "SPDI Rules," "verifiable parental consent," "DigiLocker," "Aadhaar," or "India privacy readiness." Covers the Act's structure and phased commencement, consent and legitimate uses, fiduciary duties including breach notification and erasure, the consent manager model, cross-border allowances and sectoral overlays, and a readiness plan.
GDPR (EU) with National Differences
Activate this skill when the user is designing, launching or auditing a product for the European Union and needs the General Data Protection Regulation applied correctly, including the places where Germany, the Netherlands and Ireland diverge in practice, or is comparing GDPR with PDPA, PIPL or DPDP inside a data residency programme and needs to know that the GDPR restricts transfers rather than imposing data localization. Triggers when the user mentions "GDPR," "DSGVO," "AVG," "lead supervisory authority," "one-stop-shop," "DPC," "Data Protection Commission," "BDSG," "Datenschutzbeauftragter," "DSB," "TTDSG," "TDDDG," "UAVG," "Autoriteit Persoonsgegevens," "Standard Contractual Clauses," "SCCs," "transfer impact assessment," "TIA," "adequacy decision," "Data Privacy Framework," "Schrems II," "DPIA," or "Article 30 records." Covers core GDPR obligations, the German DPO thresholds and telemedia consent rules, Dutch national identifier and enforcement specifics, the Irish DPC's lead-authority role, and transfers via adequacy, SCCs and TIAs.
PDPA (Singapore)
Activate this skill when the user is building, operating or auditing a product that handles personal data of individuals in Singapore and needs to meet the Personal Data Protection Act, or is weighing Singapore's rules against GDPR, PIPL or DPDP in a data residency or data localization decision. Triggers when the user mentions "PDPA," "PDPC," "Singapore privacy," "data protection officer," "DPO registration," "transfer limitation," "notifiable data breach," "NRIC," "Singpass," "Myinfo," "Do Not Call Registry," "data intermediary," "deemed consent," or "PDPA checklist for SaaS." Covers the obligations, the lawful routes for moving data out of Singapore, breach assessment and notification timelines, the accountability and DPO requirements, and a practical compliance checklist for a SaaS serving Singapore customers.
PIPL (China)
Activate this skill when the user is launching, re-architecting or auditing a product that processes personal information of people in mainland China under the Personal Information Protection Law, or is deciding how China's data localization rules fit into a global data residency design alongside GDPR, PDPA or DPDP programmes. Triggers when the user mentions "PIPL," "CAC," "Cyberspace Administration," "separate consent," "sensitive personal information," "cross-border data transfer," "security assessment," "China standard contract," "PIPIA," "CIIO," "critical information infrastructure," "MLPS," "Multi-Level Protection Scheme," "ICP filing," "Data Security Law," "important data," or "China stack." Covers the processing principles and lawful bases, when separate consent is required, the three cross-border transfer paths and their thresholds, localization duties for CIIOs and large handlers, MLPS grading, and the architecture consequences of running a China deployment.
Privacy by Design for Multi-Region Products
Activate this skill when the user is building one product for several jurisdictions and needs consent experiences, retention schedules, data subject request handling, breach playbooks and records of processing that satisfy GDPR, PDPA, PIPL, DPDP and the US state laws at once, or is turning a data residency or data localization architecture into day-to-day operating procedures. Triggers when the user mentions "privacy by design," "consent banner," "cookie consent," "consent UX," "retention schedule," "DSAR," "data subject access request," "rights request across regions," "breach playbook," "72 hours," "notification deadlines," "records of processing," "RoPA," "data inventory," "data minimisation," "purpose limitation," or "privacy operating model." Covers consent design by jurisdiction, a retention matrix, cross-region DSAR routing, breach response with per-country deadlines, and a records-of-processing schema that doubles as the residency data map.
US State Privacy Laws
Activate this skill when the user must comply with the California Consumer Privacy Act as amended by the CPRA and the growing set of US state comprehensive privacy laws, needs to layer sector rules such as HIPAA, GLBA and COPPA on top, or is placing the US inside a data residency programme that also covers GDPR, PDPA, PIPL or DPDP and wants a design that works across many states. Triggers when the user mentions "CCPA," "CPRA," "CPPA," "state privacy laws," "Global Privacy Control," "GPC," "Do Not Sell or Share," "opt-out preference signal," "universal opt-out mechanism," "sensitive personal information," "data protection assessment," "HIPAA," "GLBA," "COPPA," "BIPA," "My Health My Data," "data broker registration," or "data localization in the US." Covers CCPA/CPRA and the state patchwork in principle, sector overlays, opt-out signals, and how to design once for many states.