-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
130 lines (118 loc) · 3.5 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
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!
service: cordis-serverless # NOTE: update this with your service name
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: "1.4.0"
provider:
name: aws
environment:
REGION: eu-west-1
runtime: nodejs4.3
region: eu-west-1
iamRoleStatements: # permissions for all of your functions can be set here
- Effect: Allow
Action: # Gives permission to DynamoDB tables in a specific region
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
Resource: "arn:aws:dynamodb:eu-west-1:*:*"
functions:
# Retrieve projects
getProjects:
handler: handler.getProjects
events:
- http:
path: projects
method: get
cors: true
# Retrieve organizations
getOrganizations:
handler: handler.getOrganizations
events:
- http:
path: organizations
method: get
cors: true
# GraphQL endpoint
runGraphQL:
handler: handler.runGraphQL
events:
- http:
path: graphql
method: post
cors: true
# Populates our database of projects regularly
populateDb:
handler: handler.populateDb
timeout: 300
memorySize: 1024
events:
- schedule:
rate: rate(1 day)
enabled: false
# Populates our database of projects regularly
populateDbOrganizations:
handler: handler.populateDbOrganizations
timeout: 300
memorySize: 1024
events:
- schedule:
rate: rate(1 day)
enabled: false
# DynamoDB stream function to annotate results
annotateDb:
handler: handler.annotateDb
events:
# @todo parametrize
- stream: arn:aws:dynamodb:eu-west-1:365688147560:table/cordis_projects/stream/2016-12-28T21:33:51.804
resources:
Resources:
projectTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: cordis_projects
AttributeDefinitions:
- AttributeName: rcn
AttributeType: N
KeySchema:
- AttributeName: rcn
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
# Every item averages 2kb, and we'd like to write 5000 items per second, so we need a (very large) write capacity of 10000
# Note that we won't be writing that often so this is not really a big deal.
# However, that would be REALLY EXPENSIVE, so we need to finetune this.
WriteCapacityUnits: 1
organizationTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: cordis_organizations
AttributeDefinitions:
- AttributeName: projectRcn
AttributeType: N
- AttributeName: id
AttributeType: N
KeySchema:
- AttributeName: projectRcn
KeyType: HASH
- AttributeName: id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1