feat(firehose): return ExtendedS3DestinationDescription and support UpdateDestination (#1710)

* feat(firehose): return ExtendedS3DestinationDescription and support UpdateDestination

The Terraform/Pulumi provider creates delivery streams with
ExtendedS3DestinationConfiguration and reads ExtendedS3DestinationDescription
back after create; Floci parsed the config lossily and only ever emitted
S3DestinationDescription, breaking the provider read. Store the full config
(RoleARN, ErrorOutputPrefix, CompressionFormat, EncryptionConfiguration),
emit it under both wire keys like real AWS, add the required output members
(VersionId, DeliveryStreamType, HasMoreDestinations, DestinationId), and
implement UpdateDestination with version checking.

Refs #1043

* fix(firehose): reject empty destination updates and guard version parse

* fix(firehose): reject partial BufferingHints instead of absorbing defaults

AWS requires SizeInMBs and IntervalInSeconds to be specified together
(firehose service-2.json: "if you specify a value for it, you must also
specify a value for IntervalInSeconds, and vice versa"). The primitive
fields with initializers made a partial payload indistinguishable from a
full one, silently persisting a default over an existing value. Members
are now null-honest boxed Integers, create and update reject one-sided
hints with the declared InvalidArgumentException before any mutation,
and defaults apply only when the whole object is absent.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-07-02 23:59:11 -05:00
1 parent d8c09754d5
commit b3c54c1854
9 files changed
+794 -13

No files matched your search

@@ -0,0 +1,153 @@
package com.floci.test;
import org.junit.jupiter.api.*;
import software.amazon.awssdk.services.firehose.FirehoseClient;
import software.amazon.awssdk.services.firehose.model.*;
import java.util.UUID;
import static org.assertj.core.api.Assertions.*;
/**
* Issue #1043 — the Terraform/Pulumi provider creates delivery streams with
* ExtendedS3DestinationConfiguration and reads ExtendedS3DestinationDescription
* back (plus VersionId/DestinationId to drive UpdateDestination).
*/
@DisplayName("Firehose extended S3 destination — issue #1043")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class FirehoseExtendedS3Test {
private static FirehoseClient firehose;
private static final String STREAM_NAME = "sdk-extended-s3-" + UUID.randomUUID().toString().substring(0, 8);
private static final String ROLE_ARN = "arn:aws:iam::000000000000:role/firehose-role";
private static final String BUCKET_ARN = "arn:aws:s3:::floci-firehose-sdk-test";
private static String versionId;
private static String destinationId;
@BeforeAll
static void setup() {
firehose = TestFixtures.firehoseClient();
}
@AfterAll
static void cleanup() {
if (firehose != null) {
try {
firehose.deleteDeliveryStream(DeleteDeliveryStreamRequest.builder()
.deliveryStreamName(STREAM_NAME).build());
} catch (Exception ignored) {}
firehose.close();
}
}
@Test
@Order(1)
@DisplayName("Create delivery stream with ExtendedS3DestinationConfiguration")
void createExtendedS3DeliveryStream() {
CreateDeliveryStreamResponse response = firehose.createDeliveryStream(
CreateDeliveryStreamRequest.builder()
.deliveryStreamName(STREAM_NAME)
.deliveryStreamType(DeliveryStreamType.DIRECT_PUT)
.extendedS3DestinationConfiguration(ExtendedS3DestinationConfiguration.builder()
.roleARN(ROLE_ARN)
.bucketARN(BUCKET_ARN)
.prefix("events/data/")
.errorOutputPrefix("events/errors/")
.compressionFormat(CompressionFormat.GZIP)
.bufferingHints(BufferingHints.builder()
.intervalInSeconds(120)
.sizeInMBs(64)
.build())
.build())
.build());
assertThat(response.deliveryStreamARN()).contains(STREAM_NAME);
}
@Test
@Order(2)
@DisplayName("Describe returns ExtendedS3DestinationDescription (the provider read path)")
void describeReturnsExtendedS3Description() {
DeliveryStreamDescription desc = firehose.describeDeliveryStream(
DescribeDeliveryStreamRequest.builder()
.deliveryStreamName(STREAM_NAME)
.build())
.deliveryStreamDescription();
assertThat(desc.versionId()).isNotBlank();
assertThat(desc.deliveryStreamType()).isEqualTo(DeliveryStreamType.DIRECT_PUT);
assertThat(desc.hasMoreDestinations()).isFalse();
assertThat(desc.destinations()).hasSize(1);
DestinationDescription destination = desc.destinations().get(0);
assertThat(destination.destinationId()).isNotBlank();
ExtendedS3DestinationDescription extended = destination.extendedS3DestinationDescription();
assertThat(extended).as("ExtendedS3DestinationDescription must be present").isNotNull();
assertThat(extended.roleARN()).isEqualTo(ROLE_ARN);
assertThat(extended.bucketARN()).isEqualTo(BUCKET_ARN);
assertThat(extended.prefix()).isEqualTo("events/data/");
assertThat(extended.errorOutputPrefix()).isEqualTo("events/errors/");
assertThat(extended.compressionFormat()).isEqualTo(CompressionFormat.GZIP);
assertThat(extended.bufferingHints().sizeInMBs()).isEqualTo(64);
assertThat(extended.bufferingHints().intervalInSeconds()).isEqualTo(120);
assertThat(extended.encryptionConfiguration().noEncryptionConfig())
.isEqualTo(NoEncryptionConfig.NO_ENCRYPTION);
assertThat(destination.s3DestinationDescription())
.as("deprecated S3DestinationDescription mirror must also be present")
.isNotNull();
assertThat(destination.s3DestinationDescription().bucketARN()).isEqualTo(BUCKET_ARN);
versionId = desc.versionId();
destinationId = destination.destinationId();
}
@Test
@Order(3)
@DisplayName("UpdateDestination applies changes and bumps VersionId")
void updateDestination() {
firehose.updateDestination(UpdateDestinationRequest.builder()
.deliveryStreamName(STREAM_NAME)
.currentDeliveryStreamVersionId(versionId)
.destinationId(destinationId)
.extendedS3DestinationUpdate(ExtendedS3DestinationUpdate.builder()
.compressionFormat(CompressionFormat.SNAPPY)
.bufferingHints(BufferingHints.builder()
.intervalInSeconds(60)
.sizeInMBs(128)
.build())
.build())
.build());
DeliveryStreamDescription desc = firehose.describeDeliveryStream(
DescribeDeliveryStreamRequest.builder()
.deliveryStreamName(STREAM_NAME)
.build())
.deliveryStreamDescription();
assertThat(desc.versionId()).isNotEqualTo(versionId);
ExtendedS3DestinationDescription extended =
desc.destinations().get(0).extendedS3DestinationDescription();
assertThat(extended.compressionFormat()).isEqualTo(CompressionFormat.SNAPPY);
assertThat(extended.bufferingHints().sizeInMBs()).isEqualTo(128);
assertThat(extended.roleARN()).as("untouched fields survive the update").isEqualTo(ROLE_ARN);
assertThat(extended.prefix()).isEqualTo("events/data/");
}
@Test
@Order(4)
@DisplayName("UpdateDestination with stale version throws ConcurrentModificationException")
void updateDestinationStaleVersion() {
assertThatThrownBy(() -> firehose.updateDestination(UpdateDestinationRequest.builder()
.deliveryStreamName(STREAM_NAME)
.currentDeliveryStreamVersionId("99")
.destinationId(destinationId)
.extendedS3DestinationUpdate(ExtendedS3DestinationUpdate.builder()
.compressionFormat(CompressionFormat.GZIP)
.build())
.build()))
.isInstanceOf(ConcurrentModificationException.class);
}
}