mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(rds): support tagging DB snapshots (#3649)
TagResource/UntagResource/ListTagsForResource rejected a snapshot ARN
outright ("not yet implemented by Floci"), and CreateDBSnapshot
silently dropped its Tags parameter even though DbSnapshot already had
a tags field. Both are now wired up: CreateDBSnapshot stores Tags, the
generic tag-resource dispatch resolves a "snapshot" ARN type against
the snapshot store, and DescribeDBSnapshots echoes DBSnapshotArn and
TagList like the other tagged resource types already do.
Snapshots are now region-scoped the same way DB instances and clusters
already are: CreateDBSnapshot/DescribeDBSnapshots/DescribeDBSnapshot-
Attributes/ModifyDBSnapshotAttribute/RestoreDBInstanceFromDBSnapshot
all thread the request's signed region through to snapshot storage and
lookup (via the same dbResourceKey/hasRdsResourceIdentity scoping the
instance/cluster stores use), so DBSnapshotArn reflects the request's
actual region and a snapshot created in one region is not visible to
Describe/Tag calls signed for another.
Verifying this live against a real floci instance via Terraform
surfaced two more gaps blocking any use of aws_db_snapshot at all,
regardless of tagging: DescribeDBSnapshotAttributes (called on every
read of the resource) and ModifyDBSnapshotAttribute were both
completely unimplemented. Added minimal support for both (the
"restore" attribute, i.e. cross-account copy/restore authorization,
modeled as plain in-memory state, no real cross-account sharing).
DeleteDBSnapshot is also unimplemented and was not added here — a
snapshot can be created and tagged but not destroyed via Terraform.
Noted in docs/services/rds.md as a follow-up, along with the other
resource types the original gap report mentioned (Aurora cluster
snapshots, reserved instances) that aren't modeled in Floci at all, so
tagging doesn't apply to them either.
Added a Terraform compatibility scenario (aws_db_snapshot with tags,
verifying create, tag read-back, a clean second plan, and an in-place
tag update) and ran it against a live floci instance before
committing, including a re-run after the region-scoping fix.
This commit is contained in:
1 parent
560b3e4aae
commit
315dfe69f0
10 files changed
+506
-24
No files matched your search
@@ -95,9 +95,11 @@ public class RdsQueryHandler {
|
||||
case "DescribeOptionGroups" -> handleDescribeOptionGroups(params, region);
|
||||
case "ModifyOptionGroup" -> handleModifyOptionGroup(params, region);
|
||||
case "DeleteOptionGroup" -> handleDeleteOptionGroup(params, region);
|
||||
case "CreateDBSnapshot" -> handleCreateDbSnapshot(params);
|
||||
case "RestoreDBInstanceFromDBSnapshot" -> handleRestoreDbInstanceFromDbSnapshot(params);
|
||||
case "DescribeDBSnapshots" -> handleDescribeDbSnapshots(params);
|
||||
case "CreateDBSnapshot" -> handleCreateDbSnapshot(params, region);
|
||||
case "RestoreDBInstanceFromDBSnapshot" -> handleRestoreDbInstanceFromDbSnapshot(params, region);
|
||||
case "DescribeDBSnapshots" -> handleDescribeDbSnapshots(params, region);
|
||||
case "DescribeDBSnapshotAttributes" -> handleDescribeDbSnapshotAttributes(params, region);
|
||||
case "ModifyDBSnapshotAttribute" -> handleModifyDbSnapshotAttribute(params, region);
|
||||
case "DescribeDBProxies" -> handleDescribeDbProxies(params, region);
|
||||
case "CreateDBProxy" -> handleCreateDbProxy(params, region);
|
||||
case "ModifyDBProxy" -> handleModifyDbProxy(params, region);
|
||||
@@ -1054,9 +1056,7 @@ public class RdsQueryHandler {
|
||||
return settings;
|
||||
}
|
||||
|
||||
// ── Snapshots & Proxies (not modeled — empty lists) ───────────────────────
|
||||
|
||||
private Response handleCreateDbSnapshot(MultivaluedMap<String, String> params) {
|
||||
private Response handleCreateDbSnapshot(MultivaluedMap<String, String> params, String region) {
|
||||
String snapshotId = params.getFirst("DBSnapshotIdentifier");
|
||||
String instanceId = params.getFirst("DBInstanceIdentifier");
|
||||
if (snapshotId == null || snapshotId.isBlank()) {
|
||||
@@ -1066,7 +1066,8 @@ public class RdsQueryHandler {
|
||||
return AwsQueryResponse.error("InvalidParameterValue", "DBInstanceIdentifier is required.", AwsNamespaces.RDS, 400);
|
||||
}
|
||||
try {
|
||||
io.github.hectorvent.floci.services.rds.model.DbSnapshot snapshot = service.createDbSnapshot(snapshotId, instanceId);
|
||||
io.github.hectorvent.floci.services.rds.model.DbSnapshot snapshot =
|
||||
service.createDbSnapshot(snapshotId, instanceId, parseTags(params), region);
|
||||
String result = dbSnapshotXml(snapshot);
|
||||
return Response.ok(AwsQueryResponse.envelope("CreateDBSnapshot", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
@@ -1074,7 +1075,7 @@ public class RdsQueryHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleRestoreDbInstanceFromDbSnapshot(MultivaluedMap<String, String> params) {
|
||||
private Response handleRestoreDbInstanceFromDbSnapshot(MultivaluedMap<String, String> params, String region) {
|
||||
String instanceId = params.getFirst("DBInstanceIdentifier");
|
||||
String snapshotId = params.getFirst("DBSnapshotIdentifier");
|
||||
if (instanceId == null || instanceId.isBlank()) {
|
||||
@@ -1099,7 +1100,7 @@ public class RdsQueryHandler {
|
||||
java.util.Map<String, String> tags = parseTags(params);
|
||||
|
||||
try {
|
||||
DbInstance instance = service.restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass, availabilityZone, multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags);
|
||||
DbInstance instance = service.restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass, availabilityZone, multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags, region);
|
||||
String result = dbInstanceXml(instance);
|
||||
return Response.ok(AwsQueryResponse.envelope("RestoreDBInstanceFromDBSnapshot", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
@@ -1107,11 +1108,12 @@ public class RdsQueryHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleDescribeDbSnapshots(MultivaluedMap<String, String> params) {
|
||||
private Response handleDescribeDbSnapshots(MultivaluedMap<String, String> params, String region) {
|
||||
String snapshotId = params.getFirst("DBSnapshotIdentifier");
|
||||
String instanceId = params.getFirst("DBInstanceIdentifier");
|
||||
try {
|
||||
Collection<io.github.hectorvent.floci.services.rds.model.DbSnapshot> result = service.describeDbSnapshots(snapshotId, instanceId);
|
||||
Collection<io.github.hectorvent.floci.services.rds.model.DbSnapshot> result =
|
||||
service.describeDbSnapshots(snapshotId, instanceId, region);
|
||||
XmlBuilder xml = new XmlBuilder().start("DBSnapshots");
|
||||
for (io.github.hectorvent.floci.services.rds.model.DbSnapshot s : result) {
|
||||
xml.raw(dbSnapshotXml(s));
|
||||
@@ -1123,6 +1125,33 @@ public class RdsQueryHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleDescribeDbSnapshotAttributes(MultivaluedMap<String, String> params, String region) {
|
||||
String snapshotId = params.getFirst("DBSnapshotIdentifier");
|
||||
try {
|
||||
io.github.hectorvent.floci.services.rds.model.DbSnapshot snapshot =
|
||||
service.describeDbSnapshotAttributes(snapshotId, region);
|
||||
String result = dbSnapshotAttributesResultXml(snapshot);
|
||||
return Response.ok(AwsQueryResponse.envelope(
|
||||
"DescribeDBSnapshotAttributes", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleModifyDbSnapshotAttribute(MultivaluedMap<String, String> params, String region) {
|
||||
String snapshotId = params.getFirst("DBSnapshotIdentifier");
|
||||
String attributeName = params.getFirst("AttributeName");
|
||||
try {
|
||||
io.github.hectorvent.floci.services.rds.model.DbSnapshot snapshot = service.modifyDbSnapshotAttribute(
|
||||
snapshotId, attributeName, memberList(params, "ValuesToAdd"), memberList(params, "ValuesToRemove"), region);
|
||||
String result = dbSnapshotAttributesResultXml(snapshot);
|
||||
return Response.ok(AwsQueryResponse.envelope(
|
||||
"ModifyDBSnapshotAttribute", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
return AwsQueryResponse.error(e.getErrorCode(), e.getMessage(), AwsNamespaces.RDS, e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleDescribeDbProxies(MultivaluedMap<String, String> params, String region) {
|
||||
XmlBuilder xml = new XmlBuilder().start("DBProxies");
|
||||
for (DbProxy p : service.listDbProxies(params.getFirst("DBProxyName"), region)) {
|
||||
@@ -1446,9 +1475,25 @@ public class RdsQueryHandler {
|
||||
.elem("Port", s.getPort())
|
||||
.elem("IAMDatabaseAuthenticationEnabled", s.isIamDatabaseAuthenticationEnabled());
|
||||
if (s.getDbiResourceId() != null) xml.elem("DbiResourceId", s.getDbiResourceId());
|
||||
if (s.getDbSnapshotArn() != null) xml.elem("DBSnapshotArn", s.getDbSnapshotArn());
|
||||
xml.start("TagList");
|
||||
writeTags(xml, s.getTags());
|
||||
xml.end("TagList");
|
||||
return xml.end("DBSnapshot").build();
|
||||
}
|
||||
|
||||
private String dbSnapshotAttributesResultXml(io.github.hectorvent.floci.services.rds.model.DbSnapshot s) {
|
||||
XmlBuilder xml = new XmlBuilder().start("DBSnapshotAttributesResult")
|
||||
.elem("DBSnapshotIdentifier", s.getDbSnapshotIdentifier());
|
||||
xml.start("DBSnapshotAttributes").start("DBSnapshotAttribute")
|
||||
.elem("AttributeName", "restore");
|
||||
xml.start("AttributeValues");
|
||||
s.getRestoreAccountIds().forEach(id -> xml.elem("AttributeValue", id));
|
||||
xml.end("AttributeValues");
|
||||
xml.end("DBSnapshotAttribute").end("DBSnapshotAttributes");
|
||||
return xml.end("DBSnapshotAttributesResult").build();
|
||||
}
|
||||
|
||||
private String dbInstanceInnerXml(DbInstance i) {
|
||||
DbEndpoint ep = i.getEndpoint();
|
||||
String engineStr = instanceEngine(i);
|
||||
@@ -1980,6 +2025,7 @@ public class RdsQueryHandler {
|
||||
case "SubnetIds" -> quoted + "(\\.member|\\.SubnetIdentifier)?\\.\\d+";
|
||||
case "VpcSecurityGroupIds" -> quoted + "(\\.member|\\.VpcSecurityGroupId)?\\.\\d+";
|
||||
case "OptionsToRemove" -> quoted + "(\\.member|\\.OptionName)?\\.\\d+";
|
||||
case "ValuesToAdd", "ValuesToRemove" -> quoted + "(\\.member|\\.AttributeValue)?\\.\\d+";
|
||||
default -> {
|
||||
// Option configurations nest their membership lists under an indexed prefix,
|
||||
// so the alternate member names have to be matched on the suffix.
|
||||
|
||||
@@ -756,11 +756,22 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
}
|
||||
|
||||
public DbSnapshot createDbSnapshot(String snapshotId, String instanceId) {
|
||||
if (snapshots.get(snapshotId).isPresent()) {
|
||||
return createDbSnapshot(snapshotId, instanceId, Map.of(), regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public DbSnapshot createDbSnapshot(String snapshotId, String instanceId, Map<String, String> tags) {
|
||||
return createDbSnapshot(snapshotId, instanceId, tags, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public synchronized DbSnapshot createDbSnapshot(String snapshotId, String instanceId,
|
||||
Map<String, String> tags, String region) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String accountId = currentAccountId();
|
||||
if (findSnapshotForScope(accountId, effectiveRegion, snapshotId) != null) {
|
||||
throw new AwsException("DBSnapshotAlreadyExists", "DBSnapshot " + snapshotId + " already exists.", 400);
|
||||
}
|
||||
|
||||
DbInstance instance = getDbInstance(instanceId);
|
||||
DbInstance instance = getDbInstance(instanceId, effectiveRegion);
|
||||
|
||||
if (instance.getEngine() != DatabaseEngine.POSTGRES) {
|
||||
throw new AwsException("InvalidDBInstanceState", "Operation CreateDBSnapshot is not supported for engine " + instance.getEngine() + ".", 400);
|
||||
@@ -772,6 +783,8 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
instance.getCreatedAt(), instance.getEndpoint() != null ? instance.getEndpoint().port() : instance.getProxyPort(),
|
||||
instance.isIamDatabaseAuthenticationEnabled(), instance.getDbiResourceId(), instance.getDbInstanceClass());
|
||||
snapshot.setDbName(instance.getDbName());
|
||||
snapshot.setTags(tags != null ? new java.util.LinkedHashMap<>(tags) : new java.util.LinkedHashMap<>());
|
||||
snapshot.setDbSnapshotArn(regionResolver.buildArn("rds", effectiveRegion, "snapshot:" + snapshotId));
|
||||
|
||||
String sqlDump = "";
|
||||
if (!config.services().rds().mock()) {
|
||||
@@ -782,17 +795,26 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
throw new AwsException("InvalidDBInstanceState", "Failed to create snapshot: " + e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
snapshotData.put(snapshotId, sqlDump);
|
||||
snapshots.put(snapshotId, snapshot);
|
||||
snapshotData.put(dbResourceKey(effectiveRegion, snapshotId), sqlDump);
|
||||
putSnapshotForScope(accountId, effectiveRegion, snapshotId, snapshot);
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass, String availabilityZone, boolean multiAz, String dbSubnetGroupName, java.util.List<String> vpcSecurityGroupIds, java.util.Map<String, String> tags) {
|
||||
DbSnapshot snapshot = snapshots.get(snapshotId)
|
||||
return restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass, availabilityZone,
|
||||
multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass,
|
||||
String availabilityZone, boolean multiAz, String dbSubnetGroupName,
|
||||
java.util.List<String> vpcSecurityGroupIds,
|
||||
java.util.Map<String, String> tags, String region) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
DbSnapshot snapshot = Optional.ofNullable(findSnapshotForScope(currentAccountId(), effectiveRegion, snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound", "DBSnapshot " + snapshotId + " not found.", 404));
|
||||
|
||||
String sqlDump = snapshotData.get(snapshotId)
|
||||
String sqlDump = snapshotData.get(dbResourceKey(effectiveRegion, snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound", "DBSnapshot data for " + snapshotId + " not found.", 404));
|
||||
|
||||
String targetClass = (dbInstanceClass != null && !dbInstanceClass.isBlank()) ? dbInstanceClass : snapshot.getDbInstanceClass();
|
||||
@@ -824,8 +846,14 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
}
|
||||
|
||||
public Collection<DbSnapshot> describeDbSnapshots(String snapshotId, String instanceId) {
|
||||
return describeDbSnapshots(snapshotId, instanceId, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public Collection<DbSnapshot> describeDbSnapshots(String snapshotId, String instanceId, String region) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String accountId = currentAccountId();
|
||||
if (snapshotId != null && !snapshotId.isBlank()) {
|
||||
DbSnapshot snapshot = snapshots.get(snapshotId)
|
||||
DbSnapshot snapshot = Optional.ofNullable(findSnapshotForScope(accountId, effectiveRegion, snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound", "DBSnapshot " + snapshotId + " not found.", 404));
|
||||
if (instanceId != null && !instanceId.isBlank()) {
|
||||
if (instanceId.equals(snapshot.getDbInstanceIdentifier())) {
|
||||
@@ -837,7 +865,10 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
return List.of(snapshot);
|
||||
}
|
||||
|
||||
List<DbSnapshot> allSnapshots = snapshots.scan(k -> true);
|
||||
List<DbSnapshot> allSnapshots = snapshots.scan(k -> true).stream()
|
||||
.filter(s -> hasRdsResourceIdentity(s.getDbSnapshotArn(), accountId, effectiveRegion,
|
||||
"snapshot", s.getDbSnapshotIdentifier()))
|
||||
.toList();
|
||||
if (instanceId != null && !instanceId.isBlank()) {
|
||||
return allSnapshots.stream()
|
||||
.filter(s -> instanceId.equals(s.getDbInstanceIdentifier()))
|
||||
@@ -846,6 +877,46 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
return allSnapshots;
|
||||
}
|
||||
|
||||
public DbSnapshot describeDbSnapshotAttributes(String snapshotId) {
|
||||
return describeDbSnapshotAttributes(snapshotId, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public DbSnapshot describeDbSnapshotAttributes(String snapshotId, String region) {
|
||||
return Optional.ofNullable(findSnapshotForScope(currentAccountId(), effectiveRegion(region), snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound",
|
||||
"DBSnapshot " + snapshotId + " not found.", 404));
|
||||
}
|
||||
|
||||
public DbSnapshot modifyDbSnapshotAttribute(String snapshotId, String attributeName,
|
||||
List<String> valuesToAdd, List<String> valuesToRemove) {
|
||||
return modifyDbSnapshotAttribute(snapshotId, attributeName, valuesToAdd, valuesToRemove,
|
||||
regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public synchronized DbSnapshot modifyDbSnapshotAttribute(String snapshotId, String attributeName,
|
||||
List<String> valuesToAdd, List<String> valuesToRemove,
|
||||
String region) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String accountId = currentAccountId();
|
||||
DbSnapshot snapshot = Optional.ofNullable(findSnapshotForScope(accountId, effectiveRegion, snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound",
|
||||
"DBSnapshot " + snapshotId + " not found.", 404));
|
||||
if (!"restore".equals(attributeName)) {
|
||||
throw new AwsException("InvalidParameterValue",
|
||||
"AttributeName must be restore.", 400);
|
||||
}
|
||||
List<String> updated = new java.util.ArrayList<>(snapshot.getRestoreAccountIds());
|
||||
if (valuesToAdd != null) {
|
||||
valuesToAdd.stream().filter(v -> !updated.contains(v)).forEach(updated::add);
|
||||
}
|
||||
if (valuesToRemove != null) {
|
||||
updated.removeAll(valuesToRemove);
|
||||
}
|
||||
snapshot.setRestoreAccountIds(updated);
|
||||
putSnapshotForScope(accountId, effectiveRegion, snapshotId, snapshot);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public Map<String, String> listTagsForResource(String resourceName) {
|
||||
return listTagsForResource(resourceName, resourceRegionOrDefault(resourceName));
|
||||
}
|
||||
@@ -951,6 +1022,16 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
currentAccountId(), effectiveRegion, resourceId, group);
|
||||
});
|
||||
}
|
||||
case "snapshot" -> {
|
||||
DbSnapshot snapshot = Optional.ofNullable(
|
||||
findSnapshotForScope(currentAccountId(), effectiveRegion, resourceId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound",
|
||||
"DBSnapshot " + resourceId + " not found.", 404));
|
||||
yield new TagHandle(snapshot.getTags(), updated -> {
|
||||
snapshot.setTags(updated);
|
||||
putSnapshotForScope(currentAccountId(), effectiveRegion, resourceId, snapshot);
|
||||
});
|
||||
}
|
||||
case "db-proxy" -> {
|
||||
DbProxy proxy = proxies.scan(k -> true).stream()
|
||||
.filter(candidate -> effectiveRegion.equals(regionFromArn(candidate.getDbProxyArn())))
|
||||
@@ -5316,6 +5397,41 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized DbSnapshot findSnapshotForScope(String accountId, String region, String snapshotId) {
|
||||
String effectiveAccountId = accountId != null ? accountId : currentAccountId();
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String key = dbResourceKey(effectiveRegion, snapshotId);
|
||||
java.util.function.Predicate<DbSnapshot> owner = snapshot -> hasRdsResourceIdentity(
|
||||
snapshot.getDbSnapshotArn(), effectiveAccountId, effectiveRegion, "snapshot", snapshotId);
|
||||
if (snapshots instanceof AccountAwareStorageBackend<DbSnapshot> aware) {
|
||||
return aware.getForAccountMigratingLegacyKeys(
|
||||
effectiveAccountId, key, List.of(snapshotId), owner)
|
||||
.filter(owner)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
Optional<DbSnapshot> canonical = snapshots.get(key).filter(owner);
|
||||
if (canonical.isPresent()) {
|
||||
snapshots.get(snapshotId).filter(owner).ifPresent(ignored -> snapshots.delete(snapshotId));
|
||||
return canonical.get();
|
||||
}
|
||||
Optional<DbSnapshot> legacy = snapshots.get(snapshotId).filter(owner);
|
||||
if (legacy.isPresent()) {
|
||||
snapshots.put(key, legacy.get());
|
||||
snapshots.delete(snapshotId);
|
||||
}
|
||||
return legacy.orElse(null);
|
||||
}
|
||||
|
||||
private void putSnapshotForScope(String accountId, String region, String snapshotId, DbSnapshot snapshot) {
|
||||
String key = dbResourceKey(region, snapshotId);
|
||||
if (snapshots instanceof AccountAwareStorageBackend<DbSnapshot> aware) {
|
||||
aware.putForAccount(accountId, key, snapshot);
|
||||
} else {
|
||||
snapshots.put(key, snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized DbSubnetGroup findSubnetGroupForScope(
|
||||
String accountId, String region, String groupName) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
|
||||
@@ -3,13 +3,16 @@ package io.github.hectorvent.floci.services.rds.model;
|
||||
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 DbSnapshot {
|
||||
|
||||
private String dbSnapshotIdentifier;
|
||||
private String dbSnapshotArn;
|
||||
private String dbInstanceIdentifier;
|
||||
private Instant snapshotCreateTime;
|
||||
private DatabaseEngine engine;
|
||||
@@ -27,6 +30,8 @@ public class DbSnapshot {
|
||||
private String dbName;
|
||||
private String dbInstanceClass;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
/** Account IDs authorized to copy/restore this snapshot; the "restore" DBSnapshotAttribute. */
|
||||
private List<String> restoreAccountIds = new ArrayList<>();
|
||||
|
||||
public DbSnapshot() {}
|
||||
|
||||
@@ -55,6 +60,9 @@ public class DbSnapshot {
|
||||
public String getDbSnapshotIdentifier() { return dbSnapshotIdentifier; }
|
||||
public void setDbSnapshotIdentifier(String dbSnapshotIdentifier) { this.dbSnapshotIdentifier = dbSnapshotIdentifier; }
|
||||
|
||||
public String getDbSnapshotArn() { return dbSnapshotArn; }
|
||||
public void setDbSnapshotArn(String dbSnapshotArn) { this.dbSnapshotArn = dbSnapshotArn; }
|
||||
|
||||
public String getDbInstanceIdentifier() { return dbInstanceIdentifier; }
|
||||
public void setDbInstanceIdentifier(String dbInstanceIdentifier) { this.dbInstanceIdentifier = dbInstanceIdentifier; }
|
||||
|
||||
@@ -100,6 +108,11 @@ public class DbSnapshot {
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
|
||||
public List<String> getRestoreAccountIds() { return restoreAccountIds; }
|
||||
public void setRestoreAccountIds(List<String> restoreAccountIds) {
|
||||
this.restoreAccountIds = restoreAccountIds != null ? restoreAccountIds : new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getDbName() { return dbName; }
|
||||
public void setDbName(String dbName) { this.dbName = dbName; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user