-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
106 lines (93 loc) · 3.03 KB
/
template.yaml
File metadata and controls
106 lines (93 loc) · 3.03 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
DatabaseHost:
Type: String
DatabasePort:
Type: String
DatabaseUser:
Type: String
DatabasePassword:
Type: String
DatabaseName:
Type: String
S3DocumentsBucket:
Type: String
Globals:
Function:
Timeout: 120
MemorySize: 128
Runtime: python3.10
Environment:
Variables:
DATABASE_USER: !Ref DatabaseUser
DATABASE_PASSWORD: !Ref DatabasePassword
DATABASE_DATABASE: !Ref DatabaseName
DATABASE_PORT: !Ref DatabasePort
DATABASE_HOST: !Ref DatabaseHost
S3_DOCUMENTS_BUCKET: !Ref S3DocumentsBucket
LOG_LEVEL: INFO
Tags:
LambdaPowertools: python
Resources:
# =============== LAMBDA FUNCTIONS ==============
StoreUserInputToS3Lambda:
Type: AWS::Serverless::Function
Properties:
Handler: handler.lambda_handler
CodeUri: src/lambdas/store_input_to_bucket/
Events:
DocumentToStoreEvent:
Type: SQS
Properties:
Queue: !GetAtt DocumentToStoreQueue.Arn
BatchSize: 10
APIEndpointsHandlerLambda:
Type: AWS::Serverless::Function
Properties:
Handler: handler.lambda_handler
CodeUri: src/lambdas/api_endpoints/
Events:
AnyApiEvent:
Type: Api
Properties:
RestApiId: !Ref APIGateway
Path: /{proxy+}
Method: ANY
# ====================== S3 =====================
S3DocumentsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref S3DocumentsBucket
# ================== SQS ==================
DocumentToStoreQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: "DocumentToStoreQueue"
VisibilityTimeout: 120
# ===================== API =====================
APIGateway:
Type: AWS::Serverless::Api
Properties:
Name: "api-gateway"
StageName: 'local'
Outputs:
ListAllCustomers:
Description: The endpoint to show all existing customers in the system.
Value: !Sub 'GET https://${APIGateway}.execute-api.localhost.localstack.cloud:4566/local/customer/'
GetCustomer:
Name:
Description: The endpoint to return a specific customer by id.
Value: !Sub 'GET https://${APIGateway}.execute-api.localhost.localstack.cloud:4566/local/customer/<id>/'
CreateCustomer:
Description: The endpoint to create a new customer in the system.
Value: !Sub 'POST https://${APIGateway}.execute-api.localhost.localstack.cloud:4566/local/customer/'
ListAllDocuments:
Description: The endpoint to show all stored documents' keys in the S3 bucket.
Value: !Sub 'GET https://${APIGateway}.execute-api.localhost.localstack.cloud:4566/local/document/'
GetDocument:
Description: The endpoint to store document's content by key.
Value: !Sub 'GET https://${APIGateway}.execute-api.localhost.localstack.cloud:4566/local/customer/<key>/'
StoreDocumentQueueURL:
Description: The SQS queue URL for storing documents.
Value: !Ref DocumentToStoreQueue