-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yaml
104 lines (100 loc) · 2.65 KB
/
template.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: core infrastructure definitions
Parameters:
DataBucket:
Type: String
Description: S3 bucket to store data
OpenAIAPIKey:
Type: String
Description: OpenAI API key
JWTSigningKey:
Type: String
Description: JWT signing key
Resources:
infoFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: cmd/lambda/info/
Description: function responsible for responding to user questions
Environment:
Variables:
DATA_BUCKET_NAME:
Ref: DataBucket
QUESTIONS_TABLE_NAME:
Ref: questionsTable
SUMMARIES_TABLE_NAME:
Ref: summariesTable
OPENAI_API_KEY:
Ref: OpenAIAPIKey
JWT_SIGNING_KEY:
Ref: JWTSigningKey
Events:
QuestionEvent:
Type: Api
Properties:
Method: POST
Path: /question
SummariesEvent:
Type: Api
Properties:
Method: GET
Path: /summaries
Handler: info
MemorySize: 512
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource:
Fn::Sub: arn:aws:s3:::${DataBucket}/*
- Effect: Allow
Action:
- dynamodb:BatchWriteItem
- dynamodb:Scan
Resource:
Fn::GetAtt:
- summariesTable
- Arn
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource:
Fn::GetAtt:
- questionsTable
- Arn
Runtime: go1.x
Timeout: 15
questionsTable:
Type: AWS::Serverless::SimpleTable
summariesTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: String
Outputs:
QuestionsTableName:
Value:
Ref: questionsTable
SummariesTableName:
Value:
Ref: summariesTable
DataBucketName:
Value:
Ref: DataBucket
OpenAIAPIKey:
Value:
Ref: OpenAIAPIKey
QuestionAPIEndpoint:
Description: Endpoint for processing user questions
Value:
Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/question
SummariesAPIEndpoint:
Description: Endpoint for serving essay summaries
Value:
Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/summaries