Skip to content

Commit

Permalink
chore(kinesisfirehose-alpha): replacedestinations property with `de…
Browse files Browse the repository at this point in the history
…stination` 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*
  • Loading branch information
paulhcsun authored Oct 4, 2024
1 parent a37b27e commit 1e2cff1
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 104 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iot-actions-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ import * as destinations from '@aws-cdk/aws-kinesisfirehose-destinations-alpha';

const bucket = new s3.Bucket(this, 'MyBucket');
const stream = new firehose.DeliveryStream(this, 'MyStream', {
destinations: [new destinations.S3Bucket(bucket)],
destination: new destinations.S3Bucket(bucket),
});

const topicRule = new iot.TopicRule(this, 'TopicRule', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestStack extends cdk.Stack {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const stream = new firehose.DeliveryStream(this, 'MyStream', {
destinations: [new destinations.S3Bucket(bucket)],
destination: new destinations.S3Bucket(bucket),
});
topicRule.addAction(
new actions.FirehosePutRecordAction(stream, {
Expand Down
37 changes: 17 additions & 20 deletions packages/@aws-cdk/aws-kinesisfirehose-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ used as a destination. More supported destinations are covered [below](#destinat
```ts
const bucket = new s3.Bucket(this, 'Bucket');
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [new destinations.S3Bucket(bucket)],
destination: new destinations.S3Bucket(bucket),
});
```

Expand Down Expand Up @@ -71,7 +71,7 @@ declare const destination: firehose.IDestination;
const sourceStream = new kinesis.Stream(this, 'Source Stream');
new firehose.DeliveryStream(this, 'Delivery Stream', {
sourceStream: sourceStream,
destinations: [destination],
destination: destination,
});
```

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

new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [s3Destination],
destination: s3Destination,
});
```

Expand Down Expand Up @@ -154,18 +154,18 @@ declare const destination: firehose.IDestination;
// SSE with an AWS-owned key
new firehose.DeliveryStream(this, 'Delivery Stream AWS Owned', {
encryption: firehose.StreamEncryption.awsOwnedKey(),
destinations: [destination],
destination: destination,
});
// SSE with an customer-managed key that is created automatically by the CDK
new firehose.DeliveryStream(this, 'Delivery Stream Implicit Customer Managed', {
encryption: firehose.StreamEncryption.customerManagedKey(),
destinations: [destination],
destination: destination,
});
// SSE with an customer-managed key that is explicitly specified
declare const key: kms.Key;
new firehose.DeliveryStream(this, 'Delivery Stream Explicit Customer Managed', {
encryption: firehose.StreamEncryption.customerManagedKey(key),
destinations: [destination],
destination: destination,
});
```

Expand Down Expand Up @@ -196,7 +196,7 @@ const destination = new destinations.S3Bucket(bucket, {
});

new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [destination],
destination: destination,
});
```

Expand All @@ -208,7 +208,7 @@ const destination = new destinations.S3Bucket(bucket, {
loggingConfig: new destinations.DisableLogging(),
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [destination],
destination: destination,
});
```

Expand Down Expand Up @@ -271,7 +271,7 @@ const s3Destination = new destinations.S3Bucket(bucket, {
compression: destinations.Compression.SNAPPY,
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [s3Destination],
destination: s3Destination,
});
```

Expand All @@ -292,7 +292,7 @@ const destination = new destinations.S3Bucket(bucket, {
bufferingSize: Size.mebibytes(8),
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [destination],
destination: destination,
});
```

Expand All @@ -309,7 +309,7 @@ const destination = new destinations.S3Bucket(bucket, {
bufferingInterval: Duration.seconds(0),
});
new firehose.DeliveryStream(this, 'ZeroBufferDeliveryStream', {
destinations: [destination],
destination: destination,
});
```

Expand All @@ -332,7 +332,7 @@ const destination = new destinations.S3Bucket(bucket, {
encryptionKey: key,
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [destination],
destination: destination,
});
```

Expand All @@ -350,35 +350,32 @@ backed up to S3.
// Enable backup of all source records (to an S3 bucket created by CDK).
declare const bucket: s3.Bucket;
new firehose.DeliveryStream(this, 'Delivery Stream Backup All', {
destinations: [
destination:
new destinations.S3Bucket(bucket, {
s3Backup: {
mode: destinations.BackupMode.ALL,
},
}),
],
});
// Explicitly provide an S3 bucket to which all source records will be backed up.
declare const backupBucket: s3.Bucket;
new firehose.DeliveryStream(this, 'Delivery Stream Backup All Explicit Bucket', {
destinations: [
destination:
new destinations.S3Bucket(bucket, {
s3Backup: {
bucket: backupBucket,
},
}),
],
});
// Explicitly provide an S3 prefix under which all source records will be backed up.
new firehose.DeliveryStream(this, 'Delivery Stream Backup All Explicit Prefix', {
destinations: [
destination:
new destinations.S3Bucket(bucket, {
s3Backup: {
mode: destinations.BackupMode.ALL,
dataOutputPrefix: 'mybackup',
},
}),
],
});
```

Expand Down Expand Up @@ -431,7 +428,7 @@ const s3Destination = new destinations.S3Bucket(bucket, {
processor: lambdaProcessor,
});
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [s3Destination],
destination: s3Destination,
});
```

Expand Down Expand Up @@ -473,7 +470,7 @@ const destinationRole = new iam.Role(this, 'Destination Role', {
declare const bucket: s3.Bucket;
const destination = new destinations.S3Bucket(bucket, { role: destinationRole });
new firehose.DeliveryStream(this, 'Delivery Stream', {
destinations: [destination],
destination: destination,
role: deliveryStreamRole,
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,9 @@ export enum StreamEncryptionType {
*/
export interface DeliveryStreamProps {
/**
* The destinations that this delivery stream will deliver data to.
*
* Only a singleton array is supported at this time.
* The destination that this delivery stream will deliver data to.
*/
readonly destinations: IDestination[];
readonly destination: IDestination;

/**
* A name for the delivery stream.
Expand Down Expand Up @@ -324,10 +322,6 @@ export class DeliveryStream extends DeliveryStreamBase {

this._role = props.role;

if (props.destinations.length !== 1) {
throw new Error(`Only one destination is allowed per delivery stream, given ${props.destinations.length}`);
}

if (props.encryption?.encryptionKey || props.sourceStream) {
this._role = this._role ?? new iam.Role(this, 'Service Role', {
assumedBy: new iam.ServicePrincipal('firehose.amazonaws.com'),
Expand Down Expand Up @@ -369,7 +363,7 @@ export class DeliveryStream extends DeliveryStreamBase {
readStreamGrant = props.sourceStream.grantRead(this._role);
}

const destinationConfig = props.destinations[0].bind(this, {});
const destinationConfig = props.destination.bind(this, {});

const resource = new CfnDeliveryStream(this, 'Resource', {
deliveryStreamEncryptionConfigurationInput: encryptionConfig,
Expand Down
Loading

0 comments on commit 1e2cff1

Please sign in to comment.