-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
131 lines (119 loc) · 3.4 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
service: spotify-f2p-app
frameworkVersion: "3"
provider:
name: aws
region: eu-central-1
stage: dev
runtime: nodejs14.x
environment:
BITLY_SECRET: ${env:BITLY_SECRET}
FRONTEND_URL: ${env:FRONTEND_URL}
BACKEND_URL: ${env:BACKEND_URL}
SPOTIFY_CLIENT_SECRET: ${env:SPOTIFY_CLIENT_SECRET}
SPOTIFY_CLIENT_ID: ${env:SPOTIFY_CLIENT_ID}
plugins:
- serverless-iam-roles-per-function
- serverless-s3-deploy
- serverless-dynamodb
- serverless-offline
custom:
stage: ${opt:stage, self:provider.stage}
config:
table: ${self:custom.stage}-f2p-table
bucket: ${self:custom.stage}-f2p-frontend
sync: ${self:service}-${self:custom.stage}-sync
assets:
targets:
- bucket: ${self:custom.config.bucket}
files:
- source: ./packages/frontend/build
globs: "**/*"
dynamodb:
stages:
- dev
inMemory: false
start:
port: 8000
seed: true
migrate: true
sharedDb: true
package:
individually: true
patterns:
- "!./**"
functions:
backend:
handler: ./packages/backend/build/handler.handle
package:
patterns:
- "./packages/backend/build/handler.js"
events:
- http:
path: /backend/{proxy+}
method: get
cors: true
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource:
- "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:custom.config.table}"
- "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:custom.config.table}/index/*"
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource:
- "arn:aws:lambda:${opt:region, self:provider.region}:*:function:${self:custom.config.sync}"
environment:
TABLE_NAME: ${self:custom.config.table}
SYNC_LAMBDA: ${self:custom.config.sync}
sync:
handler: ./packages/sync/build/handler.handle
package:
patterns:
- "./packages/sync/build/handler.js"
timeout: 900
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:UpdateItem
Resource:
- "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:custom.config.table}"
- "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:custom.config.table}/index/*"
environment:
TABLE_NAME: ${self:custom.config.table}
resources:
Resources:
Table:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: ${self:custom.config.table}
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: ${self:custom.config.bucket}
WebsiteConfiguration:
ErrorDocument: "index.html"
IndexDocument: "index.html"
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref WebsiteBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "s3:GetObject"
Principal: "*"
Resource: !Sub "${WebsiteBucket.Arn}/*"