-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yml
More file actions
93 lines (88 loc) · 2.38 KB
/
template.yml
File metadata and controls
93 lines (88 loc) · 2.38 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'Stock demo'
Resources:
ConsumedFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/event.productConsumed
Runtime: nodejs6.10
Policies: AmazonDynamoDBFullAccess
Environment:
Variables:
EVENT_TABLE: !Ref StockEventTable
Events:
ConsumeStockApi:
Type: Api
Properties:
Path: /consumed/{productId}
Method: post
ReceivedFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/event.productReceived
Runtime: nodejs6.10
Policies: AmazonDynamoDBFullAccess
Environment:
Variables:
EVENT_TABLE: !Ref StockEventTable
Events:
EntryStockApi:
Type: Api
Properties:
Path: /received/{productId}
Method: post
GetStockFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/stock.getStock
Runtime: nodejs6.10
Policies: AmazonDynamoDBReadOnlyAccess
Environment:
Variables:
MODEL_TABLE: !Ref StockReadModelTable
Events:
GetStockFunctionApi:
Type: Api
Properties:
Path: /{productId}
Method: get
StockEventListenerFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/eventListener.listener
Runtime: nodejs6.10
Policies: AmazonDynamoDBFullAccess
Environment:
Variables:
MODEL_TABLE: !Ref StockReadModelTable
Events:
StockEventStream:
Type: DynamoDB
Properties:
Stream: !GetAtt StockEventTable.StreamArn
StartingPosition: TRIM_HORIZON
BatchSize: 1
StockEventTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: uuid
AttributeType: S
KeySchema:
- AttributeName: uuid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
StreamSpecification:
StreamViewType: NEW_IMAGE
StockReadModelTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: productId
Type: Number
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2