-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
162 lines (146 loc) · 4.01 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
service: observatory-api
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:GetObject"
Resource:
- "arn:aws:s3:::o9y.soil.observations/*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource:
- "arn:aws:s3:::o9y.soil.observations"
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
Resource:
- "Fn::GetAtt": [ ReactionsTable, Arn ]
- "Fn::GetAtt": [ EventsTable, Arn ]
- "Fn::GetAtt": [ EventsDailyRollupTable, Arn ]
plugins:
- serverless-domain-manager
custom:
customDomain:
domainName: api.o9y.soma.farm
basePath: ''
stage: ${self:provider.stage}
certificateName: 'api.o9y.soma.farm'
createRoute53Record: false
functions:
measureObservationFoliage:
handler: src/observation/observation-handler.measureFoliage
events:
- s3:
bucket: o9y.soil.observations
event: s3:ObjectCreated:*
getObservationFoliage:
handler: src/observation/observation-handler.getFoliageTimeSeries
events:
- http:
path: observation/foliage
method: get
cors: true
observationGetUploadUrl:
handler: src/observation/observation-handler.getUploadURL
events:
- http:
path: observation
method: get
request:
template:
application/json: >
{
"fileType" : "$input.params('fileType')"
}
cors: true
observationGetLatest:
handler: src/observation/observation-handler.getLatest
events:
- http:
path: observation/latest
method: get
cors: true
rollupFoliage:
handler: src/observation/observation-handler.rollupFoliageTimeSeries
events:
- stream:
type: dynamodb
arn:
Fn::GetAtt: [ EventsTable, StreamArn ]
batchSize: 1
recordReaction:
handler: src/reaction/reaction-handler.recordReaction
events:
- http:
path: reaction
method: post
cors: true
resources:
Resources:
EventsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: events
AttributeDefinitions:
- AttributeName: event_type
AttributeType: S
- AttributeName: date_time
AttributeType: N
KeySchema:
- AttributeName: event_type
KeyType: HASH
- AttributeName: date_time
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
EventsDailyRollupTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: events_daily_rollup
AttributeDefinitions:
- AttributeName: event_type
AttributeType: S
- AttributeName: date_time
AttributeType: N
KeySchema:
- AttributeName: event_type
KeyType: HASH
- AttributeName: date_time
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
ReactionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: reactions
AttributeDefinitions:
- AttributeName: reaction_type
AttributeType: S
- AttributeName: datetime
AttributeType: N
KeySchema:
- AttributeName: reaction_type
KeyType: HASH
- AttributeName: datetime
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5