-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathfirehose.test.ts
118 lines (101 loc) · 3.09 KB
/
firehose.test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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';
describe('firehose', () => {
it('should have only 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',
],
},
TargetParameters: {},
});
});
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 handle an empty parameter object', () => {
// 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', {
TargetParameters: {},
});
});
it('should grant pipe role put 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
expect(template.findResources('AWS::IAM::Role')).toMatchSnapshot();
expect(template.findResources('AWS::IAM::Policy')).toMatchSnapshot();
});
});