-
Notifications
You must be signed in to change notification settings - Fork 474
Expand file tree
/
Copy pathtemplate.yaml
More file actions
91 lines (83 loc) · 2.43 KB
/
template.yaml
File metadata and controls
91 lines (83 loc) · 2.43 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Environment:
Type: String
Default: dev
AllowedValues: [dev, staging, prod]
Description: Environment name
LogLevel:
Type: String
Default: INFO
AllowedValues: [DEBUG, INFO, WARNING, ERROR]
Description: Log level for Lambda functions
Mappings:
EnvironmentMap:
dev:
MemorySize: 256
Timeout: 30
staging:
MemorySize: 512
Timeout: 60
prod:
MemorySize: 1024
Timeout: 120
Globals:
Function:
Runtime: python3.13
MemorySize: !FindInMap [EnvironmentMap, !Ref Environment, MemorySize]
Timeout: !FindInMap [EnvironmentMap, !Ref Environment, Timeout]
Environment:
Variables:
ENVIRONMENT: !Ref Environment
POWERTOOLS_SERVICE_NAME: !Sub "${AWS::StackName}-${Environment}"
POWERTOOLS_METRICS_NAMESPACE: !Sub "MyApp/${Environment}"
POWERTOOLS_LOG_LEVEL: !Ref LogLevel
POWERTOOLS_DEV: !If [IsDev, "true", "false"]
Conditions:
IsDev: !Equals [!Ref Environment, "dev"]
IsProd: !Equals [!Ref Environment, "prod"]
Resources:
# Dependencies Layer for application dependencies
DependenciesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: !Sub "${AWS::StackName}-${Environment}-dependencies"
Description: !Sub "Application dependencies for ${Environment}"
ContentUri: layers/dependencies/
CompatibleRuntimes:
- python3.13
RetentionPolicy: Delete
ApiFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: app.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:
TABLE_NAME: !Ref DynamoTable
DynamoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${AWS::StackName}-${Environment}-data"
BillingMode: !If [IsProd, "PROVISIONED", "PAY_PER_REQUEST"]
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
ProvisionedThroughput: !If
- IsProd
- ReadCapacityUnits: 5
WriteCapacityUnits: 5
- !Ref AWS::NoValue