- Newest
- Most votes
- Most comments
To address the Route53 latency-based routing conflict in your multi-stack active-active deployment, you need to modify your approach to avoid creating conflicting records while still maintaining optimal latency routing.
The core issue is that you're trying to create two latency records for the same DNS name (api.example.com) with the same region attribute, which Route53 doesn't allow. Here are solutions to resolve this:
Solution 1: Single Stack Responsibility
Modify your architecture so only one stack is responsible for creating all Route53 records:
- Create a separate "DNS stack" that depends on both regional stacks
- This DNS stack creates both latency records with the correct region settings
- Remove Route53 record creation from the individual regional stacks
Solution 2: Conditional Record Creation
Implement a condition that only allows one stack to create both records:
// Only create both records in the first stack to deploy if (deploymentRegion === Region.US_EAST_1) { // Create record pointing to us-east-1 with region=us-east-1 new route53.ARecord(this, 'PrimaryRecord', { zone: myZone, recordName: 'api.example.com', target: route53.RecordTarget.fromAlias(new targets.ApiGateway(eastApi)), region: 'us-east-1' }); // Create record pointing to us-west-2 with region=us-west-2 new route53.ARecord(this, 'SecondaryRecord', { zone: myZone, recordName: 'api.example.com', target: route53.RecordTarget.fromAlias(new targets.ApiGateway(westApi)), region: 'us-west-2' }); }
Solution 3: Use CloudFormation Custom Resources
Create a custom resource that checks if a record exists before attempting to create it, and skips creation if it would conflict.
The most straightforward approach is Solution 1, where you centralize DNS management in a single stack. This provides the cleanest separation of concerns and avoids conflicts entirely while ensuring optimal latency routing.
Remember that when using latency-based routing, Route53 will automatically direct users to the endpoint with the lowest latency based on historical data, and if health checks are configured, it will fail over to the next lowest latency endpoint if the primary is unhealthy.
For more detailed investigation specific to your AWS environment, I encourage you to reach out to AWS Support for detailed guidance.
Sources
Latency-based routing in private hosted zones - Amazon Route 53
Latency-based routing - Amazon Route 53
aws-cdk-lib.aws_route53 module · AWS CDK
Prevent the automatic failback with a Route 53 health check | AWS re:Post
Relevant content
asked 3 years ago
asked 4 years ago
- AWS OFFICIALUpdated 3 years ago
