Skip to content

Commit 1e2cff1

Browse files
authored
chore(kinesisfirehose-alpha): replacedestinations property with destination and change type from array to single IDestination (#31630)
### Reason for this change Setting a destination for your Delivery Stream was previously done by passing in an array of Destinations but with a restriction that there there could only be one Destination in that array. This property type does not make sense for the current user experience (have an array but can only specify one destination) and also does not align with the behaviour in the AWS Console which only allows you to select a single destination. If Kinesis Firehose ever supports multiple destinations in the future then we can add a new property to support that which will not be a breaking change. ### Description of changes BREAKING CHANGE: replaced `destinations` property with `destination` (singular) and changed the type from array of Destinations to a single Destination. Old behaviour would only allow an array with a single Destination to be passed in anyway. ### Description of how you validated changes unit tests + no integ snapshot changes. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a37b27e commit 1e2cff1

File tree

11 files changed

+86
-104
lines changed

11 files changed

+86
-104
lines changed

Diff for: packages/@aws-cdk/aws-iot-actions-alpha/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ import * as destinations from '@aws-cdk/aws-kinesisfirehose-destinations-alpha';
243243

244244
const bucket = new s3.Bucket(this, 'MyBucket');
245245
const stream = new firehose.DeliveryStream(this, 'MyStream', {
246-
destinations: [new destinations.S3Bucket(bucket)],
246+
destination: new destinations.S3Bucket(bucket),
247247
});
248248

249249
const topicRule = new iot.TopicRule(this, 'TopicRule', {

Diff for: packages/@aws-cdk/aws-iot-actions-alpha/test/kinesis-firehose/integ.firehose-put-record-action.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestStack extends cdk.Stack {
2121
removalPolicy: cdk.RemovalPolicy.DESTROY,
2222
});
2323
const stream = new firehose.DeliveryStream(this, 'MyStream', {
24-
destinations: [new destinations.S3Bucket(bucket)],
24+
destination: new destinations.S3Bucket(bucket),
2525
});
2626
topicRule.addAction(
2727
new actions.FirehosePutRecordAction(stream, {

Diff for: packages/@aws-cdk/aws-kinesisfirehose-alpha/README.md

+17-20
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ used as a destination. More supported destinations are covered [below](#destinat
4141
```ts
4242
const bucket = new s3.Bucket(this, 'Bucket');
4343
new firehose.DeliveryStream(this, 'Delivery Stream', {
44-
destinations: [new destinations.S3Bucket(bucket)],
44+
destination: new destinations.S3Bucket(bucket),
4545
});
4646
```
4747

@@ -71,7 +71,7 @@ declare const destination: firehose.IDestination;
7171
const sourceStream = new kinesis.Stream(this, 'Source Stream');
7272
new firehose.DeliveryStream(this, 'Delivery Stream', {
7373
sourceStream: sourceStream,
74-
destinations: [destination],
74+
destination: destination,
7575
});
7676
```
7777

@@ -108,7 +108,7 @@ declare const bucket: s3.Bucket;
108108
const s3Destination = new destinations.S3Bucket(bucket);
109109

110110
new firehose.DeliveryStream(this, 'Delivery Stream', {
111-
destinations: [s3Destination],
111+
destination: s3Destination,
112112
});
113113
```
114114

@@ -154,18 +154,18 @@ declare const destination: firehose.IDestination;
154154
// SSE with an AWS-owned key
155155
new firehose.DeliveryStream(this, 'Delivery Stream AWS Owned', {
156156
encryption: firehose.StreamEncryption.awsOwnedKey(),
157-
destinations: [destination],
157+
destination: destination,
158158
});
159159
// SSE with an customer-managed key that is created automatically by the CDK
160160
new firehose.DeliveryStream(this, 'Delivery Stream Implicit Customer Managed', {
161161
encryption: firehose.StreamEncryption.customerManagedKey(),
162-
destinations: [destination],
162+
destination: destination,
163163
});
164164
// SSE with an customer-managed key that is explicitly specified
165165
declare const key: kms.Key;
166166
new firehose.DeliveryStream(this, 'Delivery Stream Explicit Customer Managed', {
167167
encryption: firehose.StreamEncryption.customerManagedKey(key),
168-
destinations: [destination],
168+
destination: destination,
169169
});
170170
```
171171

@@ -196,7 +196,7 @@ const destination = new destinations.S3Bucket(bucket, {
196196
});
197197

198198
new firehose.DeliveryStream(this, 'Delivery Stream', {
199-
destinations: [destination],
199+
destination: destination,
200200
});
201201
```
202202

@@ -208,7 +208,7 @@ const destination = new destinations.S3Bucket(bucket, {
208208
loggingConfig: new destinations.DisableLogging(),
209209
});
210210
new firehose.DeliveryStream(this, 'Delivery Stream', {
211-
destinations: [destination],
211+
destination: destination,
212212
});
213213
```
214214

@@ -271,7 +271,7 @@ const s3Destination = new destinations.S3Bucket(bucket, {
271271
compression: destinations.Compression.SNAPPY,
272272
});
273273
new firehose.DeliveryStream(this, 'Delivery Stream', {
274-
destinations: [s3Destination],
274+
destination: s3Destination,
275275
});
276276
```
277277

@@ -292,7 +292,7 @@ const destination = new destinations.S3Bucket(bucket, {
292292
bufferingSize: Size.mebibytes(8),
293293
});
294294
new firehose.DeliveryStream(this, 'Delivery Stream', {
295-
destinations: [destination],
295+
destination: destination,
296296
});
297297
```
298298

@@ -309,7 +309,7 @@ const destination = new destinations.S3Bucket(bucket, {
309309
bufferingInterval: Duration.seconds(0),
310310
});
311311
new firehose.DeliveryStream(this, 'ZeroBufferDeliveryStream', {
312-
destinations: [destination],
312+
destination: destination,
313313
});
314314
```
315315

@@ -332,7 +332,7 @@ const destination = new destinations.S3Bucket(bucket, {
332332
encryptionKey: key,
333333
});
334334
new firehose.DeliveryStream(this, 'Delivery Stream', {
335-
destinations: [destination],
335+
destination: destination,
336336
});
337337
```
338338

@@ -350,35 +350,32 @@ backed up to S3.
350350
// Enable backup of all source records (to an S3 bucket created by CDK).
351351
declare const bucket: s3.Bucket;
352352
new firehose.DeliveryStream(this, 'Delivery Stream Backup All', {
353-
destinations: [
353+
destination:
354354
new destinations.S3Bucket(bucket, {
355355
s3Backup: {
356356
mode: destinations.BackupMode.ALL,
357357
},
358358
}),
359-
],
360359
});
361360
// Explicitly provide an S3 bucket to which all source records will be backed up.
362361
declare const backupBucket: s3.Bucket;
363362
new firehose.DeliveryStream(this, 'Delivery Stream Backup All Explicit Bucket', {
364-
destinations: [
363+
destination:
365364
new destinations.S3Bucket(bucket, {
366365
s3Backup: {
367366
bucket: backupBucket,
368367
},
369368
}),
370-
],
371369
});
372370
// Explicitly provide an S3 prefix under which all source records will be backed up.
373371
new firehose.DeliveryStream(this, 'Delivery Stream Backup All Explicit Prefix', {
374-
destinations: [
372+
destination:
375373
new destinations.S3Bucket(bucket, {
376374
s3Backup: {
377375
mode: destinations.BackupMode.ALL,
378376
dataOutputPrefix: 'mybackup',
379377
},
380378
}),
381-
],
382379
});
383380
```
384381

@@ -431,7 +428,7 @@ const s3Destination = new destinations.S3Bucket(bucket, {
431428
processor: lambdaProcessor,
432429
});
433430
new firehose.DeliveryStream(this, 'Delivery Stream', {
434-
destinations: [s3Destination],
431+
destination: s3Destination,
435432
});
436433
```
437434

@@ -473,7 +470,7 @@ const destinationRole = new iam.Role(this, 'Destination Role', {
473470
declare const bucket: s3.Bucket;
474471
const destination = new destinations.S3Bucket(bucket, { role: destinationRole });
475472
new firehose.DeliveryStream(this, 'Delivery Stream', {
476-
destinations: [destination],
473+
destination: destination,
477474
role: deliveryStreamRole,
478475
});
479476
```

Diff for: packages/@aws-cdk/aws-kinesisfirehose-alpha/lib/delivery-stream.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,9 @@ export enum StreamEncryptionType {
185185
*/
186186
export interface DeliveryStreamProps {
187187
/**
188-
* The destinations that this delivery stream will deliver data to.
189-
*
190-
* Only a singleton array is supported at this time.
188+
* The destination that this delivery stream will deliver data to.
191189
*/
192-
readonly destinations: IDestination[];
190+
readonly destination: IDestination;
193191

194192
/**
195193
* A name for the delivery stream.
@@ -324,10 +322,6 @@ export class DeliveryStream extends DeliveryStreamBase {
324322

325323
this._role = props.role;
326324

327-
if (props.destinations.length !== 1) {
328-
throw new Error(`Only one destination is allowed per delivery stream, given ${props.destinations.length}`);
329-
}
330-
331325
if (props.encryption?.encryptionKey || props.sourceStream) {
332326
this._role = this._role ?? new iam.Role(this, 'Service Role', {
333327
assumedBy: new iam.ServicePrincipal('firehose.amazonaws.com'),
@@ -369,7 +363,7 @@ export class DeliveryStream extends DeliveryStreamBase {
369363
readStreamGrant = props.sourceStream.grantRead(this._role);
370364
}
371365

372-
const destinationConfig = props.destinations[0].bind(this, {});
366+
const destinationConfig = props.destination.bind(this, {});
373367

374368
const resource = new CfnDeliveryStream(this, 'Resource', {
375369
deliveryStreamEncryptionConfigurationInput: encryptionConfig,

0 commit comments

Comments
 (0)