Video in progress

By law, citizens' personal data must be stored on servers inside the country, but some services run in a foreign cloud. How do you adapt the architecture?

First I map which data is personal and where it flows. Then I separate PII into its own in-country zone, with its own services, DBs, backups and logs, while services abroad work only with IDs or pseudonymous tokens. The places people most often forget are logs, traces, backups and external SaaS tools.

📖 Answer

In Uzbekistan too, the personal data law requires citizens' data to be stored in databases within the country's territory, and many countries have similar rules. This doesn't end with "moving the DB", because data flows through the whole system.

  1. Inventory. Which service stores, transfers or logs which PII. Unexpected places often turn up: an email service abroad (name and email), an APM SaaS (a phone number inside a URL in a trace), an error tracker (a request body in a stack trace), CI logs, analytics.

  2. Zoning. The PII zone is an in-country data center or local cloud: the customer-profile, kyc and documents services and their DBs, backups and logs. The other services (catalog, recommendations) can be abroad, but they see only a customerId or a pseudonymous token.

  3. Tokenization. If a service abroad needs a name or phone, it doesn't store it itself: when needed it asks the API in the PII zone, or never sees it at all. For example, the notification service in the PII zone sends the SMS, and the service abroad just says "template Y to customer X".

  4. Observability tools. Logs and traces must be free of PII, or the PII zone gets its own observability stack. Masking at the collector level (OpenTelemetry Collector processors) before anything goes to a foreign SaaS.

  5. Kafka and replication. Topics with PII are not mirrored to a foreign cluster. If events are free of PII, the flow is much freer.

  6. Backup and DR. The DR site must be in the country too: copying to a foreign region "only for backup" also violates the requirement.

The cost: local infrastructure is often more expensive and has fewer capabilities, running two environments adds operational load, and calls between zones add latency. So keep the PII zone as small as possible: only the services that truly work with PII.

And this is not a one-time project: when a new service or a new SaaS tool is added, "where does the PII go?" becomes a mandatory part of the architecture review. And confirm the exact legal requirements with lawyers, since they keep changing.