Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(rds): include ARNs for default cluster parameter groups (#6287)

Aniket Shukla133ad743ae53
diff --git a/docs/services/rds.md b/docs/services/rds.md
index cfe4f20bcb..050fb41081 100644
--- a/docs/services/rds.md
+++ b/docs/services/rds.md
@@ -202,6 +202,12 @@ checked against the instance's other window. Modifications apply immediately —
`arn:aws:rds:<region>:<account>:cluster-snapshot:<name>`. RDS reserved instances aren't
modeled (there's no reserved-instance API), so tagging doesn't apply to them.
+## Cluster parameter groups
+
+`DescribeDBClusterParameterGroups` includes `DBClusterParameterGroupArn` for managed `default.*`
+groups as well as customer-created groups, in both named and list responses. Managed default ARNs
+use the request's account, region, and partition with the `cluster-pg:<group-name>` resource form.
+
## Boolean parameters
The following parameters accept `true` or `false` (case-insensitive). Other values,
diff --git a/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java b/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java
index 1ce643fd43..e237710dde 100644
--- a/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java
@@ -6958,7 +6958,7 @@ public class RdsService implements Resettable, ResourceProvider {
if (group == null) {
ManagedClusterParameterGroup managed = managedClusterParameterGroup(name);
if (managed != null) {
- group = managed.toModel(effectiveRegion(region));
+ group = managed.toModel(effectiveRegion(region), regionResolver);
}
}
if (group == null) {
@@ -6988,7 +6988,7 @@ public class RdsService implements Resettable, ResourceProvider {
}
Map<String, DbClusterParameterGroup> unique = new LinkedHashMap<>();
for (ManagedClusterParameterGroup managed : MANAGED_CLUSTER_PARAMETER_GROUPS) {
- DbClusterParameterGroup group = managed.toModel(effectiveRegion);
+ DbClusterParameterGroup group = managed.toModel(effectiveRegion, regionResolver);
unique.put(group.getDbClusterParameterGroupName(), group);
}
List<DbClusterParameterGroup> storedGroups;
@@ -7036,9 +7036,10 @@ public class RdsService implements Resettable, ResourceProvider {
}
private record ManagedClusterParameterGroup(String name, String family, String description) {
- private DbClusterParameterGroup toModel(String region) {
+ private DbClusterParameterGroup toModel(String region, RegionResolver regionResolver) {
DbClusterParameterGroup group = new DbClusterParameterGroup(name, family, description);
group.setRegion(region);
+ group.setDbClusterParameterGroupArn(regionResolver.buildArn("rds", region, "cluster-pg:" + name));
return group;
}
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsDefaultClusterParameterArnIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsDefaultClusterParameterArnIntegrationTest.java
new file mode 100644
index 0000000000..390e21008a
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsDefaultClusterParameterArnIntegrationTest.java
@@ -0,0 +1,59 @@
+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.CsvSource;
+import software.amazon.awssdk.services.rds.RdsClient;
+import software.amazon.awssdk.services.rds.model.DBClusterParameterGroup;
+
+import java.util.List;
+
+import static io.github.hectorvent.floci.testing.RdsRequests.rdsClient;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+@TestProfile(RdsMockProfile.class)
+class RdsDefaultClusterParameterArnIntegrationTest {
+
+ private static final String GROUP_NAME = "default.aurora-postgresql16";
+
+ @ParameterizedTest
+ @CsvSource({"us-east-1,111111111111,aws", "eu-west-2,222222222222,aws",
+ "cn-north-1,333333333333,aws-cn", "us-gov-west-1,444444444444,aws-us-gov"})
+ void namedManagedDefaultsCarryTheRequestScopedArn(String region, String account, String partition) {
+ try (RdsClient client = rdsClient(region, account)) {
+ List<DBClusterParameterGroup> groups = client.describeDBClusterParameterGroups(request ->
+ request.dbClusterParameterGroupName(GROUP_NAME)).dbClusterParameterGroups();
+ assertEquals(1, groups.size());
+ DBClusterParameterGroup group = groups.get(0);
+ assertEquals(GROUP_NAME, group.dbClusterParameterGroupName());
+ assertEquals("aurora-postgresql16", group.dbParameterGroupFamily());
+ assertEquals("Default cluster parameter group", group.description());
+ assertEquals(arn(partition, region, account, GROUP_NAME), group.dbClusterParameterGroupArn());
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({"us-east-1,111111111111,aws", "eu-west-2,222222222222,aws",
+ "cn-north-1,333333333333,aws-cn", "us-gov-west-1,444444444444,aws-us-gov"})
+ void listedManagedDefaultsCarryTheRequestScopedArns(String region, String account, String partition) {
+ try (RdsClient client = rdsClient(region, account)) {
+ List<DBClusterParameterGroup> groups = client.describeDBClusterParameterGroups()
+ .dbClusterParameterGroups().stream()
+ .filter(group -> group.dbClusterParameterGroupName().startsWith("default."))
+ .toList();
+ assertTrue(groups.stream().anyMatch(group -> GROUP_NAME.equals(group.dbClusterParameterGroupName())));
+ for (DBClusterParameterGroup group : groups) {
+ assertEquals(arn(partition, region, account, group.dbClusterParameterGroupName()),
+ group.dbClusterParameterGroupArn());
+ }
+ }
+ }
+
+ private static String arn(String partition, String region, String account, String name) {
+ return "arn:" + partition + ":rds:" + region + ":" + account + ":cluster-pg:" + name;
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsManagedSecretIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsManagedSecretIntegrationTest.java
index 3b35c6055b..aa59e2bd69 100644
--- a/src/test/java/io/github/hectorvent/floci/services/rds/RdsManagedSecretIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsManagedSecretIntegrationTest.java
@@ -6,24 +6,19 @@ import io.github.hectorvent.floci.services.kms.KmsService;
import io.github.hectorvent.floci.testing.RdsMockProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
-import io.restassured.RestAssured;
import jakarta.inject.Inject;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.rds.RdsClient;
import software.amazon.awssdk.services.rds.model.CreateDbInstanceRequest;
import software.amazon.awssdk.services.rds.model.DBCluster;
import software.amazon.awssdk.services.rds.model.DBInstance;
import software.amazon.awssdk.services.rds.model.RdsException;
-import java.net.URI;
import java.util.Map;
import java.util.UUID;
+import static io.github.hectorvent.floci.testing.RdsRequests.rdsClient;
import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -48,7 +43,7 @@ class RdsManagedSecretIntegrationTest {
void sdkRejectsMemberCredentialParametersAndAllowsOmittedRetry(String engine, String field, boolean matching) {
String id = "member-input-" + UUID.randomUUID().toString().substring(0, 8);
String memberId = id + "-member";
- try (RdsClient rds = client("us-east-1", "000000000000")) {
+ try (RdsClient rds = rdsClient("us-east-1", "000000000000")) {
rds.createDBCluster(request -> request.dbClusterIdentifier(id).engine(engine)
.masterUsername("clusteradmin").masterUserPassword("ClusterPassword!"));
try {
@@ -90,19 +85,12 @@ class RdsManagedSecretIntegrationTest {
}
}
- private static RdsClient client(String region, String account) {
- return RdsClient.builder().endpointOverride(URI.create("http://localhost:" + RestAssured.port))
- .httpClientBuilder(UrlConnectionHttpClient.builder()).region(Region.of(region))
- .credentialsProvider(StaticCredentialsProvider.create(
- AwsBasicCredentials.create(account, "test-secret-key"))).build();
- }
-
@ParameterizedTest
@CsvSource({"us-east-1,000000000000", "cn-north-1,000000000000",
"us-east-1,222222222222", "cn-north-1,222222222222"})
void sdkReportsTheActualDefaultManagedKeyForInstancesAndClusters(String region, String account) {
String id = "managed-key-" + UUID.randomUUID().toString().substring(0, 8);
- try (RdsClient rds = client(region, account)) {
+ try (RdsClient rds = rdsClient(region, account)) {
DBInstance instance = rds.createDBInstance(request -> request
.dbInstanceIdentifier(id)
.dbInstanceClass("db.t4g.small")
@@ -150,7 +138,7 @@ class RdsManagedSecretIntegrationTest {
void sdkClusterMemberLeavesTheManagedSecretOnTheCluster(String engine, String region, String account)
throws Exception {
String id = "cluster-managed-" + UUID.randomUUID().toString().substring(0, 8);
- try (RdsClient rds = client(region, account)) {
+ try (RdsClient rds = rdsClient(region, account)) {
DBCluster cluster = rds.createDBCluster(request -> request.dbClusterIdentifier(id).engine(engine)
.masterUsername("clusteradmin").manageMasterUserPassword(true)).dbCluster();
try {
diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java
index 564f0892b2..6b05383680 100644
--- a/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java
@@ -4341,6 +4341,17 @@ class RdsServiceTest {
assertEquals(before, after);
}
+ @ParameterizedTest
+ @CsvSource({"us-east-1,aws", "eu-west-2,aws", "cn-north-1,aws-cn", "us-gov-west-1,aws-us-gov"})
+ void managedClusterParameterGroupsCarryRegionAndPartitionScopedArns(String region, String partition) {
+ for (DbClusterParameterGroup group : rdsService.listDbClusterParameterGroups(null, region)) {
+ String name = group.getDbClusterParameterGroupName();
+ String expectedArn = "arn:" + partition + ":rds:" + region + ":123456789012:cluster-pg:" + name;
+ assertEquals(expectedArn, group.getDbClusterParameterGroupArn());
+ assertEquals(expectedArn, rdsService.getDbClusterParameterGroup(name, region).getDbClusterParameterGroupArn());
+ }
+ }
+
@Test
void unsupportedManagedDefaultNamesAreNotFabricatedByReads() {
List<String> before = rdsService.listDbClusterParameterGroups(null).stream()
diff --git a/src/test/java/io/github/hectorvent/floci/testing/RdsRequests.java b/src/test/java/io/github/hectorvent/floci/testing/RdsRequests.java
index ba7c1b7c78..4dff874c75 100644
--- a/src/test/java/io/github/hectorvent/floci/testing/RdsRequests.java
+++ b/src/test/java/io/github/hectorvent/floci/testing/RdsRequests.java
@@ -1,6 +1,14 @@
package io.github.hectorvent.floci.testing;
+import io.restassured.RestAssured;
import io.restassured.specification.RequestSpecification;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.rds.RdsClient;
+
+import java.net.URI;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
@@ -13,4 +21,13 @@ public final class RdsRequests {
"AWS4-HMAC-SHA256 Credential=test/20261011/us-east-1/rds/aws4_request")
.contentType(URLENC).formParam("Action", action).formParam("Version", "2014-10-31");
}
+
+ public static RdsClient rdsClient(String region, String account) {
+ return RdsClient.builder()
+ .endpointOverride(URI.create("http://localhost:" + RestAssured.port))
+ .httpClientBuilder(UrlConnectionHttpClient.builder())
+ .region(Region.of(region))
+ .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(account, "test-secret-key")))
+ .build();
+ }
}