-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
107 lines (101 loc) · 3.19 KB
/
Copy pathtemplate.yaml
File metadata and controls
107 lines (101 loc) · 3.19 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Environment:
Type: String
Default: dev
AtlasUri:
Type: String
PostgresHost:
Type: String
PostgresPassword:
Type: String
NoEcho: true
Globals:
Api:
Cors:
AllowOrigin: "'https://www.learn-ia.app'"
AllowMethods: "'POST, OPTIONS'"
AllowHeaders: "'Content-Type, Authorization'"
Resources:
LearningPathGeneratorFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub learnia-learning-path-generator-${Environment}
Runtime: python3.12
Handler: learning_path_generator.lambda_handler
CodeUri: src/
Timeout: 300
MemorySize: 2048
Layers:
- !Ref CertificatesLayer
Environment:
Variables:
ATLAS_URI: !Ref AtlasUri
DATABASE_NAME: learnia_db
COLLECTION_NAME: courses
ATLAS_SEARCH_INDEX: default
POSTGRES_HOST: !Ref PostgresHost
POSTGRES_PORT: 5432
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: !Ref PostgresPassword
DB_SSL: "true"
DB_CA_PATH: /opt/certs/rds-us-east-2-bundle.pem
EMBEDDING_MODEL: amazon.titan-embed-text-v2:0
EMBEDDING_DIM: 1024
NOVA_MODEL: us.amazon.nova-lite-v1:0
NOVA_TEMPERATURE: 0.7
MAX_COURSES_IN_PATH: 10
MIN_COURSES_IN_PATH: 3
DEFAULT_WEEKS_ESTIMATE: 12
Policies:
- AWSLambdaBasicExecutionRole
- Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
Resource:
- arn:aws:bedrock:us-east-2::foundation-model/amazon.titan-embed-text-v2:0
- arn:aws:bedrock:us-east-2:974724840334:inference-profile/us.amazon.nova-lite-v1:0
- arn:aws:bedrock:*::foundation-model/amazon.nova-lite-v1:0
- Effect: Allow
Action:
- cloudwatch:PutMetricData
Resource: '*'
Events:
GenerateLearningPath:
Type: Api
Properties:
Path: /generate-learning-path
Method: POST
RestApiId: !Ref LearningPathApi
OptionsGenerateLearningPath:
Type: Api
Properties:
Path: /generate-learning-path
Method: OPTIONS
RestApiId: !Ref LearningPathApi
LearningPathApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Cors:
AllowOrigin: "'https://www.learn-ia.app'"
AllowMethods: "'POST, OPTIONS'"
AllowHeaders: "'Content-Type, Authorization'"
CertificatesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: learnia-rds-ca-learning-path
Description: RDS CA bundle for SSL connections
ContentUri: layer-certs/
CompatibleRuntimes:
- python3.12
Outputs:
LearningPathGeneratorApi:
Description: API Gateway endpoint URL
Value: !Sub "https://${LearningPathApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
LearningPathGeneratorFunction:
Description: Lambda Function ARN
Value: !GetAtt LearningPathGeneratorFunction.Arn