feat(rds,docdb): tag DocumentDB clusters and parameter groups (#2408)

* fix(rds): tag DB and DB cluster parameter groups

The tag resolver handled db, cluster, subgrp, db-proxy and og, so tagging a
parameter group answered that Floci does not implement the type — a live account
tags both, and the terraform provider reads a group's tags as part of its read.
DocumentDB's cluster parameter groups are these records too, so the same read
fails for aws_docdb_cluster_parameter_group.

Neither model carried tags, and neither carried the ARN a caller tags by: the
create response omitted it, leaving nothing to address the group with. Both are
stored and reported now, and tags given at create are kept, as a live account
keeps them.

* feat(docdb): tag clusters and instances

aws_docdb_cluster reads a cluster's tags as part of every read, so a cluster
that created fine failed its apply on DBClusterNotFoundFault — created, but not
readable.

DocumentDB signs with the rds credential scope, and on that scope it is told
apart by Engine or a cluster/instance identifier. The tag actions carry neither,
only the ARN of the resource they address, so they reached the RDS handler,
which does not hold DocumentDB's records. The router reads that ARN now, and an
ARN naming something DocumentDB does not have still goes to RDS.

Clusters and instances store tags, keep the ones given at create, and answer the
three tag actions. Behaviour follows a live account: an existing key is
overwritten, removing a key that is not present is not an error, and an ARN in
another region or account is rejected with the one message AWS gives for both —
storage is keyed by identifier alone, so without that check an ARN naming
another region would be answered with this caller's cluster.

A tag update is a read-modify-write, so it takes the record's monitor and the
other writers take the same one; otherwise tagging a cluster while it is being
deleted stores it again. Paths that hold both take the instance's monitor before
the cluster's.

Filters on ListTagsForResource are accepted without validation: a live account
rejects an unrecognised name, but Floci carries no list of the ones it accepts,
and the tags of one named resource are the same answer either way.

* fix(rds,docdb): store an empty value for a tag given without one

A tag whose Key arrived without a Value was stored with a null, and the read
hands the tags back as an immutable copy, which rejects nulls — so one such tag
made every subsequent read of that resource fail with an internal error, not
just the tag that caused it. A live account stores an empty value and reads it
back.

Both handlers parse tags the same way and both had it.

* fix(rds,docdb): match the whole ARN when routing tags, and give legacy groups one

Two things reported on review.

Routing read the trailing name of the ResourceName ARN and looked it up in
DocumentDB storage, but RDS and DocumentDB share one ARN space: an RDS resource
whose name a DocumentDB record happens to share was answered — and mutated —
out of the wrong store, and an RDS parameter group or option group could be
resolved as a cluster. The whole stored ARN is matched now, which settles
region, account, type and name at once, as the db-cluster-id filter already
does.

And only creation assigned a parameter group's ARN, so a group persisted by an
earlier version read back without one, leaving describe with no ARN to report
and the caller nothing to tag by. The read that backfills a missing region
backfills the ARN too.

The service keeps rejecting an ARN from another region or account: the router
no longer sends it one, but the check guards its own contract, and it is
covered directly rather than through the endpoint.

* fix(rds,docdb): keep one identifier space across the RDS family

Matching the whole ARN still left one ambiguity: an RDS cluster and a
DocumentDB cluster of the same name in the same account and region produce the
same ARN, and a tag call naming it could only reach one of them.

A live account settles it — creating an Aurora cluster named like an existing
DocumentDB one is refused with DBClusterAlreadyExistsFault, because the RDS
family shares one identifier space. Floci already refused that direction, since
a create naming an identifier DocumentDB holds is routed to DocumentDB, which
answers AlreadyExists; the other direction was open, so a docdb create could
take a name RDS already had.

A create naming an identifier RDS holds now goes to RDS whatever engine it
names, so it answers AlreadyExists too and the two stores cannot both hold one
identifier — which is what makes an ARN unambiguous.

* fix(rds,docdb): report a persisted identifier held by both services

Creates can no longer put one identifier in both stores, but state written
before that can, and a restart loads it. For such a record the identifier
checks in the router already send every action to DocumentDB — describe, modify
and delete included — and have long before tags existed, so tags answer from
there too: one identifier keeps one answer, rather than a tag call reaching a
record no describe can show.

The collision is logged once per ARN, since the RDS record behind it cannot be
reached on this scope at all and only deleting one of the two records fixes it.

* fix(docdb): build cluster and instance ARNs from the caller's region

The ARN was built from the configured default region, so a caller signing for
anywhere else got back an ARN naming somewhere they were not — and since a tag
call is checked against the region it is made from, that caller could not tag
the cluster the create had just answered with.

It also reopened the identifier collision from the other side: the create-time
check looked for an RDS record in the request region while the ARN landed in
the default one, so signing the create for another region got past the check and
produced two records under one ARN. DocumentDB keys records by bare identifier,
so the check now covers every region — narrower than AWS, which allows one name
per region, but Floci cannot hold both and answer either correctly.

The check also asked about the wrong identifier for instances: CreateDBInstance
names its parent cluster, and that cluster existing in RDS is the normal case,
not a clash. Only the identifier being created is checked, and the clash is
answered with AlreadyExists directly rather than by handing the create to a
service that rejects the engine first.

* fix(rds): scope the create-time identifier check to the request's region

Widening it to every region broke what RDS actually does: names are scoped by
region, so the same instance name in two regions is two resources, and
RdsControlPlaneTest.sdkScopesTheSameDbInstanceNameBySignedRegion pins exactly
that. The second create answered DBInstanceAlreadyExists.

The cross-region case that widening was meant to cover is closed by the ARNs
instead: each carries the region it was created in, so two records of one name
in different regions never share an ARN and no tag call has to choose between
them. What must not exist is one identifier in both services in one region, and
that is what the check now asks about.

* fix(docdb): decide ownership of an identifier per region

The routing checks asked whether DocumentDB holds an identifier at all, and its
records are keyed by identifier alone, so a name DocumentDB held in one region
was taken away from RDS in every other one: the create was refused as already
existing, and a describe, modify or delete answered from the wrong region's
record.

The region now comes from the one place a record carries it — the ARN — so
DocumentDB claims an identifier only in the region it was created in. Records
written before ARNs carried the caller's region read as the configured default,
which is the region they were in fact created under.

This was true before tags existed; it becomes reachable in a way worth fixing
now that a create in another region records that region rather than the default.

* fix(docdb): check the identifier on every route into DocumentDB

The create-time check lived in the rds credential scope's branch, but
DocumentDB is reachable under its own scope too, and that one dispatches
straight to its handler — which knows only its own store. A create signed that
way could take an identifier RDS already held in the region, which is the state
the ARN matching relies on being impossible.

The check is one method now, called from both routes.

Neptune shares the same identifier space and its scope is not checked either;
that is untouched here, since this PR's invariant is about the ARN a tag call
resolves and Neptune holds no tags.

* fix(docdb): resolve a tag ARN to the record it names, not to the identifier

resolveTagTarget checked the ARN's region against the caller's and then loaded
the record by identifier, and records are keyed by identifier alone — so an ARN
whose region matched the request but named a record stored in another region
resolved to that other record, and tagged it.

Reachable on the docdb credential scope, which dispatches to this service
directly rather than through the routing that matches the whole ARN. The stored
ARN is now compared with the one asked for, and anything else is not found.
This commit is contained in:
Michal Schreiber authored and GitHub committed 2026-08-19 20:23:32 -04:00
1 parent 498021087f
commit 7b83bd5283
18 files changed
+1693 -141

No files matched your search

@@ -15,6 +15,7 @@ import io.github.hectorvent.floci.services.elasticache.ElastiCacheQueryHandler;
import io.github.hectorvent.floci.services.iam.IamQueryHandler;
import io.github.hectorvent.floci.services.iam.StsQueryHandler;
import io.github.hectorvent.floci.services.rds.RdsQueryHandler;
import io.github.hectorvent.floci.services.rds.RdsService;
import io.github.hectorvent.floci.services.sns.SnsQueryHandler;
import io.github.hectorvent.floci.services.ses.SesQueryHandler;
import io.github.hectorvent.floci.services.sqs.SqsQueryHandler;
@@ -181,6 +182,9 @@ public class AwsQueryController {
private final NeptuneService neptuneService;
private final DocDbQueryHandler docDbQueryHandler;
private final DocDbService docDbService;
private final RdsService rdsService;
/** ARNs already reported as held by both services, so the warning is logged once each. */
private final java.util.Set<String> reportedArnCollisions = java.util.concurrent.ConcurrentHashMap.newKeySet();
private final SqsQueryHandler sqsQueryHandler;
private final SnsQueryHandler snsQueryHandler;
private final SesQueryHandler sesQueryHandler;
@@ -203,6 +207,7 @@ public class AwsQueryController {
NeptuneService neptuneService,
DocDbQueryHandler docDbQueryHandler,
DocDbService docDbService,
RdsService rdsService,
SqsQueryHandler sqsQueryHandler, SnsQueryHandler snsQueryHandler,
SesQueryHandler sesQueryHandler,
IamQueryHandler iamQueryHandler, StsQueryHandler stsQueryHandler,
@@ -221,6 +226,7 @@ public class AwsQueryController {
this.neptuneService = neptuneService;
this.docDbQueryHandler = docDbQueryHandler;
this.docDbService = docDbService;
this.rdsService = rdsService;
this.sqsQueryHandler = sqsQueryHandler;
this.snsQueryHandler = snsQueryHandler;
this.sesQueryHandler = sesQueryHandler;
@@ -291,6 +297,12 @@ public class AwsQueryController {
String engine = formParams.getFirst("Engine");
String clusterId = formParams.getFirst("DBClusterIdentifier");
String instanceId = formParams.getFirst("DBInstanceIdentifier");
Response identifierClash = rdsAlreadyHoldsIdentifier(action, formParams, region);
if (identifierClash != null) {
yield identifierClash;
}
if ("neptune".equalsIgnoreCase(engine)
|| neptuneService.hasCluster(clusterId)
|| neptuneService.hasInstance(instanceId)) {
@@ -298,14 +310,20 @@ public class AwsQueryController {
}
if ("docdb".equalsIgnoreCase(engine)
|| docDbService.hasCluster(clusterId)
|| docDbService.hasInstance(instanceId)) {
|| docDbService.hasCluster(clusterId, region)
|| docDbService.hasInstance(instanceId, region)
|| namesDocDbResource(formParams.getFirst("ResourceName"), region)) {
yield docDbQueryHandler.handle(action, formParams);
}
yield rdsQueryHandler.handle(action, formParams, region);
}
case "neptune" -> neptuneQueryHandler.handle(action, formParams);
case "docdb" -> docDbQueryHandler.handle(action, formParams);
case "docdb" -> {
// The same check as on the rds scope: DocumentDB is reachable under either, and a
// create that skipped it here would put a second record under an ARN RDS owns.
Response clash = rdsAlreadyHoldsIdentifier(action, formParams, region);
yield clash != null ? clash : docDbQueryHandler.handle(action, formParams);
}
case "email" -> sesQueryHandler.handle(action, formParams, region);
case "monitoring" -> cloudWatchMetricsQueryHandler.handle(action, formParams, region);
case "cloudformation" -> cloudFormationQueryHandler.handle(action, formParams, region);
@@ -319,6 +337,61 @@ public class AwsQueryController {
};
}
/**
* The AlreadyExists answer when a create names an identifier RDS already holds here, or null.
*
* <p>One identifier space covers the whole RDS family: a live account refuses to create an
* Aurora cluster named like an existing DocumentDB one. Answering that way is what stops two
* services holding one identifier in one region, which no ARN could then tell apart — so the
* check has to run on every route that reaches DocumentDB, not only the {@code rds} scope.
*
* <p>Only the identifier being created is checked: {@code CreateDBInstance} names its parent
* cluster too, and that cluster existing in RDS is the normal case rather than a clash.
*/
private Response rdsAlreadyHoldsIdentifier(String action,
MultivaluedMap<String, String> formParams,
String region) {
if ("CreateDBCluster".equals(action) && rdsService.hasClusterOrInstance(
formParams.getFirst("DBClusterIdentifier"), null, region)) {
return xmlErrorResponse("DBClusterAlreadyExistsFault", "DB Cluster already exists", 400);
}
if ("CreateDBInstance".equals(action) && rdsService.hasClusterOrInstance(
null, formParams.getFirst("DBInstanceIdentifier"), region)) {
return xmlErrorResponse("DBInstanceAlreadyExists", "DB Instance already exists", 400);
}
return null;
}
/**
* Whether a tagging {@code ResourceName} names a DocumentDB cluster or instance.
*
* <p>The tag actions carry no engine or identifier to route on — only the ARN of the resource
* they address — so without reading it they reach the RDS handler, which does not hold
* DocumentDB's records. The whole ARN is matched, not its trailing name: RDS and DocumentDB
* share one ARN space, so a name both services use would otherwise be answered from the wrong
* store, and an RDS parameter group or option group could be resolved as a cluster. Anything
* DocumentDB does not hold under that exact ARN stays with RDS.
*
* <p>State persisted before creates were made to share one identifier space can still hold the
* same identifier in both stores. DocumentDB answers it, which is what the identifier checks
* above already do for every other action on that record — describe, modify and delete
* included — so one identifier keeps one answer. The collision is logged once, because the
* RDS record behind it is unreachable on this scope and only deleting one of the two fixes it.
*/
private boolean namesDocDbResource(String resourceName, String region) {
if (!docDbService.hasResourceWithArn(resourceName)) {
return false;
}
String identifier = resourceName.substring(resourceName.lastIndexOf(':') + 1);
if (rdsService.hasClusterOrInstance(identifier, identifier, region)
&& reportedArnCollisions.add(resourceName)) {
LOG.warnv("RDS and DocumentDB both hold {0}; DocumentDB answers for it, as it does for "
+ "every other action on that identifier. Delete one of the two records.",
resourceName);
}
return true;
}
private Response handleCognitoQuery(String action, MultivaluedMap<String, String> formParams, String region) {
// Cognito is primarily JSON 1.1, but we provide a bridge for Query protocol if hit.
// Convert MultivaluedMap to JsonNode if needed, but for now just return UnsupportedOperation
@@ -13,7 +13,11 @@ import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ApplicationScoped
public class DocDbQueryHandler {
@@ -43,6 +47,9 @@ public class DocDbQueryHandler {
case "DescribeDBInstances"-> handleDescribeDbInstances(params);
case "DeleteDBInstance" -> handleDeleteDbInstance(params);
case "ModifyDBInstance" -> handleModifyDbInstance(params);
case "ListTagsForResource" -> handleListTagsForResource(params);
case "AddTagsToResource" -> handleAddTagsToResource(params);
case "RemoveTagsFromResource" -> handleRemoveTagsFromResource(params);
default -> AwsQueryResponse.error("UnsupportedOperation",
"Operation " + action + " is not supported by DocDB.", AwsNamespaces.RDS, 400);
};
@@ -71,6 +78,11 @@ public class DocDbQueryHandler {
DocDbCluster cluster = service.createDbCluster(id, engineVersion,
masterUsername, masterPassword, iamEnabled);
// Tags given at create are readable back on a live account, so they must not be dropped.
Map<String, String> tags = parseTags(params);
if (!tags.isEmpty()) {
service.addTagsToResource(cluster.getDbClusterArn(), tags);
}
return Response.ok(AwsQueryResponse.envelope("CreateDBCluster", AwsNamespaces.RDS,
clusterXml(cluster))).build();
}
@@ -316,4 +328,64 @@ public class DocDbQueryHandler {
}
return null;
}
}
// ── Tags ──────────────────────────────────────────────────────────────────
private Response handleListTagsForResource(MultivaluedMap<String, String> params) {
// Filters are accepted without validation: a live account rejects an unrecognised filter
// name, but Floci carries no list of the names it accepts, and the tags of one named
// resource are the same answer either way.
Map<String, String> tags = service.listTagsForResource(params.getFirst("ResourceName"));
XmlBuilder xml = new XmlBuilder().start("TagList");
tags.forEach((key, value) -> xml.start("Tag")
.elem("Key", key)
.elem("Value", value == null ? "" : value)
.end("Tag"));
xml.end("TagList");
return Response.ok(AwsQueryResponse.envelope("ListTagsForResource",
AwsNamespaces.RDS, xml.build())).build();
}
private Response handleAddTagsToResource(MultivaluedMap<String, String> params) {
service.addTagsToResource(params.getFirst("ResourceName"), parseTags(params));
return Response.ok(AwsQueryResponse.envelope("AddTagsToResource", AwsNamespaces.RDS, "")).build();
}
private Response handleRemoveTagsFromResource(MultivaluedMap<String, String> params) {
service.removeTagsFromResource(params.getFirst("ResourceName"), tagKeys(params));
return Response.ok(AwsQueryResponse.envelope("RemoveTagsFromResource",
AwsNamespaces.RDS, "")).build();
}
/** Every spelling the SDKs and the CLI use for a tag list, as RdsQueryHandler reads them. */
private static Map<String, String> parseTags(MultivaluedMap<String, String> params) {
Map<String, String> tags = new LinkedHashMap<>();
for (String prefix : List.of("Tags.member", "Tags.Tag", "Tag")) {
for (int i = 1; ; i++) {
String key = params.getFirst(prefix + "." + i + ".Key");
if (key == null) {
break;
}
// A key given without a value is stored as an empty value, as AWS stores it —
// a null would also break the immutable copy the read hands back.
String value = params.getFirst(prefix + "." + i + ".Value");
tags.put(key, value == null ? "" : value);
}
}
return tags;
}
private static List<String> tagKeys(MultivaluedMap<String, String> params) {
List<String> keys = new ArrayList<>();
for (String prefix : List.of("TagKeys.member", "TagKeys.TagKey", "TagKeys")) {
for (int i = 1; ; i++) {
String key = params.getFirst(prefix + "." + i);
if (key == null) {
break;
}
keys.add(key);
}
}
return keys;
}
}
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.docdb;
import com.fasterxml.jackson.core.type.TypeReference;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.StorageBackend;
@@ -17,8 +18,11 @@ import org.jboss.logging.Logger;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@ApplicationScoped
public class DocDbService {
@@ -32,6 +36,11 @@ public class DocDbService {
private final EmulatorConfig config;
private final RegionResolver regionResolver;
private final DocDbContainerManager containerManager;
/**
* One monitor per stored record, taken by everything that writes it. A tag update is a
* read-modify-write, so without a lock shared with delete it can put a deleted cluster back.
*/
private final ConcurrentHashMap<String, Object> writeLocks = new ConcurrentHashMap<>();
@Inject
public DocDbService(EmulatorConfig config,
@@ -52,58 +61,63 @@ public class DocDbService {
public DocDbCluster createDbCluster(String id, String engineVersion,
String masterUsername, String masterPassword,
boolean iamEnabled) {
if (clusters.get(id).isPresent()) {
throw new AwsException("DBClusterAlreadyExistsFault",
"DocDB cluster " + id + " already exists.", 400);
}
String region = regionResolver.getDefaultRegion();
DocDbCluster cluster = new DocDbCluster();
cluster.setDbClusterIdentifier(id);
cluster.setStatus("available");
cluster.setEngineVersion(engineVersion != null ? engineVersion : ENGINE_VERSION_DEFAULT);
cluster.setMasterUsername(masterUsername);
cluster.setIamDatabaseAuthenticationEnabled(iamEnabled);
cluster.setDbClusterArn(regionResolver.buildArn("rds", region, "cluster:" + id));
cluster.setDbClusterResourceId("cluster-" + UUID.randomUUID().toString()
.replace("-", "").substring(0, 24).toUpperCase());
cluster.setCreatedAt(Instant.now());
cluster.setDbClusterMembers(new ArrayList<>());
if (config.services().docdb().mock()) {
LOG.infov("Creating DocDB cluster {0} in mock mode (no container)", id);
cluster.setEndpoint("localhost");
cluster.setReaderEndpoint("localhost");
cluster.setPort(MONGO_PORT);
} else {
String image = config.services().docdb().defaultImage();
LOG.infov("Creating DocDB cluster {0}, image={1}", id, image);
// A cluster record is metadata: its identifier, ARN and tags need no Docker, so the
// cluster is created and reaches 'available' even when no daemon is reachable. Only
// connecting to the database needs the container.
DocDbContainerHandle handle = containerManager.tryStart(id, image, masterUsername, masterPassword);
if (handle != null) {
cluster.setEndpoint(handle.getHost());
cluster.setReaderEndpoint(handle.getHost());
cluster.setPort(handle.getPort());
cluster.setContainerId(handle.getContainerId());
cluster.setContainerHost(handle.getHost());
cluster.setContainerPort(handle.getPort());
} else {
cluster.setEndpoint(resolveEndpointHost());
cluster.setReaderEndpoint(resolveEndpointHost());
cluster.setPort(MONGO_PORT);
LOG.warnv("DocDB cluster {0} created without a backing MongoDB container: no "
+ "Docker daemon is reachable. Metadata operations work; connections to "
+ "the cluster do not until a daemon appears.", id);
synchronized (lockFor("cluster:" + id)) {
if (clusters.get(id).isPresent()) {
throw new AwsException("DBClusterAlreadyExistsFault",
"DocDB cluster " + id + " already exists.", 400);
}
}
clusters.put(id, cluster);
LOG.infov("DocDB cluster {0} created, endpoint={1}:{2}",
id, cluster.getEndpoint(), String.valueOf(cluster.getPort()));
return cluster;
// The caller's region, not the configured default: the ARN this create answers with is
// the one the caller tags by, and a tag call is checked against the region it is made
// from — an ARN naming somewhere else is one its own creator cannot use.
String region = regionResolver.getRegion();
DocDbCluster cluster = new DocDbCluster();
cluster.setDbClusterIdentifier(id);
cluster.setStatus("available");
cluster.setEngineVersion(engineVersion != null ? engineVersion : ENGINE_VERSION_DEFAULT);
cluster.setMasterUsername(masterUsername);
cluster.setIamDatabaseAuthenticationEnabled(iamEnabled);
cluster.setDbClusterArn(regionResolver.buildArn("rds", region, "cluster:" + id));
cluster.setDbClusterResourceId("cluster-" + UUID.randomUUID().toString()
.replace("-", "").substring(0, 24).toUpperCase());
cluster.setCreatedAt(Instant.now());
cluster.setDbClusterMembers(new ArrayList<>());
if (config.services().docdb().mock()) {
LOG.infov("Creating DocDB cluster {0} in mock mode (no container)", id);
cluster.setEndpoint("localhost");
cluster.setReaderEndpoint("localhost");
cluster.setPort(MONGO_PORT);
} else {
String image = config.services().docdb().defaultImage();
LOG.infov("Creating DocDB cluster {0}, image={1}", id, image);
// A cluster record is metadata: its identifier, ARN and tags need no Docker, so the
// cluster is created and reaches 'available' even when no daemon is reachable. Only
// connecting to the database needs the container.
DocDbContainerHandle handle = containerManager.tryStart(id, image, masterUsername, masterPassword);
if (handle != null) {
cluster.setEndpoint(handle.getHost());
cluster.setReaderEndpoint(handle.getHost());
cluster.setPort(handle.getPort());
cluster.setContainerId(handle.getContainerId());
cluster.setContainerHost(handle.getHost());
cluster.setContainerPort(handle.getPort());
} else {
cluster.setEndpoint(resolveEndpointHost());
cluster.setReaderEndpoint(resolveEndpointHost());
cluster.setPort(MONGO_PORT);
LOG.warnv("DocDB cluster {0} created without a backing MongoDB container: no "
+ "Docker daemon is reachable. Metadata operations work; connections to "
+ "the cluster do not until a daemon appears.", id);
}
}
clusters.put(id, cluster);
LOG.infov("DocDB cluster {0} created, endpoint={1}:{2}",
id, cluster.getEndpoint(), String.valueOf(cluster.getPort()));
return cluster;
}
}
public DocDbCluster getDbCluster(String id) {
@@ -113,17 +127,64 @@ public class DocDbService {
}
public boolean hasCluster(String id) {
return hasCluster(id, regionResolver.getRegion());
}
/**
* Whether DocumentDB holds this cluster <em>in this region</em>.
*
* <p>The records are keyed by identifier alone, so the region has to come from the one place
* that carries it — the stored ARN. Without that, an RDS request naming a cluster DocumentDB
* holds somewhere else is answered from here, and a name RDS is free to reuse in another
* region stops being usable.
*/
public boolean hasCluster(String id, String region) {
if (id == null || id.isBlank()) {
return false;
}
return clusters.get(id).isPresent();
return clusters.get(id).filter(c -> regionOf(c.getDbClusterArn()).equals(region)).isPresent();
}
/** Refuses a record whose own ARN is not the one that was asked for. */
private static void requireArnNamesRecord(String requested, String stored,
String errorCode, String message) {
if (stored != null && !stored.equalsIgnoreCase(requested)) {
throw new AwsException(errorCode, message, 404);
}
}
/** The region a record was created in, taken from its ARN; older records carry the default. */
private String regionOf(String arn) {
return AwsArnUtils.regionOrDefault(arn, regionResolver.getDefaultRegion());
}
/**
* Whether an ARN names a DocumentDB cluster or instance, matched against the stored ARN.
*
* <p>RDS and DocumentDB share the {@code arn:aws:rds:...} space, so the trailing identifier
* alone does not identify a service: an RDS resource whose name a DocumentDB record happens to
* share would be answered from the wrong store. The full ARN settles region, account, type and
* name in one comparison, as the db-cluster-id filter already does.
*/
public boolean hasResourceWithArn(String arn) {
if (arn == null || !arn.startsWith("arn:")) {
return false;
}
return clusters.scan(k -> true).stream()
.anyMatch(c -> arn.equalsIgnoreCase(c.getDbClusterArn()))
|| instances.scan(k -> true).stream()
.anyMatch(i -> arn.equalsIgnoreCase(i.getDbInstanceArn()));
}
public boolean hasInstance(String id) {
return hasInstance(id, regionResolver.getRegion());
}
public boolean hasInstance(String id, String region) {
if (id == null || id.isBlank()) {
return false;
}
return instances.get(id).isPresent();
return instances.get(id).filter(i -> regionOf(i.getDbInstanceArn()).equals(region)).isPresent();
}
public Collection<DocDbCluster> listDbClusters(String filterId) {
@@ -143,39 +204,43 @@ public class DocDbService {
}
public DocDbCluster modifyDbCluster(String id, String engineVersion, Boolean iamEnabled) {
DocDbCluster cluster = getDbCluster(id);
if (engineVersion != null && !engineVersion.isBlank()) {
cluster.setEngineVersion(engineVersion);
synchronized (lockFor("cluster:" + id)) {
DocDbCluster cluster = getDbCluster(id);
if (engineVersion != null && !engineVersion.isBlank()) {
cluster.setEngineVersion(engineVersion);
}
if (iamEnabled != null) {
cluster.setIamDatabaseAuthenticationEnabled(iamEnabled);
}
clusters.put(id, cluster);
LOG.infov("DocDB cluster {0} modified", id);
return cluster;
}
if (iamEnabled != null) {
cluster.setIamDatabaseAuthenticationEnabled(iamEnabled);
}
clusters.put(id, cluster);
LOG.infov("DocDB cluster {0} modified", id);
return cluster;
}
public void deleteDbCluster(String id) {
DocDbCluster cluster = clusters.get(id).orElseThrow(() ->
new AwsException("DBClusterNotFoundFault",
"DocDB cluster " + id + " not found.", 404));
synchronized (lockFor("cluster:" + id)) {
DocDbCluster cluster = clusters.get(id).orElseThrow(() ->
new AwsException("DBClusterNotFoundFault",
"DocDB cluster " + id + " not found.", 404));
if (cluster.getDbClusterMembers() != null && !cluster.getDbClusterMembers().isEmpty()) {
throw new AwsException("InvalidDBClusterStateFault",
"Cannot delete DocDB cluster " + id + " — it still has DB instances.", 400);
if (cluster.getDbClusterMembers() != null && !cluster.getDbClusterMembers().isEmpty()) {
throw new AwsException("InvalidDBClusterStateFault",
"Cannot delete DocDB cluster " + id + " — it still has DB instances.", 400);
}
cluster.setStatus("deleting");
clusters.put(id, cluster);
if (cluster.getContainerId() != null) {
containerManager.stop(new DocDbContainerHandle(
cluster.getContainerId(), id,
cluster.getContainerHost(), cluster.getContainerPort()));
}
clusters.delete(id);
LOG.infov("DocDB cluster {0} deleted", id);
}
cluster.setStatus("deleting");
clusters.put(id, cluster);
if (cluster.getContainerId() != null) {
containerManager.stop(new DocDbContainerHandle(
cluster.getContainerId(), id,
cluster.getContainerHost(), cluster.getContainerPort()));
}
clusters.delete(id);
LOG.infov("DocDB cluster {0} deleted", id);
}
// ── Instances ─────────────────────────────────────────────────────────────
@@ -183,34 +248,39 @@ public class DocDbService {
public DocDbInstance createDbInstance(String id, String dbClusterIdentifier,
String dbInstanceClass, String engineVersion,
boolean iamEnabled) {
if (instances.get(id).isPresent()) {
throw new AwsException("DBInstanceAlreadyExists",
"DocDB instance " + id + " already exists.", 400);
// Instance monitor before cluster monitor, the one order every path that holds both uses.
synchronized (lockFor("instance:" + id)) {
synchronized (lockFor("cluster:" + dbClusterIdentifier)) {
if (instances.get(id).isPresent()) {
throw new AwsException("DBInstanceAlreadyExists",
"DocDB instance " + id + " already exists.", 400);
}
DocDbCluster cluster = getDbCluster(dbClusterIdentifier);
String region = regionResolver.getRegion();
DocDbInstance instance = new DocDbInstance();
instance.setDbInstanceIdentifier(id);
instance.setDbClusterIdentifier(dbClusterIdentifier);
instance.setDbInstanceClass(dbInstanceClass != null ? dbInstanceClass : "db.r5.large");
instance.setEngineVersion(engineVersion != null ? engineVersion : cluster.getEngineVersion());
instance.setStatus("available");
instance.setEndpoint(cluster.getEndpoint());
instance.setPort(cluster.getPort());
instance.setIamDatabaseAuthenticationEnabled(iamEnabled);
instance.setDbInstanceArn(regionResolver.buildArn("rds", region, "db:" + id));
instance.setDbiResourceId("db-" + UUID.randomUUID().toString()
.replace("-", "").substring(0, 24).toUpperCase());
instance.setCreatedAt(Instant.now());
cluster.getDbClusterMembers().add(id);
clusters.put(dbClusterIdentifier, cluster);
instances.put(id, instance);
LOG.infov("DocDB instance {0} created in cluster {1}", id, dbClusterIdentifier);
return instance;
}
}
DocDbCluster cluster = getDbCluster(dbClusterIdentifier);
String region = regionResolver.getDefaultRegion();
DocDbInstance instance = new DocDbInstance();
instance.setDbInstanceIdentifier(id);
instance.setDbClusterIdentifier(dbClusterIdentifier);
instance.setDbInstanceClass(dbInstanceClass != null ? dbInstanceClass : "db.r5.large");
instance.setEngineVersion(engineVersion != null ? engineVersion : cluster.getEngineVersion());
instance.setStatus("available");
instance.setEndpoint(cluster.getEndpoint());
instance.setPort(cluster.getPort());
instance.setIamDatabaseAuthenticationEnabled(iamEnabled);
instance.setDbInstanceArn(regionResolver.buildArn("rds", region, "db:" + id));
instance.setDbiResourceId("db-" + UUID.randomUUID().toString()
.replace("-", "").substring(0, 24).toUpperCase());
instance.setCreatedAt(Instant.now());
cluster.getDbClusterMembers().add(id);
clusters.put(dbClusterIdentifier, cluster);
instances.put(id, instance);
LOG.infov("DocDB instance {0} created in cluster {1}", id, dbClusterIdentifier);
return instance;
}
public DocDbInstance getDbInstance(String id) {
@@ -234,32 +304,38 @@ public class DocDbService {
}
public DocDbInstance modifyDbInstance(String id, String dbInstanceClass, Boolean iamEnabled) {
DocDbInstance instance = getDbInstance(id);
if (dbInstanceClass != null && !dbInstanceClass.isBlank()) {
instance.setDbInstanceClass(dbInstanceClass);
synchronized (lockFor("instance:" + id)) {
DocDbInstance instance = getDbInstance(id);
if (dbInstanceClass != null && !dbInstanceClass.isBlank()) {
instance.setDbInstanceClass(dbInstanceClass);
}
if (iamEnabled != null) {
instance.setIamDatabaseAuthenticationEnabled(iamEnabled);
}
instances.put(id, instance);
LOG.infov("DocDB instance {0} modified", id);
return instance;
}
if (iamEnabled != null) {
instance.setIamDatabaseAuthenticationEnabled(iamEnabled);
}
instances.put(id, instance);
LOG.infov("DocDB instance {0} modified", id);
return instance;
}
public void deleteDbInstance(String id) {
DocDbInstance instance = instances.get(id).orElseThrow(() ->
new AwsException("DBInstanceNotFound",
"DocDB instance " + id + " not found.", 404));
synchronized (lockFor("instance:" + id)) {
DocDbInstance instance = instances.get(id).orElseThrow(() ->
new AwsException("DBInstanceNotFound",
"DocDB instance " + id + " not found.", 404));
String clusterId = instance.getDbClusterIdentifier();
DocDbCluster cluster = clusters.get(clusterId).orElse(null);
if (cluster != null) {
cluster.getDbClusterMembers().remove(id);
clusters.put(clusterId, cluster);
String clusterId = instance.getDbClusterIdentifier();
synchronized (lockFor("cluster:" + clusterId)) {
DocDbCluster cluster = clusters.get(clusterId).orElse(null);
if (cluster != null) {
cluster.getDbClusterMembers().remove(id);
clusters.put(clusterId, cluster);
}
}
instances.delete(id);
LOG.infov("DocDB instance {0} deleted", id);
}
instances.delete(id);
LOG.infov("DocDB instance {0} deleted", id);
}
// ── Helpers ───────────────────────────────────────────────────────────────
@@ -267,4 +343,103 @@ public class DocDbService {
private String resolveEndpointHost() {
return config.hostname().orElse("localhost");
}
}
// ── Tags ──────────────────────────────────────────────────────────────────
/** A resolved tag target: the record's key, its tags, and a sink that persists an update. */
private record TagTarget(String lockKey, Map<String, String> tags,
java.util.function.Consumer<Map<String, String>> save) {}
public Map<String, String> listTagsForResource(String resourceName) {
return Map.copyOf(resolveTagTarget(resourceName).tags());
}
public void addTagsToResource(String resourceName, Map<String, String> tags) {
updateTags(resourceName, current -> current.putAll(tags));
}
public void removeTagsFromResource(String resourceName, Collection<String> tagKeys) {
// A key that is not present is not an error on a live account; the ones that are get removed.
updateTags(resourceName, current -> tagKeys.forEach(current::remove));
}
private void updateTags(String resourceName, java.util.function.Consumer<Map<String, String>> change) {
// Resolve once to learn which record is meant, then do the read-modify-write under that
// record's monitor and resolve again inside it: the record can be deleted in between, and
// saving what the first read returned would put it back.
String lockKey = resolveTagTarget(resourceName).lockKey();
synchronized (lockFor(lockKey)) {
TagTarget target = resolveTagTarget(resourceName);
Map<String, String> updated = new LinkedHashMap<>(target.tags());
change.accept(updated);
target.save().accept(updated);
}
}
private Object lockFor(String key) {
return writeLocks.computeIfAbsent(key, k -> new Object());
}
/**
* Resolves a tagging {@code ResourceName} to the DocumentDB record it names.
*
* <p>Only ARNs reach here: the router picks this service by looking the ARN's identifier up in
* DocumentDB storage, so a bare name stays with RDS. The region and account are checked before
* the identifier, as a live account checks them — storage is keyed by identifier alone, so an
* ARN naming another region would otherwise resolve this caller's cluster.
*/
private TagTarget resolveTagTarget(String resourceName) {
if (resourceName == null || resourceName.isBlank()) {
throw new AwsException("InvalidParameterValue", "ResourceName is required.", 400);
}
AwsArnUtils.Arn arn;
try {
arn = AwsArnUtils.parse(resourceName);
} catch (IllegalArgumentException malformed) {
throw new AwsException("InvalidParameterValue", "Invalid resource name: " + resourceName, 400);
}
if (!"rds".equals(arn.service())
|| !regionResolver.getRegion().equals(arn.region())
|| !Objects.equals(regionResolver.getAccountId(), arn.accountId())) {
// One message for both, which is what a live account answers.
throw new AwsException("InvalidParameterValue",
"The specified resource name does not match an RDS resource in this region.", 400);
}
String resource = arn.resource();
int separator = resource.indexOf(':');
if (separator < 0) {
throw new AwsException("InvalidParameterValue", "Invalid resource name: " + resourceName, 400);
}
String type = resource.substring(0, separator);
String id = resource.substring(separator + 1);
// The record has to be the one this ARN names, not merely one of that identifier: records
// are keyed by identifier alone, so an ARN whose region matches the caller but not the
// stored record would otherwise be answered — and mutated — from another region's
// resource. Reachable on the docdb credential scope, which dispatches here directly
// rather than through the routing that matches the whole ARN.
return switch (type) {
case "cluster" -> {
DocDbCluster cluster = getDbCluster(id);
requireArnNamesRecord(resourceName, cluster.getDbClusterArn(),
"DBClusterNotFoundFault", "DocDB cluster " + id + " not found.");
yield new TagTarget("cluster:" + id, cluster.getTags(), updated -> {
cluster.setTags(updated);
clusters.put(id, cluster);
});
}
case "db" -> {
DocDbInstance instance = getDbInstance(id);
requireArnNamesRecord(resourceName, instance.getDbInstanceArn(),
"DBInstanceNotFound", "DocDB instance " + id + " not found.");
yield new TagTarget("instance:" + id, instance.getTags(), updated -> {
instance.setTags(updated);
instances.put(id, instance);
});
}
default -> throw new AwsException("InvalidParameterValue",
"Tagging for resource type '" + type + "' is not yet implemented by Floci: " + resourceName, 400);
};
}
}
@@ -4,11 +4,14 @@ 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;
@RegisterForReflection
public class DocDbCluster {
private String masterUsername;
private Map<String, String> tags = new LinkedHashMap<>();
private String dbClusterIdentifier;
private String status;
@@ -78,5 +81,12 @@ public class DocDbCluster {
public int getContainerPort() { return containerPort; }
public void setContainerPort(int containerPort) { this.containerPort = containerPort; }
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
}
}
@@ -2,10 +2,13 @@ package io.github.hectorvent.floci.services.docdb.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.LinkedHashMap;
import java.util.Map;
@RegisterForReflection
public class DocDbInstance {
private String dbInstanceIdentifier;
private Map<String, String> tags = new LinkedHashMap<>();
private String dbClusterIdentifier;
private String dbInstanceClass;
private String engineVersion;
@@ -55,4 +58,11 @@ public class DocDbInstance {
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
}
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
}
}
@@ -475,6 +475,11 @@ public class RdsQueryHandler {
try {
DbParameterGroup group = service.createDbParameterGroup(
name, family, description, region);
// Tags given at create are readable back on a live account.
Map<String, String> tags = parseTags(params);
if (!tags.isEmpty()) {
service.addTagsToResource(group.getDbParameterGroupArn(), tags, region);
}
String result = paramGroupXml(group);
return Response.ok(AwsQueryResponse.envelope("CreateDBParameterGroup", AwsNamespaces.RDS, result)).build();
} catch (AwsException e) {
@@ -576,6 +581,10 @@ public class RdsQueryHandler {
try {
DbClusterParameterGroup group = service.createDbClusterParameterGroup(
name, family, description, region);
Map<String, String> tags = parseTags(params);
if (!tags.isEmpty()) {
service.addTagsToResource(group.getDbClusterParameterGroupArn(), tags, region);
}
String result = clusterParamGroupXml(group);
return Response.ok(AwsQueryResponse.envelope("CreateDBClusterParameterGroup", AwsNamespaces.RDS, result)).build();
} catch (AwsException e) {
@@ -1407,6 +1416,7 @@ public class RdsQueryHandler {
.elem("DBParameterGroupName", g.getDbParameterGroupName())
.elem("DBParameterGroupFamily", g.getDbParameterGroupFamily())
.elem("Description", g.getDescription())
.elem("DBParameterGroupArn", g.getDbParameterGroupArn())
.build();
}
@@ -1509,6 +1519,7 @@ public class RdsQueryHandler {
.elem("DBClusterParameterGroupName", g.getDbClusterParameterGroupName())
.elem("DBParameterGroupFamily", g.getDbParameterGroupFamily())
.elem("Description", g.getDescription())
.elem("DBClusterParameterGroupArn", g.getDbClusterParameterGroupArn())
.build();
}
@@ -1675,7 +1686,10 @@ public class RdsQueryHandler {
if (key == null) {
break;
}
tags.put(key, params.getFirst(prefix + "." + i + ".Value"));
// A key given without a value is stored as an empty value, as AWS stores it —
// a null would also break the immutable copy the read hands back.
String value = params.getFirst(prefix + "." + i + ".Value");
tags.put(key, value == null ? "" : value);
}
}
@@ -713,6 +713,21 @@ public class RdsService implements Resettable {
proxies.put(dbProxyKey(effectiveRegion, resolvedProxy.getDbProxyName()), updatedProxy);
});
}
case "pg" -> {
DbParameterGroup group = getDbParameterGroup(resourceId, effectiveRegion);
yield new TagHandle(group.getTags(), updated -> {
group.setTags(updated);
putParameterGroupForRegion(resourceId, effectiveRegion, group);
});
}
case "cluster-pg" -> {
DbClusterParameterGroup group =
getDbClusterParameterGroup(resourceId, effectiveRegion);
yield new TagHandle(group.getTags(), updated -> {
group.setTags(updated);
putClusterParameterGroupForRegion(resourceId, effectiveRegion, group);
});
}
case "og" -> {
if (managedOptionGroup(resourceId) != null) {
throw new AwsException("InvalidOptionGroupStateFault",
@@ -724,7 +739,7 @@ public class RdsService implements Resettable {
putOptionGroupForRegion(resourceId, effectiveRegion, group);
});
}
// Valid RDS resource types Floci does not model yet (pg, snapshot, ...) — taggable
// 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.
default -> throw new AwsException("InvalidParameterValue",
"Tagging for resource type '" + type + "' is not yet implemented by Floci: " + resourceName, 400);
@@ -1152,6 +1167,27 @@ public class RdsService implements Resettable {
return cluster;
}
/**
* Whether RDS holds a cluster or instance under this identifier.
*
* <p>The RDS-family services share one identifier space — a live account refuses to create an
* Aurora cluster named like an existing DocumentDB one with {@code DBClusterAlreadyExistsFault}
* — so a create naming an identifier RDS already holds belongs to RDS, whichever engine it
* names.
*/
public boolean hasClusterOrInstance(String clusterId, String instanceId, String region) {
// The request's region, and only it: RDS scopes these names by region — the same name in
// two regions is two resources, which the SDK compatibility suite pins — and two records
// in different regions carry different ARNs, so there is nothing for a tag call to
// confuse. What must not exist is one identifier in both services in one region.
String effectiveRegion = effectiveRegion(region);
boolean cluster = clusterId != null && !clusterId.isBlank()
&& findClusterForScope(currentAccountId(), effectiveRegion, clusterId) != null;
boolean instance = instanceId != null && !instanceId.isBlank()
&& findInstanceForScope(currentAccountId(), effectiveRegion, instanceId) != null;
return cluster || instance;
}
public DbCluster getDbCluster(String id) {
return getDbCluster(id, regionResolver.getDefaultRegion());
}
@@ -2091,6 +2127,7 @@ public class RdsService implements Resettable {
}
DbParameterGroup group = new DbParameterGroup(name, family, description);
group.setRegion(effectiveRegion);
group.setDbParameterGroupArn(regionResolver.buildArn("rds", effectiveRegion, "pg:" + name));
putParameterGroupForRegion(name, effectiveRegion, group);
return group;
}
@@ -2239,6 +2276,7 @@ public class RdsService implements Resettable {
}
DbClusterParameterGroup group = new DbClusterParameterGroup(name, family, description);
group.setRegion(effectiveRegion);
group.setDbClusterParameterGroupArn(regionResolver.buildArn("rds", effectiveRegion, "cluster-pg:" + name));
putClusterParameterGroupForRegion(name, effectiveRegion, group);
return group;
}
@@ -4213,8 +4251,19 @@ public class RdsService implements Resettable {
}
}
resolved.ifPresent(group -> {
if (group.getRegion() == null || group.getRegion().isBlank()) {
group.setRegion(effectiveRegion);
// A group persisted before either field existed reads back without them. The ARN is
// what a caller tags by, so a group that never gets one cannot be tagged at all.
boolean regionMissing = group.getRegion() == null || group.getRegion().isBlank();
boolean arnMissing = group.getDbParameterGroupArn() == null
|| group.getDbParameterGroupArn().isBlank();
if (regionMissing || arnMissing) {
if (regionMissing) {
group.setRegion(effectiveRegion);
}
if (arnMissing) {
group.setDbParameterGroupArn(
regionResolver.buildArn("rds", group.getRegion(), "pg:" + groupName));
}
putParameterGroupForRegion(groupName, effectiveRegion, group);
}
});
@@ -4286,8 +4335,17 @@ public class RdsService implements Resettable {
}
}
resolved.ifPresent(group -> {
if (group.getRegion() == null || group.getRegion().isBlank()) {
group.setRegion(effectiveRegion);
boolean regionMissing = group.getRegion() == null || group.getRegion().isBlank();
boolean arnMissing = group.getDbClusterParameterGroupArn() == null
|| group.getDbClusterParameterGroupArn().isBlank();
if (regionMissing || arnMissing) {
if (regionMissing) {
group.setRegion(effectiveRegion);
}
if (arnMissing) {
group.setDbClusterParameterGroupArn(regionResolver.buildArn(
"rds", group.getRegion(), "cluster-pg:" + groupName));
}
putClusterParameterGroupForRegion(groupName, effectiveRegion, group);
}
});
@@ -3,11 +3,14 @@ package io.github.hectorvent.floci.services.rds.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@RegisterForReflection
public class DbClusterParameterGroup {
private String dbClusterParameterGroupArn;
private Map<String, String> tags = new LinkedHashMap<>();
private String dbClusterParameterGroupName;
private String dbParameterGroupFamily;
private String description;
@@ -37,4 +40,14 @@ public class DbClusterParameterGroup {
public Map<String, String> getParameters() { return parameters; }
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
}
public String getDbClusterParameterGroupArn() { return dbClusterParameterGroupArn; }
public void setDbClusterParameterGroupArn(String dbClusterParameterGroupArn) { this.dbClusterParameterGroupArn = dbClusterParameterGroupArn; }
}
@@ -3,11 +3,14 @@ package io.github.hectorvent.floci.services.rds.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@RegisterForReflection
public class DbParameterGroup {
private String dbParameterGroupArn;
private Map<String, String> tags = new LinkedHashMap<>();
private String dbParameterGroupName;
private String dbParameterGroupFamily;
private String description;
@@ -37,4 +40,14 @@ public class DbParameterGroup {
public Map<String, String> getParameters() { return parameters; }
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
public Map<String, String> getTags() { return tags; }
/** Normalizes null: a record persisted before tags were stored deserializes without them. */
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
}
public String getDbParameterGroupArn() { return dbParameterGroupArn; }
public void setDbParameterGroupArn(String dbParameterGroupArn) { this.dbParameterGroupArn = dbParameterGroupArn; }
}