mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(rds): report the RDS hosted zone id on clusters and instances (#6826)
* fix(rds): report the RDS hosted zone id on clusters and instances DescribeDBClusters omitted HostedZoneId and DB instance endpoints omitted Endpoint.HostedZoneId, so Terraform's aws_rds_cluster.hosted_zone_id was empty and Route 53 alias records pointing at RDS endpoints failed. Add a per-region rdsHostedZoneId fact to region-facts.json through the generator, with the us-east-1 value from the AWS CLI RDS documentation, and read it through AwsRegionFacts.rdsHostedZoneId. Regions without a captured value fall back to the us-east-1 zone; Floci's Route 53 resolves alias targets by DNS name, so the fallback does not affect resolution. The value is looked up when the response is built, so existing clusters and instances report it too. Closes #6778 * fix(rds): read the RDS hosted zone from the CLI example and keep the fallback in RDS AwsRegionFacts.rdsHostedZoneId now returns an Optional like every other accessor there, and RdsQueryHandler owns the fallback zone for regions with no captured value, the way API Gateway keeps its own placeholder. A missing us-east-1 entry can no longer break a describe call. The generator reads the us-east-1 zone from a snapshot of the AWS CLI describe-db-instances example under aws-docs/partition-guides, as the GovCloud API Gateway zones come from the GovCloud guide, instead of a typed-in constant. The parse is required and fails on a missing, wrong-region or ambiguous example. Adding another region is now a data change.
This commit is contained in:
1 parent
6acadc3404
commit
628beeef85
9 files changed
+119
-6
No files matched your search
@@ -12,6 +12,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
/** The vendored per-region tables, pinned against the Terraform and CDK rows they came from. */
|
||||
class AwsRegionFactsTest {
|
||||
|
||||
@Test
|
||||
void rdsHostedZoneIsPresentOnlyForCapturedRegions() {
|
||||
assertEquals(Optional.of("Z2R2ITUGPM61AM"), AwsRegionFacts.rdsHostedZoneId("us-east-1"));
|
||||
assertTrue(AwsRegionFacts.rdsHostedZoneId("eu-west-1").isEmpty());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"us-east-1, Z35SXDOTRQ7X7K, Z26RNL4JYFTOTI, Z3AQBSTGFYJSTF",
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package io.github.hectorvent.floci.services.rds;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RdsMockProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import software.amazon.awssdk.services.rds.RdsClient;
|
||||
import software.amazon.awssdk.services.rds.model.CreateDbClusterResponse;
|
||||
|
||||
import static io.github.hectorvent.floci.testing.RdsRequests.rdsClient;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(RdsMockProfile.class)
|
||||
class RdsHostedZoneIntegrationTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"us-east-1", "eu-west-1"})
|
||||
void clusterAndInstanceHostedZonesRoundTripThroughSdk(String region) {
|
||||
String cluster = "hosted-zone-cluster";
|
||||
String instance = "hosted-zone-instance";
|
||||
try (RdsClient client = rdsClient(region, "123456789012")) {
|
||||
boolean clusterCreated = false;
|
||||
boolean instanceCreated = false;
|
||||
try {
|
||||
CreateDbClusterResponse created = client.createDBCluster(b -> b.dbClusterIdentifier(cluster)
|
||||
.engine("aurora-postgresql").masterUsername("admin").masterUserPassword("password123"));
|
||||
clusterCreated = true;
|
||||
assertEquals("Z2R2ITUGPM61AM", created.dbCluster().hostedZoneId());
|
||||
assertEquals("Z2R2ITUGPM61AM", client.describeDBClusters(b -> b.dbClusterIdentifier(cluster))
|
||||
.dbClusters().getFirst().hostedZoneId());
|
||||
client.createDBInstance(b -> b.dbInstanceIdentifier(instance).engine("postgres")
|
||||
.dbInstanceClass("db.t3.micro").masterUsername("admin").masterUserPassword("password123")
|
||||
.allocatedStorage(20));
|
||||
instanceCreated = true;
|
||||
assertEquals("Z2R2ITUGPM61AM", client.describeDBInstances(b -> b.dbInstanceIdentifier(instance))
|
||||
.dbInstances().getFirst().endpoint().hostedZoneId());
|
||||
} finally {
|
||||
try {
|
||||
if (instanceCreated) {
|
||||
client.deleteDBInstance(b -> b.dbInstanceIdentifier(instance).skipFinalSnapshot(true));
|
||||
}
|
||||
} finally {
|
||||
if (clusterCreated) {
|
||||
client.deleteDBCluster(b -> b.dbClusterIdentifier(cluster).skipFinalSnapshot(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user