fix(rds): support tagging DB proxy target groups (#3145)

RdsService's TagResource/UntagResource/ListTagsForResource dispatch
(resolveTagHandle) already covers db instances, clusters, subnet
groups, parameter groups, cluster parameter groups, option groups,
and DB proxies, but fell through to "not yet implemented by Floci"
for target-group ARNs even though every DB proxy Floci creates gets
its own default target group with a real ARN. Real AWS's
AddTagsToResource operates on target-group ARNs (it reports
DBProxyTargetGroupNotFoundFault when one doesn't exist), so this
closes that specific gap by giving DbProxyTargetGroup a tags map and
wiring it into resolveTagHandle the same way db-proxy already is.

Snapshot, reserved-instance, and event-subscription ARNs still fall
through to the same message, since Floci doesn't model those
resources at all yet: tagging them is out of scope until that
modeling work happens.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-06 15:27:34 -05:00
1 parent 691453086a
commit e0bf589972
3 files changed
+59 -2

No files matched your search

@@ -840,8 +840,30 @@ public class RdsService implements Resettable, ResourceProvider {
putOptionGroupForRegion(resourceId, effectiveRegion, group);
});
}
// Valid RDS resource types Floci does not model yet (snapshot, ri, ...) — taggable
// on real AWS, so the message states the Floci limitation rather than AWS semantics.
case "target-group" -> {
DbProxyTargetGroup targetGroup = proxyTargetGroups.scan(k -> true).stream()
.filter(candidate -> effectiveRegion.equals(
regionFromArn(candidate.getTargetGroupArn())))
.filter(candidate -> resourceName.equals(candidate.getTargetGroupArn()))
.findFirst()
.orElseThrow(() -> new AwsException("DBProxyTargetGroupNotFoundFault",
"DB proxy target group " + resourceId + " not found.", 404));
targetGroup = findProxyTargetGroup(targetGroup.getDbProxyName(), effectiveRegion)
.filter(candidate -> resourceName.equals(candidate.getTargetGroupArn()))
.orElseThrow(() -> new AwsException("DBProxyTargetGroupNotFoundFault",
"DB proxy target group " + resourceId + " not found.", 404));
DbProxyTargetGroup resolvedTargetGroup = targetGroup;
yield new TagHandle(targetGroup.getTags(), updated -> {
DbProxyTargetGroup updatedTargetGroup = copyProxyTargetGroup(resolvedTargetGroup);
updatedTargetGroup.setTags(updated);
putTargetGroupForAccount(currentAccountId(),
dbProxyKey(effectiveRegion, resolvedTargetGroup.getDbProxyName()),
updatedTargetGroup);
});
}
// Valid RDS resource types Floci does not model yet (snapshot, ri, es, secgrp, ...):
// taggable on real AWS, so the message states the Floci limitation rather than AWS
// semantics.
default -> throw new AwsException("InvalidParameterValue",
"Tagging for resource type '" + type + "' is not yet implemented by Floci: " + resourceName, 400);
};
@@ -4033,6 +4055,7 @@ public class RdsService implements Resettable, ResourceProvider {
copy.setInitQuery(source.getInitQuery());
copy.setSessionPinningFilters(source.getSessionPinningFilters());
copy.setTargets(source.getTargets());
copy.setTags(source.getTags());
return copy;
}
@@ -4,7 +4,9 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* The (single, always named {@code "default"}) target group of an {@code AWS::RDS::DBProxy}. Holds
@@ -26,6 +28,7 @@ public class DbProxyTargetGroup {
private String initQuery;
private List<String> sessionPinningFilters = new ArrayList<>();
private List<DbProxyTarget> targets = new ArrayList<>();
private Map<String, String> tags = new LinkedHashMap<>();
public DbProxyTargetGroup() {}
@@ -74,4 +77,9 @@ public class DbProxyTargetGroup {
public void setTargets(List<DbProxyTarget> targets) {
this.targets = targets != null ? new ArrayList<>(targets) : new ArrayList<>();
}
public Map<String, String> getTags() { return tags; }
public void setTags(Map<String, String> tags) {
this.tags = tags != null ? new LinkedHashMap<>(tags) : new LinkedHashMap<>();
}
}
@@ -1014,6 +1014,32 @@ class RdsServiceTest {
rdsService.listTagsForResource(cluster.getDbClusterArn()));
}
@Test
void dbProxyTargetGroupTagsRoundTripByArn() {
rdsService.createDbProxy("app-proxy", "POSTGRESQL", true, false, PROXY_ROLE_ARN,
PROXY_SUBNET_IDS, List.of(), PROXY_AUTH, Map.of());
String targetGroupArn = rdsService.describeDbProxyTargetGroups("app-proxy")
.iterator().next().getTargetGroupArn();
assertEquals(java.util.Map.of(), rdsService.listTagsForResource(targetGroupArn));
rdsService.addTagsToResource(targetGroupArn, java.util.Map.of("env", "test"));
assertEquals(java.util.Map.of("env", "test"),
rdsService.listTagsForResource(targetGroupArn));
rdsService.removeTagsFromResource(targetGroupArn, java.util.List.of("env"));
assertEquals(java.util.Map.of(), rdsService.listTagsForResource(targetGroupArn));
}
@Test
void dbProxyTargetGroupTagOperationsRejectMissingTargetGroup() {
AwsException exception = assertThrows(AwsException.class, () ->
rdsService.listTagsForResource(
"arn:aws:rds:us-east-1:123456789012:target-group:prx-tg-missing"));
assertEquals("DBProxyTargetGroupNotFoundFault", exception.getErrorCode());
}
@Test
void tagOperationsRejectUnsupportedResourceArn() {
// Parameter groups are tagged now, so an absent one is a missing resource rather than a