-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
168 lines (156 loc) · 4.73 KB
/
serverless.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
org: osiris
app: osiris-api
service: osiris-api
configValidationMode: error
frameworkVersion: '3'
custom:
wsgi:
app: app.app
secrets:
aws: ${ssm:/aws/reference/secretsmanager/app-secrets}
provider:
name: aws
region: eu-west-1
runtime: python3.9
stage: ${env:STAGE, 'dev'}
iam:
role:
statements:
- Effect: Allow
Action:
- 'secretsmanager:GetSecretValue'
- 'secretsmanager:DescribeSecret'
Resource: arn:aws:secretsmanager:*:*:secret:app-secrets*
functions:
osiris-api:
role: ApiRole
handler: wsgi_handler.handler
timeout: 25
events:
- httpApi: '*'
environment:
MONGO_URI: ${self:custom.secrets.aws.MONGO_URI}
OPENAI_API_KEY: ${self:custom.secrets.aws.OPENAI_API_KEY}
GOOGLE_CLIENT_ID: 720095072153-bl54auh9v367357cdfj7nti1eu2lvr05.apps.googleusercontent.com
DOMAIN: ".project-osiris.net"
APP_URI: "https://app.project-osiris.net"
JWT_SECRET_KEY: ${self:custom.secrets.aws.JWT_SECRET_KEY}
transcripts-processor:
handler: app.microservices.process_transcript.handle_event
role: TranscriptProcessorRole
timeout: 90
events:
- sns:
topicName: transcripts-queue
arn:
Ref: TranscriptQueue
environment:
MONGO_URI: ${self:custom.secrets.aws.MONGO_URI}
OPENAI_API_KEY: ${self:custom.secrets.aws.OPENAI_API_KEY}
TRANSCRIPTS_BUCKET: 'osiris-transcripts-${self:provider.stage}'
resources:
Resources:
TranscriptsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: osiris-transcripts-${self:provider.stage}
TranscriptQueue:
Type: AWS::SNS::Topic
Properties:
DisplayName: Transcripts Queue
TopicName: transcripts-queue
# ContentBasedDeduplication: true
FifoTopic: false
ApiRole:
Type: AWS::IAM::Role
Properties:
RoleName: Api-Role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: LogWriter
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource:
- 'arn:aws:logs:*:*:*'
- PolicyName: Access-App-Secrets
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'secretsmanager:GetSecretValue'
- 'secretsmanager:DescribeSecret'
Resource: arn:aws:secretsmanager:*:*:secret:app-secrets*
TranscriptProcessorRole:
Type: AWS::IAM::Role
Properties:
RoleName: TranscriptProcessor-Role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: LogWriter
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource:
- 'arn:aws:logs:*:*:*'
- PolicyName: Access-App-Secrets
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'secretsmanager:GetSecretValue'
- 'secretsmanager:DescribeSecret'
Resource: arn:aws:secretsmanager:*:*:secret:app-secrets*
- PolicyName: Read-Transcripts
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetObject'
- 's3:GetBucketLocation'
- 's3:ListBucket'
Resource:
- 'arn:aws:s3:::osiris-transcripts-${self:provider.stage}'
- 'arn:aws:s3:::osiris-transcripts-${self:provider.stage}/*'
DependsOn:
- TranscriptsBucket
plugins:
- serverless-wsgi
- serverless-python-requirements
package:
include:
- app/**
exclude:
- .idea/**
- tests/**
- __pycache__/**
- .git/**
- .github/**
- venv/**