-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
94 lines (87 loc) · 2.1 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
service: ai-roaster
useDotenv: true
plugins:
- serverless-offline
- serverless-plugin-warmup
- serverless-python-requirements
- serverless-dotenv-plugin
provider:
name: aws
iam:
role:
managedPolicies:
- arn:aws:iam::aws:policy/SecretsManagerReadWrite
statements:
- Effect: "Allow"
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
- s3:*
- dynamodb:*
- bedrock:*
- polly:SynthesizeSpeech
Resource: "*"
runtime: python3.10
stage: prod
memorySize: 768
timeout: 30
region: ${env:REGION}
lambdaHashingVersion: 20201221
stackTags:
owner: "Soheil Sheybani"
project: "automation"
custom:
pythonRequirements:
dockerizePip: non-linux
warmup:
default:
enabled: true
events:
- schedule: rate(5 minutes)
prewarm: true
package:
exclude:
- node_modules/**
- venv/**
- __pycache__/**
resources:
Resources:
MyPublicS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${env:ASSET_BUCKET}
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
OwnershipControls: # Move OwnershipControls to the correct place
Rules:
- ObjectOwnership: ObjectWriter
PublicBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref MyPublicS3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action: "s3:GetObject"
Resource: !Sub "${MyPublicS3Bucket.Arn}/*"
functions:
app:
handler: src/main.lambda_handler
events:
- http:
cors: true
method: ANY
path: /{proxy+}
- http:
cors: true
method: ANY
path: /
environment:
BUCKET_NAME: ${env:ASSET_BUCKET}
OPENAI_API_KEY: ${env:OPENAI_KEY_SECRET_NAME}