-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
101 lines (96 loc) · 2.43 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
service: blog
plugins:
- serverless-plugin-typescript
package:
include:
- src/**
provider:
name: aws
runtime: nodejs12.x
region: us-west-2
apiGateway:
# Delete this line after upgrading to v3.0.0 since it will be the default
shouldStartNameWithService: true
# Delete this line after upgrading to v3.0.0 since it will be the default
lambdaHashingVersion: 20201221
environment:
ARTICLES_TABLE_NAME: !Ref ArticlesTable
SERIES_TABLE_NAME: !Ref SeriesTable
DEFAULT_BUCKET_NAME: !Ref DefaultBucket
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:*
Resource: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${AWS::StackName}-*
- Effect: Allow
Action:
- s3:*
Resource: !Sub arn:aws:s3:::${AWS::StackName}-*
functions:
getArticle:
handler: src/functions/get-article.handler
events:
- http:
path: article/{id}
method: get
cors: true
request:
parameters:
paths:
id: true
getSeries:
handler: src/functions/get-series.handler
events:
- http:
path: series/{id}
method: get
cors: true
request:
parameters:
paths:
id: true
resources:
Resources:
ArticlesTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
SeriesTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
DefaultBucket:
Type: AWS::S3::Bucket
Properties:
VersioningConfiguration:
Status: Enabled
PublicBucket:
Type: AWS::S3::Bucket
Properties:
VersioningConfiguration:
Status: Enabled
PublicBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref PublicBucket
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:GetObject
Principal: "*"
Resource: !Sub ${PublicBucket.Arn}/*