-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathfirehose.ts
49 lines (43 loc) · 1.46 KB
/
firehose.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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';
/**
* 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;
}
/**
* A EventBridge Pipes target that sends messages to a Firehose stream.
*/
export class FirehoseTarget implements ITarget {
private stream: IDeliveryStream;
private streamParameters?: FirehoseTargetParameters;
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 {
if (!this.streamParameters?.inputTransformation) {
return {
targetParameters: {},
};
}
return {
targetParameters: {
inputTemplate: this.streamParameters.inputTransformation?.bind(pipe).inputTemplate,
},
};
}
}