mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(rds): store the Tags and KmsKeyId of CreateDBCluster (#7225)
* fix(rds): store the Tags and KmsKeyId of CreateDBCluster CreateDBCluster ignored both. ListTagsForResource on a cluster created with Tags returned none, DescribeDBClusters had no TagList, and it never returned a KmsKeyId, so a caller that reads them back sees none of them. The Terraform AWS provider then has an empty tags and tags_all in the state and, because kms_key_id differs from the configuration, plans to replace the cluster on every run. handleCreateDbCluster now reads Tags (the Tag and member forms, as the other RDS create calls do) and KmsKeyId and stores them on the new cluster. DBCluster gets a KmsKeyId of its own, separate from the master user secret's, and CreateDBCluster and DescribeDBClusters return it, and the cluster's tags as its TagList. * docs(rds): keep the addRolesToNewDbCluster javadoc above its method applyCreateDbClusterOptions was inserted between the javadoc of addRolesToNewDbCluster and the method, so that javadoc described the new method. Each method now has its own. * refactor(rds): tag a new DB cluster through addTagsToResource
This commit is contained in:
4 files changed
+136
No files matched your search
@@ -1357,6 +1357,16 @@ public class RdsQueryHandler {
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted,
|
||||
requestedPort);
|
||||
}
|
||||
Map<String, String> tags = parseTags(params);
|
||||
String kmsKeyId = params.getFirst("KmsKeyId");
|
||||
if (!tags.isEmpty()) {
|
||||
service.addTagsToResource(cluster.getDbClusterArn(), tags, region);
|
||||
}
|
||||
if (kmsKeyId != null && !kmsKeyId.isBlank()) {
|
||||
cluster = service.setNewDbClusterKmsKeyId(region, id, kmsKeyId);
|
||||
} else if (!tags.isEmpty()) {
|
||||
cluster = service.getDbCluster(id, region);
|
||||
}
|
||||
if (!associatedRoles.isEmpty()) {
|
||||
try {
|
||||
cluster = service.addRolesToNewDbCluster(region, id, associatedRoles);
|
||||
@@ -3474,6 +3484,7 @@ public class RdsQueryHandler {
|
||||
.elem("HttpEndpointEnabled", c.isHttpEndpointEnabled())
|
||||
.elem("MultiAZ", c.isMultiAz())
|
||||
.elem("StorageEncrypted", c.isStorageEncrypted())
|
||||
.elem("KmsKeyId", c.getKmsKeyId())
|
||||
.elem("AvailabilityZone", c.getAvailabilityZone() != null ? c.getAvailabilityZone() : config.defaultAvailabilityZone())
|
||||
.elem("PreferredMaintenanceWindow", "mon:00:00-mon:03:00")
|
||||
.elem("PreferredBackupWindow", "04:00-06:00")
|
||||
@@ -3527,6 +3538,9 @@ public class RdsQueryHandler {
|
||||
}
|
||||
xml.end("DBClusterMembers");
|
||||
writeAssociatedRoles(xml, c.getAssociatedRoles(), "DBClusterRole");
|
||||
xml.start("TagList");
|
||||
writeTags(xml, c.getTags());
|
||||
xml.end("TagList");
|
||||
return xml.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -11212,6 +11212,15 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
return RESPONSE_COPIER.convertValue(cluster, DbCluster.class);
|
||||
}
|
||||
|
||||
/** Stores the KmsKeyId a CreateDBCluster request carries, which {@code createDbCluster} has no argument for. */
|
||||
public synchronized DbCluster setNewDbClusterKmsKeyId(String region, String clusterId, String kmsKeyId) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
DbCluster cluster = getDbCluster(clusterId, effectiveRegion);
|
||||
cluster.setKmsKeyId(kmsKeyId);
|
||||
putClusterForScope(currentAccountId(), effectiveRegion, clusterId, cluster);
|
||||
return RESPONSE_COPIER.convertValue(cluster, DbCluster.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives a cluster {@code CreateDBCluster} just made the roles the request named, all in one
|
||||
* step: either every role is associated or none is. The handler deletes the new cluster when
|
||||
|
||||
@@ -46,6 +46,7 @@ public class DbCluster {
|
||||
private List<DbRoleAssociation> associatedRoles = new ArrayList<>();
|
||||
private String engineMode;
|
||||
private boolean storageEncrypted;
|
||||
private String kmsKeyId;
|
||||
|
||||
private String dockerVolumeName;
|
||||
private String volumeId;
|
||||
@@ -199,6 +200,9 @@ public class DbCluster {
|
||||
public boolean isStorageEncrypted() { return storageEncrypted; }
|
||||
public void setStorageEncrypted(boolean storageEncrypted) { this.storageEncrypted = storageEncrypted; }
|
||||
|
||||
public String getKmsKeyId() { return kmsKeyId; }
|
||||
public void setKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; }
|
||||
|
||||
public String getDockerVolumeName() { return dockerVolumeName; }
|
||||
public void setDockerVolumeName(String dockerVolumeName) { this.dockerVolumeName = dockerVolumeName; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user