-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
93 lines (89 loc) · 2.79 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
org: upstandfm
app: api
service: audio-transcoder
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'prod'}
region: ${opt:region, 'eu-central-1'}
cfnRole: ${secrets:CFN_ROLE_ARN}
memorySize: 128
timeout: 3
deploymentBucket:
name: upstandfm-deployments
serverSideEncryption: AES256
environment:
# Reuse TCP connection to reduce request latency
# For more info see:
# https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#24630
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
# The ARN has the format "arn:aws:s3:::bucketName"
# Splitting on ":::" gives us the name
S3_RECORDINGS_BUCKET_NAME:
'Fn::Select':
['1', { 'Fn::Split': [':::', '${state:infra.recordingsBucketArn}'] }]
S3_TRANSCODED_RECORDINGS_BUCKET_NAME:
'Fn::Select':
[
'1',
{
'Fn::Split':
[':::', '${state:infra.transcodedRecordingsBucketArn}'],
},
]
WORKSPACES_TABLE_NAME:
'Fn::Select':
['1', { 'Fn::Split': ['/', '${state:infra.workspacesTableArn}'] }]
# See: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_actions-resources-contextkeys.html
iamRoleStatements:
- Effect: Allow
Action:
- s3:GetObject
# MUST contain "/*" because resource type is "object"
Resource:
'Fn::Join': ['/', ['${state:infra.recordingsBucketArn}', '*']]
- Effect: Allow
Action:
- s3:GetObject
# MUST contain "/*" because resource type is "object"
Resource:
'Fn::Join': ['/', ['${state:infra.transcodedRecordingsBucketArn}', '*']]
- Effect: Allow
Action:
- s3:PutObject
# MUST contain "/*" because resource type is "object"
Resource:
'Fn::Join':
['/', ['${state:infra.transcodedRecordingsBucketArn }', '*']]
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource: ${state:infra.workspacesTableArn}
package:
exclude:
- ./*
- ./**/*.spec.js
include:
- node_modules
- src
functions:
ffmpegWebmToMp3:
memorySize: 2048
timeout: 10
handler: src/consumers.ffmpegWebmToMp3
description: Transcodes a WebM audio recording to MP3 using FFmpeg
events:
- sns: ${state:infra.newS3AudioRecordingTopicArn}
layers:
- ${state:lambda-layers.ffmpegArn}
createRecording:
handler: src/consumers.createRecording
description: Creates a recording item in DB when a new audio recording was uploaded
events:
- sns: ${state:infra.newS3AudioRecordingTopicArn}
updateRecording:
handler: src/consumers.updateRecording
description: Updates a recording item in DB when an audio recording has been transcoded
events:
- sns: ${state:infra.newS3TranscodedAudioRecordingTopicArn}