-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
117 lines (103 loc) · 2.9 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
service: sublease-lambda
plugins:
- serverless-step-functions
- serverless-webpack
- serverless-offline
provider:
name: aws
runtime: nodejs8.10
stage: ${ opt:stage, 'development'}
region: ${ self:custom.globalConfig.AwsRegion }
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchGetItem
Resource:
- "Fn::GetAtt":
- PostTable
- Arn
- Effect: Allow
Action:
- cognito-idp:AdminCreateUser
Resource:
${ self:custom.envConfig.arns.UserPool }
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource:
- arn:aws:s3:::${ self:custom.envConfig.AppBucket }/*
environment:
NODE_ENV: ${ self:provider.stage }
custom:
# Setup serverless plugins
webpackIncludeModules: true
serverless-offline:
port: 3000
babelOptions:
plugins: ["transform-es2015-modules-commonjs", "transform-object-rest-spread"]
# Define configs
globalConfig: ${ file(./configs/config.global.json) }
envConfig: ${ file(./configs/config.env.json):${ self:provider.stage } }
functions:
GraphQL:
handler: handler.graphqlHandler
events:
- http:
path: graphql
method: GET
cors: true
- http:
path: graphql
method: POST
cors: true
PreRender:
handler: handler.preRenderHandler
SavePage:
handler: handler.savePageHandler
stepFunctions:
stateMachines:
checkout:
name: ${ self:provider.stage }-publish
definition:
Comment: Prerender post into static html and save on s3
StartAt: PreRender
States:
PreRender:
Type: Task
Resource: arn:aws:lambda:us-east-1:336626025201:function:${ self:service }-${ self:provider.stage }-PreRender
Next: SavePage
ResultPath: "$.html"
OutputPath: "$"
SavePage:
Type: Task
Resource: arn:aws:lambda:us-east-1:336626025201:function:${ self:service }-${ self:provider.stage }-SavePage
End: true
resources:
Resources:
PostTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TableName: ${ self:provider.stage }-${ self:custom.globalConfig.ResourceNames.PostTable }
PostImagePool:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: ${ self:provider.stage }-${ self:custom.globalConfig.ResourceNames.PostImagePool }