fix: create Firehose buckets and backfill EKS OIDC issuers in the resource's region (#5099)

* fix: create Firehose buckets and backfill EKS OIDC issuers in the resource's region

Firehose auto-created a missing destination bucket, and the Parquet staging
bucket, in the default region rather than the stream's, and the EKS startup
backfill minted the OIDC issuer of a pre-IRSA cluster in the default region
rather than the cluster's. Both now take the region from the resource's ARN,
as cluster creation already does.

* fix(firehose): keep the shared default and staging buckets in the default region

Creating every missing bucket in its stream's region let the first stream to
deliver decide the region of the buckets all streams share: the default
destination bucket, used by every stream without its own, and the Parquet
staging bucket. Only a stream's own destination bucket now follows the
stream's region; the shared ones stay in the default region, as before. The
tests cover a configured bucket in eu-west-1 and the shared default bucket.

* fix(firehose): tell a stream's own destination from the shared default by configuration

The shared default bucket was recognised by its name, so a stream that
configured floci-firehose-results as its own destination had a missing
bucket created in the default region instead of its own. Whether the bucket
is the stream's own now follows from the stream having a destination
configured, the same test that picks the bucket.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-05 00:53:37 -04:00
1 parent 539bf15fdd
commit 4d9585583d
4 files changed
+80 -7

No files matched your search

@@ -276,6 +276,28 @@ class EksServiceTest {
assertTrue(oidcService.findVerificationKey(issuer).isPresent());
}
@Test
void initBackfillsTheOidcIssuerInTheClustersOwnRegion() {
StorageBackend<String, Cluster> clusterStore = new InMemoryStorage<>();
StorageBackend<String, ClusterOidcKey> keyStore = new InMemoryStorage<>();
Cluster legacy = new Cluster();
legacy.setName("eu-legacy-cluster");
legacy.setArn("arn:aws:eks:eu-west-1:000000000000:cluster/eu-legacy-cluster");
legacy.setStatus(ClusterStatus.ACTIVE);
clusterStore.put("eu-legacy-cluster", legacy);
EksOidcService oidcService = new EksOidcService(
fixedStorageFactory(keyStore), new ObjectMapper());
EksService restarted = new EksService(fixedStorageFactory(clusterStore), testConfig(),
new RegionResolver("us-east-1", "000000000000"), null, null, oidcService,
mock(EksAccessEntryService.class), mock(EksPodIdentityAssociationService.class));
restarted.init();
String issuer = clusterStore.get("eu-legacy-cluster").orElseThrow().getIdentity().getOidc().getIssuer();
assertTrue(issuer.startsWith("https://oidc.eks.eu-west-1.amazonaws.com/id/"), issuer);
}
@Test
void initLeavesAnExistingOidcIssuerUnchanged() {
StorageBackend<String, Cluster> clusterStore = new InMemoryStorage<>();
@@ -248,6 +248,43 @@ class FirehoseServiceTest {
.getDeliveryStreamName());
}
@Test
void aMissingDestinationBucketIsCreatedInTheStreamsRegion() {
S3Destination s3 = new S3Destination();
s3.setBucketArn("arn:aws:s3:::eu-stream-bucket");
firehoseService.createDeliveryStream("eu-west-1", "000000000000", "eu-stream", s3, List.of(), null, null);
firehoseService.putRecord("000000000000", "eu-west-1", "eu-stream",
new Record("one".getBytes(StandardCharsets.UTF_8)));
firehoseService.flush("000000000000", "eu-west-1", "eu-stream");
verify(s3Service).createBucket("eu-stream-bucket", "eu-west-1");
}
@Test
void aDestinationNamedLikeTheDefaultBucketFollowsItsStream() {
S3Destination s3 = new S3Destination();
s3.setBucketArn("arn:aws:s3:::floci-firehose-results");
firehoseService.createDeliveryStream("eu-west-1", "000000000000", "eu-named", s3, List.of(), null, null);
firehoseService.putRecord("000000000000", "eu-west-1", "eu-named",
new Record("one".getBytes(StandardCharsets.UTF_8)));
firehoseService.flush("000000000000", "eu-west-1", "eu-named");
verify(s3Service).createBucket("floci-firehose-results", "eu-west-1");
}
@Test
void theSharedDefaultBucketStaysInTheDefaultRegion() {
firehoseService.createDeliveryStream("eu-west-1", "000000000000", "eu-default", null, List.of(), null, null);
firehoseService.putRecord("000000000000", "eu-west-1", "eu-default",
new Record("one".getBytes(StandardCharsets.UTF_8)));
firehoseService.flush("000000000000", "eu-west-1", "eu-default");
verify(s3Service).createBucket("floci-firehose-results", "us-east-1");
}
@Test
void sameNameIsIndependentForEachAccountRegionDimension() {
List<String[]> owners = List.of(