forked from acolytec3/avatar-star
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
113 lines (96 loc) · 2.75 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
app: lambdavatar
service: lambdavatar
plugins:
- serverless-plugin-typescript
- serverless-s3-local
- serverless-offline-env
- serverless-offline
- serverless-prune-plugin
- serverless-domain-manager
custom:
stage: ${opt:stage, 'dev'}
bucket: ${file(env.${self:custom.stage}.json):S3BUCKETNAME}
deleteDays: ${file(env.${self:custom.stage}.json):DELETE_DAYS}
serverless-offline-env:
path: .env
serverless-offline:
noPrependStageInUrl: true
noTimeout: true
port: 3000
host: localhost
s3:
port: 8000
directory: /tmp
prune:
automatic: true
number: 3
customDomain:
domainName: 'lambdavatar.backend.ideamarket.io'
basePath: ''
stage: ${self:custom.stage}
createRoute53Record: true
provider:
name: aws
runtime: nodejs14.x
region: us-east-1
timeout: 20
environment:
IMAGE_WIDTH: ${file(env.${self:custom.stage}.json):IMAGE_WIDTH}
IMAGE_MAX_AGE: ${file(env.${self:custom.stage}.json):IMAGE_MAX_AGE}
S3_BUCKET: ${self:custom.bucket}
S3_ENDPOINT: ${file(env.${self:custom.stage}.json):S3ENDPOINT}
S3_ACCESS_KEY: ${file(env.${self:custom.stage}.json):S3ACCESSKEYID}
S3_SECRET_ACCESS_KEY: ${file(env.${self:custom.stage}.json):S3SECRETACCESSKEY}
PROXY_HOST: ${file(env.${self:custom.stage}.json):PROXY_HOST}
PROXY_PORT: ${file(env.${self:custom.stage}.json):PROXY_PORT}
PROXY_AUTH: ${file(env.${self:custom.stage}.json):PROXY_AUTH}
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
Resource:
- 'arn:aws:s3:::${self:custom.bucket}'
- 'arn:aws:s3:::${self:custom.bucket}/*'
functions:
main:
handler: src/main.default
events:
- http:
path: /{provider}/{username}
method: get
cors: true
resources:
Resources:
LambdavatarBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.bucket}
AccessControl: PublicRead
LifecycleConfiguration:
Rules:
- Id: AutoDeleteRule
Status: Enabled
ExpirationInDays: '${self:custom.deleteDays}'
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- '*'
AllowedMethods:
- GET
AllowedOrigins:
- '*'
MaxAge: '604800'
LambdavatarBucketAllowPublicReadPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LambdavatarBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetObject'
Resource:
- 'arn:aws:s3:::${self:custom.bucket}/*'
Principal: '*'