Skip to content

Commit d06339a

Browse files
committed
add firehose to write to s3
1 parent 377cbb2 commit d06339a

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

template.yaml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Resources:
5353
- kinesis:ListStreams
5454
Resource: !GetAtt KinesisStream.Arn
5555

56-
5756
LambdaFunction:
5857
Type: AWS::Lambda::Function
5958
Properties:
@@ -79,7 +78,60 @@ Resources:
7978
BatchSize: 100
8079
Enabled: true
8180

81+
FirehoseRole:
82+
Type: AWS::IAM::Role
83+
Properties:
84+
AssumeRolePolicyDocument:
85+
Version: '2012-10-17'
86+
Statement:
87+
- Effect: Allow
88+
Principal:
89+
Service: firehose.amazonaws.com
90+
Action: sts:AssumeRole
91+
Policies:
92+
- PolicyName: firehose-execution-policy
93+
PolicyDocument:
94+
Version: '2012-10-17'
95+
Statement:
96+
- Effect: Allow
97+
Action:
98+
- s3:AbortMultipartUpload
99+
- s3:GetBucketLocation
100+
- s3:GetObject
101+
- s3:ListBucket
102+
- s3:ListBucketMultipartUploads
103+
- s3:PutObject
104+
Resource:
105+
- !Sub arn:aws:s3:::${Region}-${Environment}-fraud-detection-data/processed/
106+
- !Sub arn:aws:s3:::${Region}-${Environment}-fraud-detection-data/*
107+
- Effect: Allow
108+
Action:
109+
- lambda:GetFunctionConfiguration
110+
- lambda:InvokeFunction
111+
Resource: !GetAtt LambdaFunction.Arn
112+
113+
KinesisFirehose:
114+
Type: AWS::KinesisFirehose::DeliveryStream
115+
Properties:
116+
DeliveryStreamName: !Sub "${AWS::AccountId}-firehose-stream"
117+
DeliveryStreamType: DirectPut
118+
ExtendedS3DestinationConfiguration:
119+
RoleARN: !GetAtt FirehoseRole.Arn
120+
BucketARN: !Sub arn:aws:s3:::${Region}-${Environment}-fraud-detection-data/processed/
121+
Prefix: processed-data/
122+
ErrorOutputPrefix: failed-data/
123+
ProcessingConfiguration:
124+
Enabled: true
125+
Processors:
126+
- Type: Lambda
127+
Parameters:
128+
- ParameterName: LambdaArn
129+
ParameterValue: !GetAtt LambdaFunction.Arn
130+
82131
Outputs:
83132
KinesisStreamName:
84133
Value: !Ref KinesisStream
85-
Description: Name of the Kinesis stream created
134+
Description: Name of the Kinesis stream created
135+
BucketARN:
136+
Value: !Sub arn:aws:s3:::${Region}-${Environment}-fraud-detection-data/processed/
137+
Description: ARN of the S3 bucket where processed data will be stored

0 commit comments

Comments
 (0)