-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
211 lines (194 loc) · 6.06 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
org: upstandfm
app: api
service: infra
provider:
name: aws
stage: ${opt:stage, 'prod'}
region: ${opt:region, 'eu-central-1'}
cfnRole: ${secrets:CFN_ROLE_ARN}
deploymentBucket:
name: upstandfm-deployments
serverSideEncryption: AES256 # when using server-side encryption
package:
exclude:
- ./*
resources:
# CloudFormation template syntax
Resources:
# DynamoDB
#
# For more info see:
# https://docs.aws.amazon.com/en_pv/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html
workspacesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Workspaces
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
invitesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Invites
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
# SNS
#
# For more info see:
# https://docs.aws.amazon.com/en_pv/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html
newS3AudioRecordingTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: new-s3-audio-recording
newS3TranscodedAudioRecordingTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: new-s3-transcoded-audio-recording
newInviteTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: new-invite
deletedInviteTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: deleted-invite
# S3
#
# For more info on policies see:
# https://docs.aws.amazon.com/en_pv/AWSCloudFormation/latest/UserGuide/aws-properties-sns-policy.html
#
# For more info on buckets see:
# https://docs.aws.amazon.com/en_pv/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html
s3PublishTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
Topics:
- !Ref newS3AudioRecordingTopic
- !Ref newS3TranscodedAudioRecordingTopic
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: "s3-publish-to-sns-new-audio-recording-topic"
Effect: Allow
Action: sns:Publish
Resource: !Ref newS3AudioRecordingTopic
Principal:
Service: s3.amazonaws.com
- Sid: "s3-publish-to-sns-new-transcoded-audio-recording-topic"
Effect: Allow
Action: sns:Publish
Resource: !Ref newS3TranscodedAudioRecordingTopic
Principal:
Service: s3.amazonaws.com
recordingsBucket:
Type: AWS::S3::Bucket
DependsOn: s3PublishTopicPolicy
Properties:
BucketName: upstandfm-recordings
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- HEAD
- PUT
AllowedOrigins:
- "*"
NotificationConfiguration:
TopicConfigurations:
- Event: s3:ObjectCreated:*
# For more info see:
# https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
Filter:
S3Key:
Rules:
- Name: prefix
Value: audio/
- Name: suffix
Value: .webm
Topic: !Ref newS3AudioRecordingTopic
transcodedRecordingsBucket:
Type: AWS::S3::Bucket
DependsOn: s3PublishTopicPolicy
Properties:
BucketName: upstandfm-transcoded-recordings
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
- HEAD
AllowedOrigins:
- "*"
NotificationConfiguration:
TopicConfigurations:
- Event: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: audio/
Topic: !Ref newS3TranscodedAudioRecordingTopic
# Serverless output variables
# For more info see:
# https://serverless.com/framework/docs/dashboard/output-variables/
outputs:
# DynamoDB
workspacesTableArn:
"Fn::GetAtt": [workspacesTable, Arn]
invitesTableArn:
"Fn::GetAtt": [invitesTable, Arn]
invitesTableStreamArn:
"Fn::GetAtt": [invitesTable, StreamArn]
# SNS
newS3AudioRecordingTopicArn: !Ref newS3AudioRecordingTopic
newS3TranscodedAudioRecordingTopicArn: !Ref newS3TranscodedAudioRecordingTopic
newInviteTopicArn: !Ref newInviteTopic
deleteInviteTopicArn: !Ref deletedInviteTopic
# S3
recordingsBucketArn:
"Fn::GetAtt": [recordingsBucket, Arn]
transcodedRecordingsBucketArn:
"Fn::GetAtt": [transcodedRecordingsBucket, Arn]