-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(pipes-targets-alpha): support Amazon Data Firehose target #33860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8975483
firehose target
Tietew d53a290
README
Tietew bcc5e8c
typo
Tietew 55b8a84
Merge branch 'main' into pipes-firehose-target
Tietew fba3a98
sort
Tietew d59cf93
Merge branch 'main' into pipes-firehose-target
Tietew 4c7f232
Merge branch 'main' into pipes-firehose-target
Tietew 4cf50eb
stream -> deliveryStream
Tietew 1b866a7
null commit
Tietew 0292f79
update snapshot (new region)
Tietew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { IInputTransformation, IPipe, ITarget, TargetConfig } from '@aws-cdk/aws-pipes-alpha'; | ||
| import { IRole } from 'aws-cdk-lib/aws-iam'; | ||
| import { IDeliveryStream } from 'aws-cdk-lib/aws-kinesisfirehose'; | ||
|
|
||
| /** | ||
| * Amazon Data Firehose target properties. | ||
| */ | ||
| export interface FirehoseTargetParameters { | ||
| /** | ||
| * The input transformation to apply to the message before sending it to the target. | ||
| * | ||
| * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetparameters.html#cfn-pipes-pipe-pipetargetparameters-inputtemplate | ||
| * @default - none | ||
| */ | ||
| readonly inputTransformation?: IInputTransformation; | ||
| } | ||
|
|
||
| /** | ||
| * An EventBridge Pipes target that sends messages to an Amazon Data Firehose delivery stream. | ||
| */ | ||
| export class FirehoseTarget implements ITarget { | ||
| private stream: IDeliveryStream; | ||
| private streamParameters: FirehoseTargetParameters; | ||
Tietew marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public readonly targetArn: string; | ||
|
|
||
| constructor(stream: IDeliveryStream, parameters: FirehoseTargetParameters = {}) { | ||
| this.stream = stream; | ||
| this.targetArn = stream.deliveryStreamArn; | ||
| this.streamParameters = parameters; | ||
| } | ||
|
|
||
| grantPush(grantee: IRole): void { | ||
| this.stream.grantPutRecords(grantee); | ||
| } | ||
|
|
||
| bind(pipe: IPipe): TargetConfig { | ||
| return { | ||
| targetParameters: { | ||
| inputTemplate: this.streamParameters.inputTransformation?.bind(pipe).inputTemplate, | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
packages/@aws-cdk/aws-pipes-targets-alpha/test/firehose.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { InputTransformation, Pipe } from '@aws-cdk/aws-pipes-alpha'; | ||
| import { App, Stack } from 'aws-cdk-lib'; | ||
| import { Template } from 'aws-cdk-lib/assertions'; | ||
| import { DeliveryStream, S3Bucket } from 'aws-cdk-lib/aws-kinesisfirehose'; | ||
| import { Bucket } from 'aws-cdk-lib/aws-s3'; | ||
| import { TestSource } from './test-classes'; | ||
| import { FirehoseTarget } from '../lib/firehose'; | ||
|
|
||
| describe('Firehose', () => { | ||
| it('should have target arn', () => { | ||
| // ARRANGE | ||
| const app = new App(); | ||
| const stack = new Stack(app, 'TestStack'); | ||
| const bucket = new Bucket(stack, 'Bucket'); | ||
| const stream = new DeliveryStream(stack, 'MyStream', { | ||
| destination: new S3Bucket(bucket), | ||
| }); | ||
|
|
||
| const target = new FirehoseTarget(stream); | ||
|
|
||
| new Pipe(stack, 'MyPipe', { | ||
| source: new TestSource(), | ||
| target, | ||
| }); | ||
|
|
||
| // ACT | ||
| const template = Template.fromStack(stack); | ||
|
|
||
| // ASSERT | ||
| template.hasResourceProperties('AWS::Pipes::Pipe', { | ||
| Target: { | ||
| 'Fn::GetAtt': [ | ||
| 'MyStream5C050E93', | ||
| 'Arn', | ||
| ], | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should have input transformation', () => { | ||
| // ARRANGE | ||
| const app = new App(); | ||
| const stack = new Stack(app, 'TestStack'); | ||
| const bucket = new Bucket(stack, 'Bucket'); | ||
| const stream = new DeliveryStream(stack, 'MyStream', { | ||
| destination: new S3Bucket(bucket), | ||
| }); | ||
|
|
||
| const inputTransformation = InputTransformation.fromObject({ | ||
| key: 'value', | ||
| }); | ||
| const target = new FirehoseTarget(stream, { | ||
| inputTransformation, | ||
| }); | ||
|
|
||
| new Pipe(stack, 'MyPipe', { | ||
| source: new TestSource(), | ||
| target, | ||
| }); | ||
|
|
||
| // ACT | ||
| const template = Template.fromStack(stack); | ||
|
|
||
| // ASSERT | ||
| template.hasResourceProperties('AWS::Pipes::Pipe', { | ||
| TargetParameters: { | ||
| InputTemplate: '{"key":"value"}', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should grant pipe role putRecord access', () => { | ||
| // ARRANGE | ||
| const app = new App(); | ||
| const stack = new Stack(app, 'TestStack'); | ||
| const bucket = new Bucket(stack, 'Bucket'); | ||
| const stream = new DeliveryStream(stack, 'MyStream', { | ||
| destination: new S3Bucket(bucket), | ||
| }); | ||
|
|
||
| const target = new FirehoseTarget(stream); | ||
|
|
||
| new Pipe(stack, 'MyPipe', { | ||
| source: new TestSource(), | ||
| target, | ||
| }); | ||
|
|
||
| // ACT | ||
| const template = Template.fromStack(stack); | ||
|
|
||
| // ASSERT | ||
| template.hasResourceProperties('AWS::IAM::Policy', { | ||
| PolicyDocument: { | ||
| Statement: [ | ||
| { | ||
| Action: ['firehose:PutRecord', 'firehose:PutRecordBatch'], | ||
| Resource: { 'Fn::GetAtt': ['MyStream5C050E93', 'Arn'] }, | ||
| }, | ||
| ], | ||
| }, | ||
| Roles: [{ Ref: 'MyPipeRoleCBC8E9AB' }], | ||
| }); | ||
| }); | ||
| }); |
1 change: 1 addition & 0 deletions
1
....snapshot/asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.