-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
110 lines (102 loc) · 2.55 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
service: aiamond-gptbackend
provider:
name: aws
stage: dev
runtime: python3.11
region: eu-central-1
profile: default
environment:
OPENAI_API_KEY: ${env:OPENAI_API_KEY}
GPT3_MODEL: ${env:GPT3_MODEL}
GPT4_MODEL: ${env:GPT4_MODEL}
memorySize: 256 # minimum memory size for Lambda
timeout: 90 # timeout for Lambda
logRetentionInDays: 7 # keep logs for 7 days
apiGateway:
shouldStartNameWithService: true
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:*
Resource: "*"
plugins:
- serverless-wsgi
- serverless-python-requirements
- serverless-dotenv-plugin
- serverless-offline
custom:
stage: ${opt:stage, self:provider.stage}
wsgi:
app: app.app
packRequirements: false
pythonRequirements:
dockerizePip: non-linux
layer: true
noDeploy:
- boto3
dotenv:
path: .env
package:
include:
- app.py
exclude:
- node_modules/**
- venv/**
resources:
Resources:
ConversationsTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: 'Conversations'
AttributeDefinitions:
- AttributeName: 'id'
AttributeType: 'S'
KeySchema:
- AttributeName: 'id'
KeyType: 'HASH'
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
CognitoUserPool:
Type: 'AWS::Cognito::UserPool'
Properties:
UserPoolName: ${self:service}-${self:custom.stage}-user-pool
UsernameAttributes:
- email
AutoVerifiedAttributes:
- email
AdminCreateUserConfig:
AllowAdminCreateUserOnly: true
CognitoUserPoolClient:
Type: 'AWS::Cognito::UserPoolClient'
Properties:
ClientName: ${self:service}-${self:custom.stage}-user-pool-client
UserPoolId:
Ref: CognitoUserPool
ExplicitAuthFlows:
- ALLOW_USER_SRP_AUTH
- ALLOW_REFRESH_TOKEN_AUTH
functions:
app:
handler: wsgi_handler.handler
layers:
- { Ref: PythonRequirementsLambdaLayer }
events:
- http:
path: /api/
method: ANY
cors: true
authorizer:
type: COGNITO_USER_POOLS
name: SharedCognitoAuthorizer
arn:
Fn::GetAtt: [CognitoUserPool, Arn]
- http:
path: '/api/{proxy+}'
method: ANY
cors: true
authorizer:
type: COGNITO_USER_POOLS
name: ProxyCognitoAuthorizer
arn:
Fn::GetAtt: [CognitoUserPool, Arn]