-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yaml
92 lines (87 loc) · 2.62 KB
/
serverless.yaml
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
service: outil
plugins:
- serverless-plugin-typescript
- serverless-plugin-optimize
- serverless-offline
provider:
name: aws
runtime: nodejs14.x
region: ${self:custom.region}
iam:
role:
statements:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:DeleteObject
Resource: 'arn:aws:s3:::${self:custom.inputBucket}/*'
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
- s3:GetObject
- s3:DeleteObject
Resource: 'arn:aws:s3:::${self:custom.outputBucket}/*'
- Effect: Allow
Action:
- s3:ListBucket
Resource: 'arn:aws:s3:::${self:custom.inputBucket}'
- Effect: Allow
Action:
- s3:ListBucket
Resource: 'arn:aws:s3:::${self:custom.outputBucket}'
- Effect: Allow
Action:
- sqs:SendMessage
Resource: ${self:custom.deleteObjectsFromS3Queue.arn}
- Effect: Allow
Action:
- sqs:ReceiveMessage
Resource: ${self:custom.deleteObjectsFromS3Queue.arn}
environment:
INPUT_BUCKET: ${self:custom.inputBucket}
OUTPUT_BUCKET: ${self:custom.outputBucket}
DELETE_OBJECTS_FROM_S3_QUEUE_URL: ${self:custom.deleteObjectsFromS3Queue.url}
AUTH_SECRET: ${self:custom.authSecret}
functions:
main:
handler: src/lambda-main.handler
events:
- http:
method: any
path: /{any+}
layers:
- !Sub arn:aws:lambda:${self:custom.region}:${AWS::AccountId}:layer:ffmpeg:1
listStorage:
handler: src/lambda-list-storage.handler
events:
- schedule: rate(1 hour)
deleteObjectsFromStorage:
handler: src/lambda-clear-storage.handler
events:
- sqs:
arn: ${self:custom.deleteObjectsFromS3Queue.arn}
resources:
Resources:
S3InputBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.inputBucket}
S3OutputBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.outputBucket}
DeleteObjectsFromS3Queue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.deleteObjectsFromS3Queue.name}
custom:
region: ca-central-1
inputBucket: ${file(env.yml):INPUT_BUCKET}-${opt:stage, 'dev'}
outputBucket: ${file(env.yml):OUTPUT_BUCKET}-${opt:stage, 'dev'}
deleteObjectsFromS3Queue:
name: ${file(env.yml):DELETE_OBJECTS_FROM_S3_QUEUE}-${opt:stage, 'dev'}
arn: !GetAtt DeleteObjectsFromS3Queue.Arn
url: !Ref DeleteObjectsFromS3Queue
authSecret: ${file(env.yml):AUTH_SECRET}