mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix: persist SSE specification and return SSEDescription for encrypted tables (#1191)
This commit is contained in:
1 parent
24250b658d
commit
9a7070992e
3 files changed
+117
-1
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.dynamodb;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -23,6 +24,9 @@ import java.util.*;
|
||||
@ApplicationScoped
|
||||
public class DynamoDbJsonHandler {
|
||||
|
||||
private static final String DEFAULT_ACCOUNT_ID = "000000000000";
|
||||
private static final String SSE_TYPE_KMS = "KMS";
|
||||
|
||||
private final DynamoDbService dynamoDbService;
|
||||
private final DynamoDbStreamService dynamoDbStreamService;
|
||||
private final KinesisService kinesisService;
|
||||
@@ -189,6 +193,13 @@ public class DynamoDbJsonHandler {
|
||||
table.setStreamViewType(viewType);
|
||||
}
|
||||
|
||||
JsonNode sseSpec = request.path("SSESpecification");
|
||||
if (!sseSpec.isMissingNode() && sseSpec.path("Enabled").asBoolean(false)) {
|
||||
table.setSseEnabled(true);
|
||||
table.setSseType(SSE_TYPE_KMS);
|
||||
table.setKmsMasterKeyArn(defaultKmsMasterKeyArn(region));
|
||||
}
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.set("TableDescription", tableToNode(table));
|
||||
return Response.ok(response).build();
|
||||
@@ -1777,6 +1788,16 @@ public class DynamoDbJsonHandler {
|
||||
ptNode.put("NumberOfDecreasesToday", table.getProvisionedThroughput().getNumberOfDecreasesToday());
|
||||
node.set("ProvisionedThroughput", ptNode);
|
||||
|
||||
if (table.isSseEnabled()) {
|
||||
ObjectNode sseDescription = objectMapper.createObjectNode();
|
||||
sseDescription.put("Status", "ENABLED");
|
||||
sseDescription.put("SSEType", table.getSseType() != null ? table.getSseType() : SSE_TYPE_KMS);
|
||||
sseDescription.put("KMSMasterKeyArn", table.getKmsMasterKeyArn() != null
|
||||
? table.getKmsMasterKeyArn()
|
||||
: defaultKmsMasterKeyArn(AwsArnUtils.regionOrDefault(table.getTableArn(), "us-east-1")));
|
||||
node.set("SSEDescription", sseDescription);
|
||||
}
|
||||
|
||||
List<GlobalSecondaryIndex> gsis = table.getGlobalSecondaryIndexes();
|
||||
if (gsis != null && !gsis.isEmpty()) {
|
||||
ArrayNode gsiArray = objectMapper.createArrayNode();
|
||||
@@ -1865,6 +1886,11 @@ public class DynamoDbJsonHandler {
|
||||
return node;
|
||||
}
|
||||
|
||||
private String defaultKmsMasterKeyArn(String region) {
|
||||
return AwsArnUtils.Arn.of("kms", region, DEFAULT_ACCOUNT_ID,
|
||||
"key/aws-managed-dynamodb").toString();
|
||||
}
|
||||
|
||||
private ObjectNode continuousBackupsDescriptionNode(TableDefinition table) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("ContinuousBackupsStatus", "ENABLED");
|
||||
|
||||
@@ -39,6 +39,9 @@ public class TableDefinition {
|
||||
private boolean streamEnabled;
|
||||
private String streamArn;
|
||||
private String streamViewType;
|
||||
private boolean sseEnabled;
|
||||
private String sseType;
|
||||
private String kmsMasterKeyArn;
|
||||
private List<KinesisStreamingDestination> kinesisStreamingDestinations;
|
||||
|
||||
public TableDefinition() {
|
||||
@@ -148,6 +151,15 @@ public class TableDefinition {
|
||||
public String getStreamViewType() { return streamViewType; }
|
||||
public void setStreamViewType(String streamViewType) { this.streamViewType = streamViewType; }
|
||||
|
||||
public boolean isSseEnabled() { return sseEnabled; }
|
||||
public void setSseEnabled(boolean sseEnabled) { this.sseEnabled = sseEnabled; }
|
||||
|
||||
public String getSseType() { return sseType; }
|
||||
public void setSseType(String sseType) { this.sseType = sseType; }
|
||||
|
||||
public String getKmsMasterKeyArn() { return kmsMasterKeyArn; }
|
||||
public void setKmsMasterKeyArn(String kmsMasterKeyArn) { this.kmsMasterKeyArn = kmsMasterKeyArn; }
|
||||
|
||||
public List<KinesisStreamingDestination> getKinesisStreamingDestinations() {
|
||||
return kinesisStreamingDestinations != null ? kinesisStreamingDestinations : new ArrayList<>();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user