generated from Hebilicious/serverless-esbuild-template
-
Notifications
You must be signed in to change notification settings - Fork 71
/
serverless.yml
128 lines (124 loc) · 3.17 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
service: dynamodb-instagram
plugins:
- serverless-esbuild
- serverless-offline
provider:
name: aws
runtime: nodejs12.x
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:BatchGetItem"
- "dynamodb:ConditionCheckItem"
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:Query"
- "dynamodb:UpdateItem"
Resource:
- Fn::GetAtt:
- InstagramTable
- Arn
- Fn::Join:
- "/"
- - Fn::GetAtt:
- InstagramTable
- Arn
- "index/GSI1"
environment:
TABLE_NAME: { Ref: InstagramTable }
functions:
createUser:
handler: src/handlers/createUser.main
events:
- http:
path: /users
method: post
getUser:
handler: src/handlers/getUser.main
events:
- http:
path: /users/{username}
method: get
createPhoto:
handler: src/handlers/createPhoto.main
events:
- http:
path: /users/{username}/photos
method: post
getPhoto:
handler: src/handlers/getPhoto.main
events:
- http:
path: /users/{username}/photos/{photoId}
method: get
likePhoto:
handler: src/handlers/likePhoto.main
events:
- http:
path: /users/{username}/photos/{photoId}/likes
method: post
listLikesForPhoto:
handler: src/handlers/listLikesForPhoto.main
events:
- http:
path: /users/{username}/photos/{photoId}/likes
method: get
commentOnPhoto:
handler: src/handlers/commentOnPhoto.main
events:
- http:
path: /users/{username}/photos/{photoId}/comments
method: post
listCommentsForPhoto:
handler: src/handlers/listCommentsForPhoto.main
events:
- http:
path: /users/{username}/photos/{photoId}/comments
method: get
followUser:
handler: src/handlers/followUser.main
events:
- http:
path: /users/{username}/followers
method: post
listFollowersOfUser:
handler: src/handlers/listFollowersOfUser.main
events:
- http:
path: /users/{username}/followers
method: get
listFollowedByUser:
handler: src/handlers/listFollowedByUser.main
events:
- http:
path: /users/{username}/following
method: get
resources:
Resources:
InstagramTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: "PK"
AttributeType: "S"
- AttributeName: "SK"
AttributeType: "S"
- AttributeName: "GSI1PK"
AttributeType: "S"
- AttributeName: "GSI1SK"
AttributeType: "S"
KeySchema:
- AttributeName: "PK"
KeyType: "HASH"
- AttributeName: "SK"
KeyType: "RANGE"
BillingMode: "PAY_PER_REQUEST"
GlobalSecondaryIndexes:
- IndexName: 'GSI1'
KeySchema:
- AttributeName: "GSI1PK"
KeyType: "HASH"
- AttributeName: "GSI1SK"
KeyType: "RANGE"
Projection:
ProjectionType: ALL