Skip to content

Commit

Permalink
fix(events_targets): kinesisfirehosestream not accepting ideliverystr…
Browse files Browse the repository at this point in the history
…eam for imported deliverystream (#30189)

### Issue # (if applicable)

Closes #25451

### Reason for this change

Current events targets implementation only support L1 Delivery Stream as the input. We should support L2 IDeliveryStream as well for imported kinesis firehose stream.

### Description of changes

Add a V2 class to support kinesis firehose stream.

### Description of how you validated changes

New tests and existing tests pass.

### 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
GavinZZ authored May 16, 2024
1 parent c7c75f8 commit d7e6a10
Show file tree
Hide file tree
Showing 12 changed files with 1,150 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-kinesisfirehose-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"devDependencies": {
"@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.12",
"aws-cdk-lib": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as kinesis from 'aws-cdk-lib/aws-kinesis';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as events from 'aws-cdk-lib/aws-events';
import * as targets from 'aws-cdk-lib/aws-events-targets';
import * as cdk from 'aws-cdk-lib';
import { Construct, Node } from 'constructs';
import * as firehose from '../lib';
Expand Down Expand Up @@ -58,6 +60,41 @@ describe('delivery stream', () => {
});
});

test('creates stream with events target V2 class', () => {
const stream = new firehose.DeliveryStream(stack, 'DeliveryStream', {
destinations: [mockS3Destination],
});

new events.Rule(stack, 'rule', {
eventPattern: {
source: ['aws.s3'],
detail: {
eventName: ['PutObject'],
},
},
}).addTarget(new targets.KinesisFirehoseStreamV2(firehose.DeliveryStream.fromDeliveryStreamArn(stack, 'firehose', stream.deliveryStreamArn)));

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Targets: [
{
Arn: {
'Fn::GetAtt': [
'DeliveryStream58CF96DB',
'Arn',
],
},
Id: 'Target0',
RoleArn: {
'Fn::GetAtt': [
'firehoseEventsRole71BC7157',
'Arn',
],
},
},
],
});
});

test('provided role is set as grant principal', () => {
const role = new iam.Role(stack, 'Role', {
assumedBy: new iam.ServicePrincipal('firehose.amazonaws.com'),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d7e6a10

Please sign in to comment.