-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserverless.yml
107 lines (100 loc) · 2.85 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
frameworkVersion: ">=1.2.0 <2.0.0"
service: blog-polly # NOTE: update this with your service name
provider:
name: aws
runtime: nodejs4.3
cfLogs: true
environment:
SERVERLESS_STAGE: ${opt:stage, self:provider.stage}
SERVERLESS_PROJECT: ${self:service}
SERVERLESS_REGION: ${opt:region, self:provider.region}
BLOG_BUCKET: ${self:provider.environment.SERVERLESS_PROJECT}-blog-${self:provider.environment.SERVERLESS_STAGE}
PODCAST_BUCKET: ${self:provider.environment.SERVERLESS_PROJECT}-podcast-${self:provider.environment.SERVERLESS_STAGE}
TABLE_NAME: ${self:provider.environment.SERVERLESS_PROJECT}-blog-podcast-${self:provider.environment.SERVERLESS_STAGE}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:*
Resource: arn:aws:dynamodb:${self:provider.environment.SERVERLESS_REGION}:*:*
- Effect: Allow
Action:
- s3:ListBucket
Resource:
- "*"
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:DeleteObject
Resource:
- "*"
- Effect: Allow
Action:
- SNS:*
Resource: arn:aws:sns:${self:provider.environment.SERVERLESS_REGION}:*:*
- Effect: Allow
Action:
- polly:SynthesizeSpeech
Resource: "*"
package:
exclude:
- test/**
- .git/**
functions:
aggregate:
handler: aggregate/index.handler
timeout: 30
events:
- schedule: rate(10 minutes)
convert:
handler: convert/index.handler
events:
- s3:
bucket: ${self:provider.environment.BLOG_BUCKET} # ALSO CREATES THE BUCKET !!!
event: s3:ObjectCreated:*
plugins:
- serverless-mocha-plugin
- serverless-webpack
- serverless-offline
custom:
serverless-mocha-plugin:
functionTemplate: templates/function.ejs
webpackIncludeModules: true
resources:
Resources:
PodcastBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.PODCAST_BUCKET}
PodcastBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: PodcastBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: PodcastBucket
- "/*"
# BlogPodcastTable:
# Type: AWS::DynamoDB::Table
# DeletionPolicy: Retain
# Properties:
# AttributeDefinitions:
# - AttributeName: id
# AttributeType: S
# KeySchema:
# - AttributeName: id
# KeyType: HASH
# ProvisionedThroughput:
# ReadCapacityUnits: 1
# WriteCapacityUnits: 1
# TableName: ${self:provider.environment.TABLE_NAME}