forked from DasithKuruppu/Serverless-GraphQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
127 lines (125 loc) · 3.63 KB
/
Copy pathserverless.yml
File metadata and controls
127 lines (125 loc) · 3.63 KB
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
service: aws-nodejs
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-plugin-offline-dynamodb-stream
- serverless-s3-sync #https://github.com/k1LoW/serverless-s3-sync
- serverless-jest-plugin
- serverless-offline
custom:
# Our stage is based on what is passed in when running serverless
# commands. Or fallsback to what we have set in the provider section.
stage: ${opt:stage, self:provider.stage}
# Set the table name here so we can use it while testing locally
tableName: ${self:custom.stage}-events
# Set our DynamoDB throughput for prod and all other non-prod stages.
s3Bucket: webapps3bucket-${self:custom.stage}
s3Sync:
- bucketName: ${self:custom.s3Bucket} # required
localDir: client/ # required
params: # optional
- index.html:
CacheControl: 'no-cache'
tableThroughputs:
prod: 1 #more throughput on production env
default: 1
tableThroughput: ${self:custom.tableThroughputs.${self:custom.stage}, self:custom.tableThroughputs.default}
webpack:
webpackConfig: './webpack.config.js' # Name of webpack configuration file
includeModules: true # Node modules configuration for packaging
packager: 'npm' # Packager that will be used to package your external module
dynamodb:
start:
port: 8000
migrate: true
inMemory: true
noStart: true
dynamodbStream:
port: 8000
streams:
- table: EventTable
functions:
- processStreams
jest:
collectCoverage: true
collectCoverageFrom:
- "**/*.js"
- "!**/__tests__/**"
- "!**/node_modules/**"
- "!**/.webpack/**"
preset: "ts-jest"
environment: ${file(env.yml):${self:custom.stage}, file(env.yml):default}
provider:
name: aws
runtime: nodejs8.10
stage: default
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:ListTables
- dynamodb:DescribeTable
- dynamodb:DescribeStream
- dynamodb:ListStreams
- dynamodb:GetShardIterator
- dynamodb:BatchGetItem
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:DescribeReservedCapacity
- dynamodb:DescribeReservedCapacityOfferings
- dynamodb:GetRecords
Resource:
Fn::Join:
- ""
- - "arn:aws:dynamodb:*:*:table/"
- Ref: EventsGqlDynamoDbTable
- Effect: Allow
Action:
- es:ESHttpPost
- es:ESHttpPut
- es:ESHttpDelete
- es:ESHttpGet
Resource:
- { "Fn::GetAtt": ["EventsGqlElasticSearch", "DomainArn"] }
- { "Fn::Join": ["", ["Fn::GetAtt": ["EventsGqlElasticSearch", "DomainArn"], "/*"]] }
functions:
queryEvents:
handler: handler.queryEvents
events:
- http:
path: events
method: post
cors: true
environment:
TABLE_NAME: ${self:custom.tableName}
dynamo-stream-to-elasticsearch:
handler: handler.processStreams
memorySize: 128
timeout: 60
events:
- stream:
type: dynamodb
batchSize: 100
enabled: true
arn:
Fn::GetAtt:
- EventsGqlDynamoDbTable
- StreamArn
environment:
ELASTICSEARCH_URL:
Fn::GetAtt:
- EventsGqlElasticSearch
- DomainEndpoint
resources:
# DynamoDB
- ${file(resources/dynamodb.yml)}
# S3
- ${file(resources/s3-bucket-cdn.yml)}
# Cognito
- ${file(resources/cognito-user-pool.yml)}
- ${file(resources/cognito-identity-pool.yml)}
# elasticsearch
- ${file(resources/elasticsearch.yml)}