mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(rds): include ARNs for default cluster parameter groups (#6287)
* fix(rds): include ARNs for default cluster parameter groups * test(rds): share SDK client fixture
This commit is contained in:
1 parent
e01fbd8bf8
commit
133ad743ae
6 files changed
+101
-19
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+59
@@ -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;
|
||||
}
|
||||
}
|
||||
+4
-16
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user