-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
185 lines (181 loc) · 5.09 KB
/
template.yaml
File metadata and controls
185 lines (181 loc) · 5.09 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: "Infrastructure for Fridge Log app."
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
# You can add LoggingConfig parameters such as the Logformat, Log Group, and SystemLogLevel or ApplicationLogLevel. Learn more here https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-loggingconfig.
LoggingConfig:
LogFormat: JSON
Resources:
#APIs
GetItemsApi:
Type: AWS::Serverless::Api
Properties:
Name: "GetItemsApi"
StageName: prod
Cors:
AllowMethods: "'GET, OPTIONS'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
PutItemApi:
Type: AWS::Serverless::Api
Properties:
Name: "PutItemApi"
StageName: prod
Cors:
AllowMethods: "'OPTIONS, POST'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
DeleteItemApi:
Type: AWS::Serverless::Api
Properties:
Name: "DeleteItemAPi"
StageName: prod
Cors:
AllowMethods: "'OPTIONS, POST'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
CapturePhotoApi:
Type: AWS::Serverless::Api
Properties:
Name: "CapturePhotoApi"
StageName: prod
Cors:
AllowMethods: "'OPTIONS, POST'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
CheckEmailExistenceApi:
Type: AWS::Serverless::Api
Properties:
Name: "CheckEmailExistenceApi"
StageName: prod
Cors:
AllowMethods: "'OPTIONS, GET'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
#Lambda functions
ReadDDB:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
FunctionName: "ReadDDB"
CodeUri: read-ddb/
Handler: read_from_ddb.handler
Runtime: nodejs20.x
Architectures:
- x86_64
Events:
ReadFromDDB:
Type: Api
Properties:
Path: /ReadFromDDB/items
Method: get
RestApiId: !Ref GetItemsApi
WriteDDB:
Type: AWS::Serverless::Function
Properties:
FunctionName: "WriteDDB"
CodeUri: write-ddb/
Handler: write_to_ddb.handler
Runtime: nodejs20.x
Architectures:
- x86_64
Events:
WriteToTableItem:
Type: Api
Properties:
Path: /WriteToDDB/putItem
Method: post
RestApiId: !Ref PutItemApi
ScanSendNotif:
Type: AWS::Serverless::Function
Properties:
Timeout: 10
CodeUri: scan-send-notif/
FunctionName: "ScanSendNotif"
Handler: scan_send_notif.handler
Runtime: nodejs20.x
Architectures:
- x86_64
DeleteItemDDB:
Type: AWS::Serverless::Function
Properties:
FunctionName: "DeleteItemDDB"
CodeUri: delete-item-ddb/
Handler: delete_item.handler
Runtime: nodejs20.x
Architectures:
- x86_64
Events:
DeleteItemDDB:
Type: Api
Properties:
Path: /DeleteItem/item/{email}
Method: post
RestApiId: !Ref DeleteItemApi
CapturePhoto:
Type: AWS::Serverless::Function
Properties:
CodeUri: capture-photo/
FunctionName: "CapturePhoto"
Handler: capture_photo.handler
Runtime: nodejs20.x
Timeout: 6
Architectures:
- x86_64
Events:
CapturePhoto:
Type: Api
Properties:
Path: /capturePhoto/item
Method: post
RestApiId: !Ref CapturePhotoApi
CheckEmailExistence:
Type: AWS::Serverless::Function
Properties:
FunctionName: "CheckEmailExistence"
CodeUri: check-email-existence/
Handler: check_email_existence.handler
Runtime: nodejs20.x
Timeout: 4
Architectures:
- x86_64
Events:
CheckEmailExist:
Type: Api
Properties:
Path: /checkEmailExistence/email
Method: get
RestApiId: !Ref CheckEmailExistenceApi
#DDB Tables
ItemsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: user_email
AttributeType: S
- AttributeName: timestamp
AttributeType: N
KeySchema:
- AttributeName: user_email
KeyType: HASH # primary key
- AttributeName: timestamp
KeyType: RANGE # sort key
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: FridgeLogItem
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
- AttributeName: user_email
KeyType: HASH
AttributeDefinitions:
- AttributeName: user_email
AttributeType: S
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: FridgeLogUser