feat(guardduty): support publishing destinations (#6016)

* feat(guardduty): support publishing destinations

Add CreatePublishingDestination, DescribePublishingDestination,
UpdatePublishingDestination, DeletePublishingDestination and
ListPublishingDestinations under /detector/{detectorId}/publishingDestination.
Previously these returned UnknownOperationException, which broke
Terraform's aws_guardduty_publishing_destination.

Destinations are stored per detector through StorageFactory, so they follow
the detector's account and region scoping, survive a persistent-storage
reload, and report PUBLISHING on create (the state Terraform's create waiter
targets). A missing destination returns BadRequestException with the message
the Terraform provider matches for not-found. Deleting a detector removes its
destinations.

clientToken makes create idempotent and is capped at the model's 64
characters, measured in code points as the model's length constraint is.
destinationArn stays optional on create: the GuardDuty model marks
DestinationProperties.DestinationArn and KmsKeyArn as not required
(botocore guardduty/2017-11-28 service-2.json).

The service gains a five-store constructor; the existing three- and
four-store (malware protection plan) constructors delegate to it.

Closes #4983

* docs(guardduty): update the service matrix operation count

* test(guardduty): cover the publishing destination lifecycle through the SDK

Create, describe, update, list and delete an S3 publishing destination
with the AWS SDK v2 GuardDuty client, asserting the shapes as the SDK
reads them, including the required publishingFailureStartTimestamp.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-19 16:45:15 -04:00
1 parent 28799ed352
commit fb390968d5
8 files changed
+654 -1

No files matched your search

@@ -9,6 +9,9 @@ import software.amazon.awssdk.services.guardduty.model.AutoEnableMembers;
import software.amazon.awssdk.services.guardduty.model.BadRequestException;
import software.amazon.awssdk.services.guardduty.model.CreateDetectorResponse;
import software.amazon.awssdk.services.guardduty.model.DescribeOrganizationConfigurationResponse;
import software.amazon.awssdk.services.guardduty.model.DescribePublishingDestinationResponse;
import software.amazon.awssdk.services.guardduty.model.DestinationProperties;
import software.amazon.awssdk.services.guardduty.model.DestinationType;
import software.amazon.awssdk.services.guardduty.model.DetectorAdditionalConfiguration;
import software.amazon.awssdk.services.guardduty.model.DetectorFeature;
import software.amazon.awssdk.services.guardduty.model.DetectorFeatureConfiguration;
@@ -23,6 +26,7 @@ import software.amazon.awssdk.services.guardduty.model.OrgFeatureAdditionalConfi
import software.amazon.awssdk.services.guardduty.model.OrgFeatureStatus;
import software.amazon.awssdk.services.guardduty.model.OrganizationAdditionalConfiguration;
import software.amazon.awssdk.services.guardduty.model.OrganizationFeatureConfiguration;
import software.amazon.awssdk.services.guardduty.model.PublishingStatus;
import java.util.List;
import java.util.Map;
@@ -118,6 +122,73 @@ class GuardDutyTest {
}
}
@Test
void publishingDestinationLifecycleUsesAwsSdkWireShapes() throws Exception {
String bucketArn = "arn:aws:s3:::compat-findings-bucket";
String firstKey = "arn:aws:kms:us-east-1:000000000000:key/compat-first";
String secondKey = "arn:aws:kms:us-east-1:000000000000:key/compat-second";
try (GuardDutyClient guardduty = TestFixtures.guardDutyClient()) {
String detectorId = guardduty.createDetector(request -> request.enable(true)).detectorId();
try (AutoCloseable deleteDetector = () ->
guardduty.deleteDetector(request -> request.detectorId(detectorId))) {
String destinationId = guardduty.createPublishingDestination(request -> request
.detectorId(detectorId)
.destinationType(DestinationType.S3)
.destinationProperties(DestinationProperties.builder()
.destinationArn(bucketArn)
.kmsKeyArn(firstKey)
.build()))
.destinationId();
assertThat(destinationId).isNotBlank();
DescribePublishingDestinationResponse described =
guardduty.describePublishingDestination(request -> request
.detectorId(detectorId)
.destinationId(destinationId));
assertThat(described.destinationId()).isEqualTo(destinationId);
assertThat(described.destinationType()).isEqualTo(DestinationType.S3);
assertThat(described.status()).isEqualTo(PublishingStatus.PUBLISHING);
assertThat(described.publishingFailureStartTimestamp()).isNotNull();
assertThat(described.destinationProperties().destinationArn()).isEqualTo(bucketArn);
assertThat(described.destinationProperties().kmsKeyArn()).isEqualTo(firstKey);
guardduty.updatePublishingDestination(request -> request
.detectorId(detectorId)
.destinationId(destinationId)
.destinationProperties(DestinationProperties.builder()
.destinationArn(bucketArn)
.kmsKeyArn(secondKey)
.build()));
assertThat(guardduty.describePublishingDestination(request -> request
.detectorId(detectorId)
.destinationId(destinationId))
.destinationProperties().kmsKeyArn()).isEqualTo(secondKey);
assertThat(guardduty.listPublishingDestinations(request -> request.detectorId(detectorId))
.destinations())
.singleElement()
.satisfies(destination -> {
assertThat(destination.destinationId()).isEqualTo(destinationId);
assertThat(destination.destinationType()).isEqualTo(DestinationType.S3);
assertThat(destination.status()).isEqualTo(PublishingStatus.PUBLISHING);
});
guardduty.deletePublishingDestination(request -> request
.detectorId(detectorId)
.destinationId(destinationId));
assertThat(guardduty.listPublishingDestinations(request -> request.detectorId(detectorId))
.destinations()).isEmpty();
assertThatThrownBy(() -> guardduty.describePublishingDestination(request -> request
.detectorId(detectorId)
.destinationId(destinationId)))
.isInstanceOf(BadRequestException.class)
.hasMessageContaining("input parameters have invalid values");
}
}
}
@Test
void organizationConfigurationRoundTripsThroughTheSdk() throws Exception {
try (GuardDutyClient guardduty = TestFixtures.guardDutyClient()) {