-
Notifications
You must be signed in to change notification settings - Fork 474
Expand file tree
/
Copy pathtemplate.yaml
More file actions
81 lines (74 loc) · 2.22 KB
/
template.yaml
File metadata and controls
81 lines (74 loc) · 2.22 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Runtime: python3.13
Timeout: 30
MemorySize: 512
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: !Ref AWS::StackName
POWERTOOLS_METRICS_NAMESPACE: MyApp
POWERTOOLS_LOG_LEVEL: INFO
Resources:
# Dependencies Layer (pydantic, requests, etc.)
DependenciesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: !Sub "${AWS::StackName}-dependencies"
Description: Application dependencies
ContentUri: layers/dependencies/
CompatibleRuntimes:
- python3.13
RetentionPolicy: Delete
# API Lambda Function (lightweight - only app code)
ApiFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/app/
Handler: app_sam_layer.lambda_handler
Layers:
- arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV3-python313-x86_64:31
- !Ref DependenciesLayer
Events:
ApiEvent:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: api-service
# Background Worker Function
WorkerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/worker/
Handler: worker_sam_layer.lambda_handler
Layers:
- arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV3-python313-x86_64:31
- !Ref DependenciesLayer
Events:
SQSEvent:
Type: SQS
Properties:
Queue: !GetAtt WorkerQueue.Arn
BatchSize: 10
FunctionResponseTypes:
- ReportBatchItemFailures
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: worker-service
# SQS Queue for worker
WorkerQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub "${AWS::StackName}-worker-queue"
VisibilityTimeout: 180
Outputs:
ApiUrl:
Description: API Gateway endpoint URL
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
WorkerQueueUrl:
Description: SQS Queue URL for worker
Value: !Ref WorkerQueue