-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserverless.yml
108 lines (100 loc) · 2.76 KB
/
serverless.yml
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
service: my-google-analytics
provider:
name: aws
runtime: nodejs6.10
stage: prod
region: ap-northeast-2
environment: ${file(./env/${opt:stage}.yml)}
# you can add statements to the Lambda function's IAM Role here
iamRoleStatements:
- Effect: "Allow"
Action:
- "firehose:PutRecord"
Resource: "*"
functions:
index:
handler: src/handler.index
events:
- http:
path: /
method: GET
memorySize: 256
timeout: 10
collect:
handler: src/handler.collect
events:
- http:
path: /events
method: POST
memorySize: 256
timeout: 30
resources:
Resources:
DataBucket:
Type: AWS::S3::Bucket
Properties:
BucketName:
Ref: DataBucketName
DataTrackerFirehose:
Type: "AWS::KinesisFirehose::DeliveryStream"
Properties:
DeliveryStreamName: DataTracker-${opt:stage}
DeliveryStreamType: DirectPut
ExtendedS3DestinationConfiguration:
BucketARN:
Fn::GetAtt:
- DataBucket
- Arn
BufferingHints:
SizeInMBs: 1
IntervalInSeconds: 60
CompressionFormat: GZIP
Prefix: "${opt:identifier}-google-analytics/"
CloudWatchLoggingOptions:
Enabled: true
LogGroupName: /aws/kinesisfirehose/DataTracker-${opt:stage}
LogStreamName: S3Delivery
RoleARN:
Fn::GetAtt:
- DataTrackerRole
- Arn
DataTrackerRole:
Type: AWS::IAM::Role
Properties:
RoleName: DataTrackerRole-${opt:stage}
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- firehose.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: S3-Access-Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "s3:GetBucketLocation"
- "s3:GetObject"
- "s3:ListBucket"
- "s3:ListBucketMultipartUploads"
- "s3:PutObject"
Resource:
- Fn::Join:
- "/"
- - Fn::GetAtt:
- DataBucket
- Arn
- "${opt:identifier}-google-analytics/*"
Parameters:
DataBucketName:
Type: String
Default: "${opt:identifier}-google-analytics"
Outputs:
S3BucketName:
Value: ${opt:identifier}-google-analytics
FirehosePrefix:
Value: ${opt:identifier}-google-analytics/