-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
135 lines (121 loc) · 3.38 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
service: restaurant
provider:
name: aws
runtime: nodejs10.x
stage: dev
region: ap-northeast-2
environment:
RESTAURANT_TABLE: ${self:service}-${opt:stage, self:provider.stage}
USER_TABLE: 'user-${opt:stage, self:provider.stage}'
BUCKET_NAME: 'lunchsquad-${self:service}-img'
COGNITO_POOL_ID: 'ap-northeast-2_xHKF0PEUB'
COGNITO_REGION: 'ap-northeast-2'
GOOGLE_CLIENT_ID: '726729206181-s4juih3ct7umd1hc028rarv2at97vdtl.apps.googleusercontent.com'
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- s3:PutObject
Resource: '*'
resources:
Resources:
RestaurantsDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: 'id'
AttributeType: 'S'
KeySchema:
- AttributeName: 'id'
KeyType: 'HASH'
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: 'NEW_AND_OLD_IMAGES'
TableName: ${self:provider.environment.RESTAURANT_TABLE}
UserDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: 'userId'
AttributeType: 'S'
KeySchema:
- AttributeName: 'userId'
KeyType: 'HASH'
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: 'NEW_AND_OLD_IMAGES'
TableName: ${self:provider.environment.USER_TABLE}
StorageBucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: ${self:provider.environment.BUCKET_NAME}
CognitoUserPoolLunchSquad:
Type: 'AWS::Cognito::UserPool'
functions:
addRestaurants:
handler: api/restaurants.add
memorySize: 128
description: Add restaurants information.
events:
- http:
path: restaurants
method: post
listRestaurants:
handler: api/restaurants.list
memorySize: 128
description: List all restaurants
events:
- http:
path: restaurants
method: get
restaurantDetails:
handler: api/restaurants.get
events:
- http:
path: restaurant/{id}
method: get
randomRecommendation:
handler: api/restaurants.getRandom
events:
- http:
path: restaurant/random
method: get
UploadImage:
handler: api/restaurants.uploadImage
events:
- http:
path: restaurant/upload_img
method: post
cors: true
RegisterUserToDynamoDB:
handler: api/users.registerUserToDynamoDB
description: Register user in DynamoDB after recieve cognito post confirmation event
events:
- cognitoUserPool:
pool: LunchSquad
trigger: PostConfirmation
VerifyJWT:
handler: api/users.verifyJwt
description: Decode and verity jwt sent from client
events:
- http:
path: user/jwt
method: post
VerifyGoogleLoginToken:
handler: api/users.verifyGoogleLogin
description: Verity token sent from google oauth login
events:
- http:
path: user/google_login
method: post
plugins:
- serverless-offline