-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserverless.yml
More file actions
160 lines (152 loc) · 3.88 KB
/
serverless.yml
File metadata and controls
160 lines (152 loc) · 3.88 KB
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
service: srv-s3-proxy
app: content
org: ${opt:org, 'maniacalmenagerie'}
frameworkVersion: '2'
plugins:
- serverless-bundle
provider:
name: aws
runtime: nodejs12.x
region: eu-west-2
stage: ${opt:stage, 'qa'}
apiGateway:
shouldStartNameWithService: true
binaryMediaTypes:
- '*/*'
metrics: true
iamRoleStatements:
- Effect: Allow
Action:
- s3:ListBucket
- s3:GetObject
Resource:
- Fn::GetAtt: [S3BucketImages, Arn]
- Fn::GetAtt: [S3BucketStatic, Arn]
custom:
bundle:
sourcemaps: false
stats: true
linting: false
packagerOptions:
scripts:
- npm install --arch=x64 --platform=linux sharp
functions:
GetImage:
handler: src/httpApi/v1/index.getFile
memorySize: 1024
timeout: 15
environment:
BUCKET:
Ref: S3BucketImages
events:
- http:
path: /content/img/{proxy+}
method: get
# - alb:
# listenerArn: ${param:ALB-ARN}
# priority: 1
# conditions:
# host:
# - <HOSTNAME GOES HERE>
# path: /content/img/*
# method:
# - GET
GetStaticResource:
handler: src/httpApi/v1/index.getFile
environment:
BUCKET:
Ref: S3BucketStatic
events:
- http:
path: /_common/{proxy+}
method: get
resources:
Resources:
S3BucketImages:
Type: 'AWS::S3::Bucket'
Properties:
PublicAccessBlockConfiguration:
RestrictPublicBuckets: true
BucketPolicyImages:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: S3BucketImages
PolicyDocument:
Statement:
- Effect: Allow
Principal:
AWS:
Fn::GetAtt: [IamRoleLambdaExecution, Arn]
Action:
- s3:GetObject
Resource:
- Fn::Join:
- ''
- - Fn::GetAtt: [S3BucketImages, Arn]
- /*
- Effect: Allow
Principal:
AWS:
Fn::GetAtt: [IamRoleLambdaExecution, Arn]
Action:
- s3:ListBucket
Resource:
- Fn::GetAtt: [S3BucketImages, Arn]
S3BucketStatic:
Type: 'AWS::S3::Bucket'
Properties:
PublicAccessBlockConfiguration:
RestrictPublicBuckets: true
BucketPolicyStatic:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: S3BucketStatic
PolicyDocument:
Statement:
- Effect: Allow
Principal:
AWS:
Fn::GetAtt: [IamRoleLambdaExecution, Arn]
Action:
- s3:GetObject
Resource:
- Fn::Join:
- ''
- - Fn::GetAtt: [S3BucketStatic, Arn]
- /*
- Effect: Allow
Principal:
AWS:
Fn::GetAtt: [IamRoleLambdaExecution, Arn]
Action:
- s3:ListBucket
Resource:
- Fn::GetAtt: [S3BucketStatic, Arn]
Outputs:
FunctionNameGetImage:
Value:
Ref: GetImageLambdaFunction
Export:
Name: ${self:provider.stage}-GetImageLambdaFunction
S3BucketNameImages:
Value:
Ref: S3BucketImages
Export:
Name: ${self:provider.stage}-VedImageBucket
S3BucketArnImages:
Value:
Fn::GetAtt: S3BucketImages.Arn
Export:
Name: ${self:provider.stage}-VedImageBucketArn
S3BucketNameStatic:
Value:
Ref: S3BucketStatic
Export:
Name: ${self:provider.stage}-VedStaticBucket
S3BucketArnStatic:
Value:
Fn::GetAtt: S3BucketStatic.Arn
Export:
Name: ${self:provider.stage}-VedStaticBucketArn