-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserverless.yaml
More file actions
96 lines (94 loc) · 2.79 KB
/
Copy pathserverless.yaml
File metadata and controls
96 lines (94 loc) · 2.79 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
service: aws-nodejs
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-plugin-offline-dynamodb-stream
- 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.
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
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:
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)}
# elasticsearch
- ${file(resources/elasticsearch.yml)}