mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(firehose): validate and persist ProcessingConfiguration (#3375)
* feat(firehose): validate and persist ProcessingConfiguration
A stream configured with a record transformation was accepted with a 200,
the member dropped by ignoreUnknown, and nothing echoed back. It is now
modelled, validated and stored, so a caller sees what it configured. The
transformation itself is not applied yet: records are still delivered
untransformed, and create and update say so in a warning.
The behavior follows what real AWS does, probed in us-west-2:
- A Lambda processor requires a LambdaArn, which must be a well-formed
function ARN, and BufferSizeInMBs and BufferIntervalInSeconds are
all-or-nothing.
- Processor types and parameter names are checked against AWS's enums,
reproducing the order those sets are printed in and the 1-based member
paths of the constraint messages.
- UpdateDestination replaces the whole block rather than merging it
member-wise, the opposite of DataFormatConversionConfiguration: an update
carrying only {"Enabled": false} leaves no processors behind, and an
update is validated against its own content.
- A stored Lambda processor gains NumberOfRetries 3 and the stream's
RoleArn, echoed in AWS's own parameter order.
Two checks AWS does not make are deliberately absent: NumberOfRetries is
not range-checked, accepted as 0 or 9 despite the documented 1 to 8, and the
function a LambdaArn names is not required to exist, unlike the Glue table a
conversion schema names.
* docs(firehose): record what AWS does with a null processor list member
Probed: real AWS answers InternalFailure for "Processors": [null] and for
"Parameters": [null], a fault of its own rather than a validation error.
Reproducing that helps nobody, so the entry stays ignored, which leaves the
configuration a caller would have had by omitting it, and the deviation is
written down instead. A test pins the choice so it reads as a decision.
The review also asked for a maximum of 3 on the processor list. Probing found
no such bound: three, four and five processors all pass validation and reach
the role check, so nothing is enforced here.
This commit is contained in:
1 parent
1726c6a8a3
commit
debf9fb0dc
10 files changed
+1056
-9
No files matched your search
+13
-9
@@ -46,7 +46,7 @@ public class FirehoseJsonHandler {
|
||||
S3Destination s3 = null;
|
||||
if (request.has("S3DestinationConfiguration")) {
|
||||
s3 = mapper.treeToValue(request.get("S3DestinationConfiguration"), S3Destination.class);
|
||||
dropConversionFromLegacyShape(s3);
|
||||
dropExtendedOnlyMembersFromLegacyShape(s3);
|
||||
S3DestinationValidator.validateWireShape(s3, "s3DestinationConfiguration");
|
||||
} else if (request.has("ExtendedS3DestinationConfiguration")) {
|
||||
s3 = mapper.treeToValue(request.get("ExtendedS3DestinationConfiguration"), S3Destination.class);
|
||||
@@ -82,7 +82,7 @@ public class FirehoseJsonHandler {
|
||||
S3DestinationValidator.validateWireShape(update, "extendedS3DestinationUpdate");
|
||||
} else if (request.has("S3DestinationUpdate")) {
|
||||
update = mapper.treeToValue(request.get("S3DestinationUpdate"), S3Destination.class);
|
||||
dropConversionFromLegacyShape(update);
|
||||
dropExtendedOnlyMembersFromLegacyShape(update);
|
||||
S3DestinationValidator.validateWireShape(update, "s3DestinationUpdate");
|
||||
}
|
||||
firehoseService.updateDestination(name, currentVersionId, destinationId, update);
|
||||
@@ -198,24 +198,28 @@ public class FirehoseJsonHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears {@code DataFormatConversionConfiguration} from a legacy
|
||||
* {@code S3DestinationConfiguration} or {@code S3DestinationUpdate}, which AWS
|
||||
* models only on the extended shapes. The two share one class here, which would
|
||||
* otherwise let a legacy request store a member its contract does not define.
|
||||
* Clears {@code DataFormatConversionConfiguration} and
|
||||
* {@code ProcessingConfiguration} from a legacy {@code S3DestinationConfiguration}
|
||||
* or {@code S3DestinationUpdate}, which AWS models only on the extended shapes. The
|
||||
* two share one class here, which would otherwise let a legacy request store members
|
||||
* its contract does not define.
|
||||
*
|
||||
* Dropped rather than rejected: AWS's JSON protocol ignores a member the shape does
|
||||
* not model, so a request carrying one succeeds with the member disregarded. The
|
||||
* SDKs cannot even send it, since it is absent from the legacy shape's model.
|
||||
* SDKs cannot even send them, since both are absent from the legacy shape's model.
|
||||
* That was probed for the conversion member; the processing member is the same
|
||||
* mechanism on the same shape.
|
||||
*
|
||||
* Only this member is cleared. {@code FileExtension}, {@code CustomTimeZone} and
|
||||
* Only these two are cleared. {@code FileExtension}, {@code CustomTimeZone} and
|
||||
* {@code S3BackupMode} are extended-only too and reach the legacy shapes the same
|
||||
* way, a deviation that predates this change and is recorded in
|
||||
* docs/services/firehose.md; widening the clearing would change behavior those
|
||||
* members already have.
|
||||
*/
|
||||
private static void dropConversionFromLegacyShape(S3Destination s3) {
|
||||
private static void dropExtendedOnlyMembersFromLegacyShape(S3Destination s3) {
|
||||
if (s3 != null) {
|
||||
s3.setDataFormatConversionConfiguration(null);
|
||||
s3.setProcessingConfiguration(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,6 +309,11 @@ public class FirehoseService implements ResourceProvider {
|
||||
|
||||
validateBufferingHints(s3Config);
|
||||
DataFormatConversionValidator.validateEffective(s3Config);
|
||||
ProcessingConfigurationValidator.validateEffective(s3Config);
|
||||
if (s3Config != null) {
|
||||
s3Config.canonicalizeProcessors();
|
||||
}
|
||||
warnIfProcessingEnabled(name, s3Config);
|
||||
String arn = AwsArnUtils.Arn.of("firehose", region, accountId,
|
||||
"deliverystream/" + name).toString();
|
||||
// CreateDeliveryStream's KinesisStreamSourceConfiguration carries only the ARN and
|
||||
@@ -364,7 +369,9 @@ public class FirehoseService implements ResourceProvider {
|
||||
S3Destination current = destination.getExtendedS3DestinationDescription();
|
||||
if (current == null) {
|
||||
DataFormatConversionValidator.validateEffective(update);
|
||||
ProcessingConfigurationValidator.validateEffective(update);
|
||||
update.applyDefaults();
|
||||
update.canonicalizeProcessors();
|
||||
destination.setExtendedS3DestinationDescription(update);
|
||||
} else {
|
||||
// AWS validates the merged effective state, not the update shape: enabling
|
||||
@@ -373,12 +380,19 @@ public class FirehoseService implements ResourceProvider {
|
||||
// Validating a merged view first also keeps a failed update from leaving a
|
||||
// half-merged destination behind in the memory backend.
|
||||
DataFormatConversionValidator.validateEffective(mergedView(current, update));
|
||||
// Not the merged view: an update carrying a ProcessingConfiguration replaces
|
||||
// the stored one outright, so AWS validates what the update itself says. A
|
||||
// processor without LambdaArn is rejected even when the stored one had it
|
||||
// (probed 2026-09-10, unlike the conversion block above).
|
||||
ProcessingConfigurationValidator.validateEffective(update);
|
||||
mergeDestination(current, update);
|
||||
current.canonicalizeProcessors();
|
||||
}
|
||||
stream.setVersionId(String.valueOf(parseVersionId(stream.getVersionId()) + 1));
|
||||
stream.setLastUpdateTimestamp(java.time.Instant.now());
|
||||
streamPut(streamKey, stream);
|
||||
LOG.infov("Updated destination {0} of Firehose delivery stream {1}", destinationId, name);
|
||||
warnIfProcessingEnabled(name, stream.s3Destination());
|
||||
}
|
||||
|
||||
public void startDeliveryStreamEncryption(String name, String keyType, String keyArn) {
|
||||
@@ -450,6 +464,20 @@ public class FirehoseService implements ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Says, where the configuration is set, that the transformation will not be applied.
|
||||
* Fires on create and on every update that leaves it enabled, so a caller who keeps
|
||||
* changing the destination keeps being told. Deliberately not in the flush path,
|
||||
* which runs on every buffered delivery: create and update are caller-driven and are
|
||||
* the moments a caller can act on the warning.
|
||||
*/
|
||||
private static void warnIfProcessingEnabled(String name, S3Destination s3) {
|
||||
if (s3 != null && s3.isProcessingEnabled()) {
|
||||
LOG.warnv("Delivery stream {0} enables a record transformation, which Floci does not"
|
||||
+ " apply yet; its records will be delivered untransformed", name);
|
||||
}
|
||||
}
|
||||
|
||||
private static void mergeDestination(S3Destination current, S3Destination update) {
|
||||
if (update.getRoleArn() != null) current.setRoleArn(update.getRoleArn());
|
||||
if (update.getBucketArn() != null) current.setBucketArn(update.getBucketArn());
|
||||
@@ -461,6 +489,12 @@ public class FirehoseService implements ResourceProvider {
|
||||
if (update.getBufferingHints() != null) current.setBufferingHints(update.getBufferingHints());
|
||||
if (update.getEncryptionConfiguration() != null) current.setEncryptionConfiguration(update.getEncryptionConfiguration());
|
||||
if (update.getS3BackupMode() != null) current.setS3BackupMode(update.getS3BackupMode());
|
||||
// Replaced whole, not merged member-wise: an update carrying only
|
||||
// {"Enabled": false} leaves Processors empty on real AWS, where the same shape
|
||||
// preserves the conversion block's members (probed 2026-09-10).
|
||||
if (update.getProcessingConfiguration() != null) {
|
||||
current.setProcessingConfiguration(update.getProcessingConfiguration());
|
||||
}
|
||||
if (update.getDataFormatConversionConfiguration() != null) {
|
||||
current.setDataFormatConversionConfiguration(mergeConversion(
|
||||
current.getDataFormatConversionConfiguration(), update.getDataFormatConversionConfiguration()));
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package io.github.hectorvent.floci.services.firehose;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessingConfiguration;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Processor;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessorParameter;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The semantic checks AWS runs on a ProcessingConfiguration once its modeled
|
||||
* constraints hold, in the order and with the wording probed against real AWS
|
||||
* (us-west-2, 2026-09-10).
|
||||
*
|
||||
* Deliberately absent: AWS does not range-check NumberOfRetries at configuration
|
||||
* time, accepting 0 and 9 alike despite the documented 1 to 8, and it does not
|
||||
* check that the function the LambdaArn names exists, unlike the Glue table a
|
||||
* conversion schema names. Both were probed; neither is enforced here.
|
||||
*/
|
||||
final class ProcessingConfigurationValidator {
|
||||
|
||||
/**
|
||||
* Lambda's own ARN shape rather than "anything without a colon": probed, AWS
|
||||
* answers "Invalid lambda ARN." for a function name carrying a space or slashes,
|
||||
* which a looser pattern would have stored.
|
||||
*/
|
||||
private static final Pattern LAMBDA_ARN = Pattern.compile(
|
||||
"arn:aws[a-zA-Z-]*:lambda:[a-z0-9-]+:\\d{12}:function:[a-zA-Z0-9_-]{1,64}"
|
||||
+ "(:(\\$LATEST|[a-zA-Z0-9_-]{1,128}))?");
|
||||
|
||||
private ProcessingConfigurationValidator() {}
|
||||
|
||||
static void validateEffective(S3Destination config) {
|
||||
if (config == null || config.getProcessingConfiguration() == null) {
|
||||
return;
|
||||
}
|
||||
ProcessingConfiguration processing = config.getProcessingConfiguration();
|
||||
if (processing.getProcessors() == null) {
|
||||
return;
|
||||
}
|
||||
// Before anything a processor's own parameters say: a repeated name is rejected
|
||||
// even when the LambdaArn the processor needs is missing too (probed).
|
||||
int lambdaProcessors = 0;
|
||||
for (Processor processor : processing.getProcessors()) {
|
||||
if (processor == null) {
|
||||
continue;
|
||||
}
|
||||
rejectDuplicateParameters(processor.getParameters());
|
||||
if ("Lambda".equals(processor.getType())) {
|
||||
lambdaProcessors++;
|
||||
}
|
||||
}
|
||||
if (lambdaProcessors > 1) {
|
||||
throw invalidArgument("Cannot have more than 1 Lambda processor.");
|
||||
}
|
||||
for (Processor processor : processing.getProcessors()) {
|
||||
if (processor == null || !"Lambda".equals(processor.getType())) {
|
||||
continue;
|
||||
}
|
||||
validateLambdaProcessor(processor.getParameters());
|
||||
}
|
||||
}
|
||||
|
||||
private static void rejectDuplicateParameters(List<ProcessorParameter> parameters) {
|
||||
if (parameters == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> seen = new HashSet<>();
|
||||
for (ProcessorParameter parameter : parameters) {
|
||||
if (parameter != null && parameter.getParameterName() != null
|
||||
&& !seen.add(parameter.getParameterName())) {
|
||||
throw invalidArgument("Duplicate ProcessorParameter passed to ProcessingConfiguration.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateLambdaProcessor(List<ProcessorParameter> parameters) {
|
||||
String lambdaArn = parameterValue(parameters, "LambdaArn");
|
||||
if (lambdaArn == null || lambdaArn.isEmpty()) {
|
||||
throw invalidArgument("LambdaArn is required when Lambda processor is used.");
|
||||
}
|
||||
if (!LAMBDA_ARN.matcher(lambdaArn).matches()) {
|
||||
throw invalidArgument("Invalid lambda ARN.");
|
||||
}
|
||||
boolean hasSize = parameterValue(parameters, "BufferSizeInMBs") != null;
|
||||
boolean hasInterval = parameterValue(parameters, "BufferIntervalInSeconds") != null;
|
||||
if (hasSize != hasInterval) {
|
||||
throw invalidArgument("Both BufferSizeInMBs and BufferIntervalInSeconds are required"
|
||||
+ " to configure buffering for lambda processor.");
|
||||
}
|
||||
}
|
||||
|
||||
private static String parameterValue(List<ProcessorParameter> parameters, String name) {
|
||||
if (parameters == null) {
|
||||
return null;
|
||||
}
|
||||
for (ProcessorParameter parameter : parameters) {
|
||||
if (parameter != null && name.equals(parameter.getParameterName())) {
|
||||
return parameter.getParameterValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AwsException invalidArgument(String message) {
|
||||
return new AwsException("InvalidArgumentException", message, 400);
|
||||
}
|
||||
}
|
||||
+100
@@ -4,12 +4,16 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.OpenXJsonSerDe;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.OrcSerDe;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ParquetSerDe;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessingConfiguration;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Processor;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessorParameter;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.SchemaConfiguration;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Serializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -104,6 +108,7 @@ final class S3DestinationValidator {
|
||||
// violations sit in more than one of them.
|
||||
collectOpenXMappingViolations(config, shapeName, violations);
|
||||
collectSchemaViolations(config, shapeName, violations);
|
||||
collectProcessingViolations(config, shapeName, violations);
|
||||
if (!violations.isEmpty()) {
|
||||
throw constraintViolations(violations);
|
||||
}
|
||||
@@ -312,6 +317,101 @@ final class S3DestinationValidator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The processor and parameter enums, in the order AWS prints them in a
|
||||
* constraint message, which is neither declaration nor alphabetical order
|
||||
* (probed 2026-09-10).
|
||||
*/
|
||||
private static final String PROCESSOR_TYPE_SET =
|
||||
"[Decompression, Lambda, RecordDeAggregation, MetadataExtraction,"
|
||||
+ " AppendDelimiterToRecord, CloudWatchLogProcessing]";
|
||||
private static final String PARAMETER_NAME_SET =
|
||||
"[DataMessageExtraction, NumberOfRetries, Delimiter, RoleArn, JsonParsingEngine,"
|
||||
+ " SubRecordType, MetadataExtractionQuery, BufferIntervalInSeconds, LambdaArn,"
|
||||
+ " BufferSizeInMBs, CompressionFormat]";
|
||||
private static final int PARAMETER_VALUE_MAX_LENGTH = 5120;
|
||||
private static final String PARAMETER_VALUE_REGEX = "^(?!\\s*$).+";
|
||||
private static final Pattern PARAMETER_VALUE_NOT_BLANK = Pattern.compile(PARAMETER_VALUE_REGEX);
|
||||
private static final Set<String> PROCESSOR_TYPES = Set.of("Decompression", "Lambda",
|
||||
"RecordDeAggregation", "MetadataExtraction", "AppendDelimiterToRecord",
|
||||
"CloudWatchLogProcessing");
|
||||
private static final Set<String> PARAMETER_NAMES = Set.of("DataMessageExtraction",
|
||||
"NumberOfRetries", "Delimiter", "RoleArn", "JsonParsingEngine", "SubRecordType",
|
||||
"MetadataExtractionQuery", "BufferIntervalInSeconds", "LambdaArn", "BufferSizeInMBs",
|
||||
"CompressionFormat");
|
||||
|
||||
/**
|
||||
* Both members are required, and the value carries a length range and a
|
||||
* not-blank pattern. An empty value trips the length and the pattern, printed in
|
||||
* that order, as the probed message does.
|
||||
*/
|
||||
private static void collectParameterViolations(ProcessorParameter parameter, String shapeName,
|
||||
String parameterPath, List<String> violations) {
|
||||
String name = parameter.getParameterName();
|
||||
if (name == null) {
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterName",
|
||||
"Member must not be null"));
|
||||
} else if (!PARAMETER_NAMES.contains(name)) {
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterName",
|
||||
"Member must satisfy enum value set: " + PARAMETER_NAME_SET));
|
||||
}
|
||||
String value = parameter.getParameterValue();
|
||||
if (value == null) {
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterValue",
|
||||
"Member must not be null"));
|
||||
return;
|
||||
}
|
||||
if (value.length() < 1) {
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterValue",
|
||||
"Member must have length greater than or equal to 1"));
|
||||
} else if (value.length() > PARAMETER_VALUE_MAX_LENGTH) {
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterValue",
|
||||
"Member must have length less than or equal to " + PARAMETER_VALUE_MAX_LENGTH));
|
||||
}
|
||||
if (PARAMETER_VALUE_NOT_BLANK.matcher(value).matches()) {
|
||||
return;
|
||||
}
|
||||
violations.add(violation(shapeName, parameterPath + ".parameterValue",
|
||||
"Member must satisfy regular expression pattern: " + PARAMETER_VALUE_REGEX));
|
||||
}
|
||||
|
||||
/** Members are numbered from 1 in these paths, as the probed messages show. */
|
||||
private static void collectProcessingViolations(S3Destination config, String shapeName,
|
||||
List<String> violations) {
|
||||
ProcessingConfiguration processing = config.getProcessingConfiguration();
|
||||
if (processing == null || processing.getProcessors() == null) {
|
||||
return;
|
||||
}
|
||||
List<Processor> processors = processing.getProcessors();
|
||||
for (int i = 0; i < processors.size(); i++) {
|
||||
Processor processor = processors.get(i);
|
||||
if (processor == null) {
|
||||
continue;
|
||||
}
|
||||
String processorPath = "processingConfiguration.processors." + (i + 1) + ".member";
|
||||
// The processor's own member before the ones nested in it, which is the
|
||||
// order AWS prints them when both are violated (probed).
|
||||
if (processor.getType() == null) {
|
||||
violations.add(violation(shapeName, processorPath + ".type", "Member must not be null"));
|
||||
} else if (!PROCESSOR_TYPES.contains(processor.getType())) {
|
||||
violations.add(violation(shapeName, processorPath + ".type",
|
||||
"Member must satisfy enum value set: " + PROCESSOR_TYPE_SET));
|
||||
}
|
||||
List<ProcessorParameter> parameters = processor.getParameters();
|
||||
if (parameters == null) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < parameters.size(); j++) {
|
||||
ProcessorParameter parameter = parameters.get(j);
|
||||
if (parameter == null) {
|
||||
continue;
|
||||
}
|
||||
String parameterPath = processorPath + ".parameters." + (j + 1) + ".member";
|
||||
collectParameterViolations(parameter, shapeName, parameterPath, violations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String violation(String shapeName, String member, String constraint) {
|
||||
return "Value at '" + shapeName + "." + member + "' failed to satisfy constraint: " + constraint;
|
||||
}
|
||||
|
||||
+136
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
@@ -196,6 +197,11 @@ public class DeliveryStreamDescription {
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class S3Destination {
|
||||
|
||||
/** The order AWS echoes a Lambda processor's parameters in, whatever order it received them (probed). */
|
||||
private static final List<String> LAMBDA_PARAMETER_ORDER = List.of("LambdaArn",
|
||||
"NumberOfRetries", "RoleArn", "BufferSizeInMBs", "BufferIntervalInSeconds");
|
||||
|
||||
@JsonProperty("RoleARN")
|
||||
private String roleArn;
|
||||
@JsonProperty("BucketARN")
|
||||
@@ -218,6 +224,8 @@ public class DeliveryStreamDescription {
|
||||
private String s3BackupMode;
|
||||
@JsonProperty("DataFormatConversionConfiguration")
|
||||
private DataFormatConversionConfiguration dataFormatConversionConfiguration;
|
||||
@JsonProperty("ProcessingConfiguration")
|
||||
private ProcessingConfiguration processingConfiguration;
|
||||
|
||||
public S3Destination() {}
|
||||
public String getRoleArn() { return roleArn; }
|
||||
@@ -247,6 +255,27 @@ public class DeliveryStreamDescription {
|
||||
this.dataFormatConversionConfiguration = configuration;
|
||||
}
|
||||
|
||||
public ProcessingConfiguration getProcessingConfiguration() {
|
||||
return processingConfiguration;
|
||||
}
|
||||
public void setProcessingConfiguration(ProcessingConfiguration processingConfiguration) {
|
||||
this.processingConfiguration = processingConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* True when a transformation applies to deliveries. An omitted Enabled is taken
|
||||
* as enabled, following the conversion block, where that was probed; the
|
||||
* processing block's own behavior for an omitted Enabled was not, and nothing
|
||||
* but the "not applied yet" warning reads this today.
|
||||
*
|
||||
* Ignored for serialization for the same reason as the accessor below.
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isProcessingEnabled() {
|
||||
return processingConfiguration != null
|
||||
&& !Boolean.FALSE.equals(processingConfiguration.getEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* True when data format conversion applies to deliveries: the configuration is
|
||||
* present and not explicitly disabled. AWS treats an omitted Enabled as enabled
|
||||
@@ -299,6 +328,57 @@ public class DeliveryStreamDescription {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Real AWS answers with more than the caller sent: a Lambda processor comes back
|
||||
* with NumberOfRetries defaulted to 3 and RoleArn filled from the delivery
|
||||
* stream's role, and the parameters are echoed in a fixed order whatever order
|
||||
* they arrived in (probed 2026-09-10).
|
||||
*
|
||||
* Called as a destination is written, not as it is read. Doing it on the way out
|
||||
* would mutate what storage handed back, so whether a Describe had happened would
|
||||
* decide what a later update sees, and RoleArn would be injected from whichever
|
||||
* role was current at the time of the read.
|
||||
*/
|
||||
public void canonicalizeProcessors() {
|
||||
if (processingConfiguration == null || processingConfiguration.getProcessors() == null) {
|
||||
return;
|
||||
}
|
||||
for (Processor processor : processingConfiguration.getProcessors()) {
|
||||
if (processor == null || !"Lambda".equals(processor.getType())
|
||||
|| processor.getParameters() == null) {
|
||||
continue;
|
||||
}
|
||||
// A repeated name never reaches here, the validator rejects it as AWS
|
||||
// does, so this only has to be stable for the names it does see.
|
||||
Map<String, String> byName = new LinkedHashMap<>();
|
||||
for (ProcessorParameter parameter : processor.getParameters()) {
|
||||
if (parameter != null && parameter.getParameterName() != null) {
|
||||
byName.putIfAbsent(parameter.getParameterName(), parameter.getParameterValue());
|
||||
}
|
||||
}
|
||||
byName.putIfAbsent("NumberOfRetries", "3");
|
||||
if (roleArn != null) {
|
||||
byName.putIfAbsent("RoleArn", roleArn);
|
||||
}
|
||||
List<ProcessorParameter> ordered = new ArrayList<>(byName.size());
|
||||
for (String name : LAMBDA_PARAMETER_ORDER) {
|
||||
if (byName.containsKey(name)) {
|
||||
ordered.add(parameter(name, byName.remove(name)));
|
||||
}
|
||||
}
|
||||
byName.forEach((name, value) -> ordered.add(parameter(name, value)));
|
||||
processor.setParameters(ordered);
|
||||
}
|
||||
}
|
||||
|
||||
private static ProcessorParameter parameter(String name, String value) {
|
||||
ProcessorParameter parameter = new ProcessorParameter();
|
||||
parameter.setParameterName(name);
|
||||
parameter.setParameterValue(value);
|
||||
return parameter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A view of this config with only the fields AWS's plain S3DestinationDescription
|
||||
* actually has - FileExtension, CustomTimeZone, and S3BackupMode are extended-only.
|
||||
@@ -325,6 +405,62 @@ public class DeliveryStreamDescription {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlike the conversion configuration below, UpdateDestination replaces this block
|
||||
* outright rather than merging it member-wise (probed), so a stored member never has
|
||||
* to survive an update that omits it.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class ProcessingConfiguration {
|
||||
@JsonProperty("Enabled")
|
||||
private Boolean enabled;
|
||||
@JsonProperty("Processors")
|
||||
private List<Processor> processors;
|
||||
|
||||
public ProcessingConfiguration() {}
|
||||
|
||||
public Boolean getEnabled() { return enabled; }
|
||||
public void setEnabled(Boolean enabled) { this.enabled = enabled; }
|
||||
public List<Processor> getProcessors() { return processors; }
|
||||
public void setProcessors(List<Processor> processors) { this.processors = processors; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class Processor {
|
||||
@JsonProperty("Type")
|
||||
private String type;
|
||||
@JsonProperty("Parameters")
|
||||
private List<ProcessorParameter> parameters;
|
||||
|
||||
public Processor() {}
|
||||
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
public List<ProcessorParameter> getParameters() { return parameters; }
|
||||
public void setParameters(List<ProcessorParameter> parameters) { this.parameters = parameters; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class ProcessorParameter {
|
||||
@JsonProperty("ParameterName")
|
||||
private String parameterName;
|
||||
@JsonProperty("ParameterValue")
|
||||
private String parameterValue;
|
||||
|
||||
public ProcessorParameter() {}
|
||||
|
||||
public String getParameterName() { return parameterName; }
|
||||
public void setParameterName(String parameterName) { this.parameterName = parameterName; }
|
||||
public String getParameterValue() { return parameterValue; }
|
||||
public void setParameterValue(String parameterValue) { this.parameterValue = parameterValue; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Members stay null-honest, mirroring real AWS: DescribeDeliveryStream echoes the
|
||||
* configuration exactly as it was given (an empty ParquetSerDe stays {}, CatalogId
|
||||
|
||||
Reference in new issue
Block a user