This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
serverless.yml
145 lines (140 loc) · 3.3 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
service:
name: serverless-polly
plugins:
- serverless-webpack
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: eu-west-1
memorySize: 128
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:PutObjectAcl"
Resource:
Fn::Join:
- ""
-
- "arn:aws:s3:::"
- Ref : AudioBucket
- "/*"
- Effect: "Allow"
Action:
- "dynamodb:DeleteItem"
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:Scan"
- "dynamodb:UpdateItem"
- "dynamodb:GetRecords"
- "dynamodb:GetShardIterator"
- "dynamodb:DescribeStream"
- "dynamodb:ListStreams"
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:dynamodb'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'Fn::Join':
- ""
-
- 'table/'
- Ref: PollyTable
- Effect: "Allow"
Action:
- "polly:*"
Resource: "*"
functions:
getpost:
handler: getpost.main
description: Gets posts from dynamodb
events:
- http:
method: get
path: /
integration: lambda
cors: true
request:
passThrough: WHEN_NO_MATCH
parameters:
querystrings:
postId: true
template:
application/json: '{ "postId" : "$input.params(''postId'')" }'
response:
headers:
Content-Type: "'application/json'"
environment:
tableName:
Ref: PollyTable
newpost:
handler: newpost.main
description: Adds new posts to dynamodb
events:
- http:
method: post
path: /
integration: lambda
cors: true
request:
passThrough: WHEN_NO_MATCH
template:
application/json: ''
response:
headers:
Content-Type: "'application/json'"
environment:
tableName:
Ref: PollyTable
convertaudio:
handler: convertaudio.main
description: Converts text to mp3 voices throught Polly
events:
- stream:
type: dynamodb
batchSize: 1
arn:
Fn::GetAtt:
- PollyTable
- StreamArn
environment:
tableName:
Ref: PollyTable
audioBucket:
Ref: AudioBucket
region: ${self:provider.region}
resources:
Resources:
PollyTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
StaticBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: index.html
AudioBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
custom:
webpack:
includeModules:
forceExclude:
- aws-sdk