Skip to content

Commit

Permalink
fix(scheduler-targets-alpha): kinesis data firehose target uses l1 in…
Browse files Browse the repository at this point in the history
…stead of l2 (#32150)

### Issue # (if applicable)

Tracking #31785 

### Reason for this change

Since the Kinesis Data Firehose Alpha module is in developer preview and contains the L2 construct for a Firehose Delivery Stream, we should make this upgrade from L1 to L2 now while the module is experimental instead of in the future, where we would need to add a V2 for this target (like for event targets, see #30189) to avoid breaking customers. 

### Description of changes

Replace CfnDeliveryStream with IDeliveryStream. The L1 uses `S3DestinationConfiguration` property whereas the L2 uses `ExtendedS3DestinationConfiguration` property  (includes additional fields on top of S3DestinationConfiguration fields). According to 
 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesisfirehose-deliverystream.html, "If you change the delivery stream destination from an Amazon S3 destination to an Amazon ES destination, update requires [some interruptions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-some-interrupt)."

### Description of how you validated changes

- Updated unit tests and integration test
- Deployed locally using CfnDeliveryStream then IDeliveryStream and verified the objects are written to the S3 bucket.

### 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*

BREAKING CHANGE: KinesisDataFirehosePutRecord scheduler target now accepts IDeliveryStream instead of CfnDeliveryStream.
  • Loading branch information
gracelu0 authored Nov 17, 2024
1 parent 50d11a3 commit 11384f0
Show file tree
Hide file tree
Showing 12 changed files with 10,934 additions and 15,278 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ The code snippet below creates an event rule with a delivery stream as a target
called every hour by EventBridge Scheduler with a custom payload.

```ts
import * as firehose from 'aws-cdk-lib/aws-kinesisfirehose';
declare const deliveryStream: firehose.CfnDeliveryStream;
import * as firehose from '@aws-cdk/aws-kinesisfirehose-alpha';
declare const deliveryStream: firehose.IDeliveryStream;

const payload = {
Data: "record",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { IDeliveryStream } from '@aws-cdk/aws-kinesisfirehose-alpha';
import { IScheduleTarget } from '@aws-cdk/aws-scheduler-alpha';
import { IRole, PolicyStatement } from 'aws-cdk-lib/aws-iam';
import { CfnDeliveryStream } from 'aws-cdk-lib/aws-kinesisfirehose';
import { ScheduleTargetBase, ScheduleTargetBaseProps } from './target';

/**
* Use an Amazon Kinesis Data Firehose as a target for AWS EventBridge Scheduler.
*/
export class KinesisDataFirehosePutRecord extends ScheduleTargetBase implements IScheduleTarget {
constructor(
private readonly deliveryStream: CfnDeliveryStream,
private readonly deliveryStream: IDeliveryStream,
props: ScheduleTargetBaseProps = {},
) {
super(props, deliveryStream.attrArn);
super(props, deliveryStream.deliveryStreamArn);
}

protected addTargetActionToRole(role: IRole): void {

role.addToPrincipalPolicy(new PolicyStatement({
actions: ['firehose:PutRecord'],
resources: [this.deliveryStream.attrArn],
resources: [this.deliveryStream.deliveryStreamArn],
}));
}
}
12 changes: 8 additions & 4 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,23 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/aws-kinesisfirehose-destinations-alpha": "0.0.0",
"@aws-cdk/aws-kinesisfirehose-alpha": "0.0.0",
"@aws-cdk/aws-scheduler-alpha": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests-alpha": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^29.5.14",
"aws-cdk-lib": "0.0.0",
"@aws-cdk/aws-scheduler-alpha": "0.0.0",
"constructs": "^10.0.0",
"@aws-cdk/integ-tests-alpha": "0.0.0"
"constructs": "^10.0.0"
},
"dependencies": {},
"peerDependencies": {
"aws-cdk-lib": "^0.0.0",
"@aws-cdk/aws-kinesisfirehose-destinations-alpha": "0.0.0",
"@aws-cdk/aws-kinesisfirehose-alpha": "0.0.0",
"@aws-cdk/aws-scheduler-alpha": "0.0.0",
"aws-cdk-lib": "^0.0.0",
"constructs": "^10.0.0"
},
"engines": {
Expand Down
Loading

0 comments on commit 11384f0

Please sign in to comment.