forked from tesladdicts/testatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firehose_formation.yaml
102 lines (96 loc) · 3.08 KB
/
firehose_formation.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: 'Create a kinesis firehouse s3 delivery stream'
Parameters:
S3BucketName:
Description: AWS S3 bucket name for storing events
Type: String
StreamName:
Description: Name of Kinesis firehose delivery stream for events
Type: String
Resources:
# Create the role to give firehose access to the necessary s3
# bucket and CloudWatchLogs area.
TeslaJSONFirehouseAccessRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: firehose.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId:
Ref: AWS::AccountId
Policies:
# name the policy firehose-StreamName-access-policy
- PolicyName: !Join ['', ['firehose-', !Ref StreamName, '-access-policy']]
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowAccessToS3Bucket
Effect: Allow
Action:
- s3:AbortMultipartUpload
- s3:GetBucketLocation
- s3:GetObject
- s3:ListBucket
- s3:ListBucketMultipartUploads
- s3:PutObject
Resource:
- !Join ['', ['arn:aws:s3:::', !Ref S3BucketName]]
- !Join ['', ['arn:aws:s3:::', !Ref S3BucketName, '/*']]
- Sid: AllowCloudWatchLogging
Effect: Allow
Action:
- logs:PutLogEvents
Resource:
- Fn::Join:
- ''
- - 'arn:aws:logs:'
- !Ref AWS::Region
- ":"
- !Ref AWS::AccountId
- ":log-group:/aws/kinesisfirehose/"
- !Ref StreamName
- ":log-stream:*"
# Policy can be assigned to any sender process/role to allow it
# to submit to the firehose
TeslaJSONFirehoseWriterPolicy:
Type: AWS::IAM::ManagedPolicy
Description: 'Allows Sending messages to firehose stream'
Properties:
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- firehose:PutRecord
Resource:
- Fn::GetAtt:
- TeslaJSONDeliveryStream
- Arn
TeslaJSONDeliveryStream:
Type: AWS::KinesisFirehose::DeliveryStream
Properties:
DeliveryStreamName:
Ref: StreamName
S3DestinationConfiguration:
BucketARN: !Join ['', ['arn:aws:s3:::', !Ref S3BucketName]]
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 1
Prefix: !Join ['',[!Ref StreamName, '/']]
CompressionFormat: "UNCOMPRESSED"
RoleARN:
Fn::GetAtt:
- "TeslaJSONFirehouseAccessRole"
- "Arn"
Outputs:
TeslaJSONFirehoseWriterPolicyArn:
Description: Managed Policy allowing sending messages to TeslaJSON firehose streams
Value: !Ref TeslaJSONFirehoseWriterPolicy
Export:
Name: TeslaJSONFirehoseWriterPolicyArn