-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserverless.yml
149 lines (140 loc) · 3.41 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
service: example-api
plugins:
- serverless-webpack
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules:
forceExclude:
- aws-sdk
provider:
name: aws
runtime: nodejs8.10
memorySize: 128
versionFunctions: false
environment:
USERS_TABLE: users
POSTS_TABLE: posts
NEO4J_URI:
Fn::Join:
- ""
- - "bolt://"
- Fn::GetAtt: [ GraphDatabaseInstance, PublicIp ]
- ":7687"
NEO4J_USERNAME: neo4j
NEO4J_PASSWORD:
Ref: GraphDatabaseInstance
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:*
Resource:
- "*"
functions:
addUser:
handler: src/handlers/addUser.default
events:
- http:
path: /users
method: post
getUsers:
handler: src/handlers/getUsers.default
events:
- http:
path: /users
method: get
addPost:
handler: src/handlers/addPost.default
events:
- http:
path: /posts
method: post
getPosts:
handler: src/handlers/getPosts.default
events:
- http:
path: /posts
method: get
load:
handler: src/handlers/load.default
events:
- stream:
type: dynamodb
arn:
Fn::GetAtt: [ UsersTable, StreamArn ]
- stream:
type: dynamodb
arn:
Fn::GetAtt: [ PostsTable, StreamArn ]
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.USERS_TABLE}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: NEW_IMAGE
PostsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.POSTS_TABLE}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: NEW_IMAGE
GraphDatabaseSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Database server
GroupName: GraphDatabase
SecurityGroupIngress:
-
IpProtocol: tcp
FromPort: 7473
ToPort: 7473
CidrIp: 0.0.0.0/0
-
IpProtocol: tcp
FromPort: 7474
ToPort: 7474
CidrIp: 0.0.0.0/0
-
IpProtocol: tcp
FromPort: 7687
ToPort: 7687
CidrIp: 0.0.0.0/0
GraphDatabaseInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-0aeebc5d17c06beff
SecurityGroupIds:
- Ref: GraphDatabaseSecurityGroup
Outputs:
GraphDatabaseUrl:
Value:
Fn::Join:
- ""
- - "https://"
- Fn::GetAtt: [ GraphDatabaseInstance, PublicIp ]
- ":7473/"
GraphDatabaseUsername:
Value: ${self:provider.environment.NEO4J_USERNAME}
GraphDatabasePassword:
Value: ${self:provider.environment.NEO4J_PASSWORD}