-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
174 lines (156 loc) · 4.42 KB
/
serverless.yml
File metadata and controls
174 lines (156 loc) · 4.42 KB
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
163
164
165
166
167
168
169
170
171
service: e-commerce
custom:
settings:
ECOMMERCE_TABLE: Orders
provider:
name: aws
runtime: nodejs12.x
region: ap-northeast-1
environment: ${self:custom.settings}
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:DescribeTable
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:Scan
- dynamodb:DeleteItem
- dynamodb:UpdateItem
- dynamodb:ConditionCheckItem
Resource:
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:custom.settings.ECOMMERCE_TABLE}"
- Effect: Allow
Action:
- dynamodb:Query
Resource:
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:custom.settings.ECOMMERCE_TABLE}/index/*"
functions:
createOrder:
handler: handler.createOrder
events:
- http:
path: /orders
method: post
getOrders:
handler: handler.getOrders
events:
- http:
path: /orders/get-all
method: get
getOrderByOrderNo:
handler: handler.getOrderByOrderNo
events:
- http:
path: /orders/ordernumber/{orderno}
method: get
filterOrdersByUserName:
handler : handler.getOrdersByUserName
events:
- http:
path: /orders/username/{username}
method: get
filterOrdersByCreatAtDate:
handler : handler.filterOrdersByCreatAtDate
events :
- http:
path: /orders/createdate/{createddate}
method: get
updateItem:
handler : handler.updateItem
events :
- http:
path: /orders/update/{orderno}
method: put
deleteItem:
handler : handler.deleteItem
events :
- http :
path : /orders/delete/{username}
method : delete
selectOrdersWithinAMonthByGivenDate:
handler : handler.selectOrdersWithinAMonthByGivenDate
events:
- http:
path : /orders/search
method: post
resources:
Resources:
OrdersTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName : "UserName"
AttributeType : "S"
- AttributeName : "OrderNo"
AttributeType : "S"
- AttributeName : "CreateAt"
AttributeType : "S"
KeySchema:
- AttributeName : "UserName"
KeyType : "HASH"
- AttributeName : "OrderNo"
KeyType : "RANGE"
ProvisionedThroughput:
WriteCapacityUnits : 1
ReadCapacityUnits : 1
TableName: ${self:custom.settings.ECOMMERCE_TABLE}
GlobalSecondaryIndexes:
- IndexName : "OrderNo_Index"
KeySchema:
- AttributeName: "OrderNo"
KeyType: "HASH"
Projection:
NonKeyAttributes:
- "UserName"
- "OrderNo"
- "Email"
- "CreateAt"
- "Address"
ProjectionType: "INCLUDE"
ProvisionedThroughput:
WriteCapacityUnits : 5
ReadCapacityUnits: 5
- IndexName: "UserName_Index"
KeySchema:
- AttributeName: "UserName"
KeyType: "HASH"
Projection:
NonKeyAttributes:
- "UserName"
- "OrderNo"
- "Email"
- "CreateAt"
- "Address"
ProjectionType: "INCLUDE"
ProvisionedThroughput:
WriteCapacityUnits : 5
ReadCapacityUnits: 5
- IndexName: "CreateAt_Index"
KeySchema:
- AttributeName: "CreateAt"
KeyType: "HASH"
Projection:
NonKeyAttributes:
- "UserName"
- "OrderNo"
- "Email"
- "CreateAt"
- "Address"
ProjectionType: "INCLUDE"
ProvisionedThroughput:
WriteCapacityUnits: 5
ReadCapacityUnits: 5
LocalSecondaryIndexes:
- IndexName: "CreateAtLocal_Index"
KeySchema:
- AttributeName : "UserName"
KeyType : "HASH"
- AttributeName : "CreateAt"
KeyType : "RANGE"
Projection:
NonKeyAttributes:
- "OrderNo"
- "UserName"
- "Address"
- "Email"
ProjectionType: "INCLUDE"