<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1" -->

---
title: Building a multi-Region API with Prisma ORM and Amazon...
description: A step-by-step guide to building a multi-Region active-active API using Prisma ORM and Amazon Aurora DSQL. Covers the key adaptations needed to make Prisma...
canonical: https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a multi-Region API with Prisma ORM and Amazon Aurora DSQL | daily.dev
og:description: A step-by-step guide to building a multi-Region active-active API using Prisma ORM and Amazon Aurora DSQL. Covers the key adaptations needed to make Prisma...
og:url: https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1
og:image: https://api.daily.dev/og/posts/61cWyhxL1.png
og:image:alt: Building a multi-Region API with Prisma ORM and Amazon Aurora DSQL
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a multi-Region API with Prisma ORM and Amazon Aurora DSQL

**[AWS Database Blog](https://daily.dev/sources/aws-database-blog)** · 11 min read · 0 upvotes · 0 comments

## Summary

A step-by-step guide to building a multi-Region active-active API using Prisma ORM and Amazon Aurora DSQL. Covers the key adaptations needed to make Prisma work with DSQL's constraints (no foreign keys, UUID primary keys, async index creation), how to implement a MultiRegionDsqlClient with in-process failover, IAM-based authentication with short-lived tokens, and deployment across two AWS Regions with Route 53 latency-based routing. Includes security considerations, cost breakdown, and a full integration test for validating failover behavior.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://aws.amazon.com/blogs/database/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql>

## Questions this post answers

### How do I configure Prisma schema to work with Amazon Aurora DSQL since it doesn't support foreign keys or sequences?

Set relationMode = "prisma" in the Prisma schema so referential integrity is enforced in application code instead of database-level foreign key constraints, since DSQL doesn't support them. Use gen_random_uuid() for primary keys instead of autoincrement(), since DSQL lacks sequences and UUIDs are globally unique across Regions. Model-level @@index directives get transformed by the aurora-dsql-prisma CLI into CREATE INDEX ASYNC statements that DSQL supports.

_daily.dev surfaces practical guides like this for developers adapting ORMs to distributed databases._

### How does automatic failover work between two Amazon Aurora DSQL Regions in a Node.js application without restarting the process?

A MultiRegionDsqlClient establishes and health-checks connections to both Regions at startup using SELECT 1, then exposes a failover() method that switches the active Prisma client to the secondary in-process when the active client throws ECONNREFUSED, ETIMEDOUT, or an unavailable error. Failover is one-shot with no automatic fail-back, so the process must restart or use a circuit breaker to retest the primary later.

_Developers designing resilient multi-region APIs can track failover patterns like this on daily.dev._

### Is it safe to automatically retry a database write after a connection failover to a secondary region in Amazon Aurora DSQL?

Retrying writes after failover is risky because ETIMEDOUT and unavailable errors are ambiguous about whether the write already committed on the primary, and retrying can create duplicate records. ECONNREFUSED is safe to retry since the connection never reached the primary. For production, restrict failover retries to reads only, or add idempotency keys to mutation endpoints so duplicates can be detected and ignored.

_Teams weighing write-safety trade-offs in distributed databases can find this kind of detail on daily.dev._

## Similar posts on daily.dev

- [Build a Spring Boot REST API with Amazon Aurora DSQL](https://daily.dev/posts/build-a-spring-boot-rest-api-with-amazon-aurora-dsql-n9w0d0wit) · AWS Database Blog · 1 upvotes · 0 comments
- [Amazon Aurora DSQL adds multi-Region cluster support in four more Regions](https://daily.dev/posts/amazon-aurora-dsql-adds-multi-region-cluster-support-in-four-more-regions-0pgaip08e) · AWS · 0 upvotes · 0 comments
- [User authentication and session management with Amazon Aurora DSQL](https://daily.dev/posts/user-authentication-and-session-management-with-amazon-aurora-dsql-nldf9icyf) · AWS Database Blog · 0 upvotes · 0 comments
- [Amazon Aurora DSQL is now available in five additional AWS Regions](https://daily.dev/posts/amazon-aurora-dsql-is-now-available-in-five-additional-aws-regions-ndgolws2k) · AWS · 0 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#distributed-systems](https://daily.dev/tags/distributed-systems), [#prisma](https://daily.dev/tags/prisma)

[View this post on daily.dev](https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building a multi-Region API with Prisma ORM and Amazon Aurora DSQL","url":"https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1"},"datePublished":"2026-07-21T17:07:39.485Z","dateModified":"2026-09-14T07:38:56.319Z","description":"A step-by-step guide to building a multi-Region active-active API using Prisma ORM and Amazon Aurora DSQL. Covers the key adaptations needed to make Prisma...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5ed1317be965f6799f4cbc80e0a71f2f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5ed1317be965f6799f4cbc80e0a71f2f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"AWS Database Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"AWS Database Blog","logo":"https://media.daily.dev/image/upload/s--En-avd2a--/f_auto,q_auto/v1780213446/logos/aws-database-blog?_a=BAMAMiWQ0","url":"https://daily.dev/sources/aws-database-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,distributed-systems,prisma","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AWS Database Blog","item":"https://daily.dev/sources/aws-database-blog"},{"@type":"ListItem","position":3,"name":"Building a multi-Region API with Prisma ORM and Amazon Aurora DSQL"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/building-a-multi-region-api-with-prisma-orm-and-amazon-aurora-dsql-61cwyhxl1#faq","mainEntity":[{"@type":"Question","name":"How do I configure Prisma schema to work with Amazon Aurora DSQL since it doesn't support foreign keys or sequences?","acceptedAnswer":{"@type":"Answer","text":"Set relationMode = \"prisma\" in the Prisma schema so referential integrity is enforced in application code instead of database-level foreign key constraints, since DSQL doesn't support them. Use gen_random_uuid() for primary keys instead of autoincrement(), since DSQL lacks sequences and UUIDs are globally unique across Regions. Model-level @@index directives get transformed by the aurora-dsql-prisma CLI into CREATE INDEX ASYNC statements that DSQL supports. daily.dev surfaces practical guides like this for developers adapting ORMs to distributed databases."}},{"@type":"Question","name":"How does automatic failover work between two Amazon Aurora DSQL Regions in a Node.js application without restarting the process?","acceptedAnswer":{"@type":"Answer","text":"A MultiRegionDsqlClient establishes and health-checks connections to both Regions at startup using SELECT 1, then exposes a failover() method that switches the active Prisma client to the secondary in-process when the active client throws ECONNREFUSED, ETIMEDOUT, or an unavailable error. Failover is one-shot with no automatic fail-back, so the process must restart or use a circuit breaker to retest the primary later. Developers designing resilient multi-region APIs can track failover patterns like this on daily.dev."}},{"@type":"Question","name":"Is it safe to automatically retry a database write after a connection failover to a secondary region in Amazon Aurora DSQL?","acceptedAnswer":{"@type":"Answer","text":"Retrying writes after failover is risky because ETIMEDOUT and unavailable errors are ambiguous about whether the write already committed on the primary, and retrying can create duplicate records. ECONNREFUSED is safe to retry since the connection never reached the primary. For production, restrict failover retries to reads only, or add idempotency keys to mutation endpoints so duplicates can be detected and ignored. Teams weighing write-safety trade-offs in distributed databases can find this kind of detail on daily.dev."}}]}
```

