Repository navigation
Expand file tree
/
Copy pathcloudformation.yaml
More file actions
90 lines (85 loc) · 2.33 KB
/
Copy pathcloudformation.yaml
File metadata and controls
90 lines (85 loc) · 2.33 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
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A stack to store and alert user about crypto currencies.
Parameters:
PhoneNumber:
Type: String
Description: The phone number recipient of the coin alert, in E.164 (e.g. +15555550100) format.
Default: 0
PctChangeCutoff:
Type: Number
Description: The percent change of a coin for which you would like to get an SMS alert for.
Default: 5
CoinList:
Type: String
Default: BTC,ETH
Description: The list of coins to be alerted about, separated by commas and no spaces (e.g. "BTC,ETH,LTC").
Resources:
Alert:
Type: AWS::Serverless::Function
Properties:
Handler: alert.lambda_handler
Runtime: python3.6
Timeout: 60
Environment:
Variables:
PHONE_NUMBER: !Ref PhoneNumber
COIN_LIST: !Ref CoinList
SNS_TOPIC: !Ref SNSTopic
TABLE_NAME: !Ref DynamoDBTable
PCT_CHANGE_CUTOFF: !Ref PctChangeCutoff
Events:
Timer:
Type: Schedule
Properties:
Schedule: rate(5 minutes)
Policies:
- SNSPublishMessagePolicy:
TopicName: !GetAtt SNSTopic.TopicName
- DynamoDBCrudPolicy:
TableName: !Ref DynamoDBTable
CollectPrices:
Type: AWS::Serverless::Function
Properties:
Handler: collect.lambda_handler
Runtime: python3.6
Timeout: 60
Environment:
Variables:
TABLE_NAME: !Ref DynamoDBTable
Events:
Timer:
Type: Schedule
Properties:
Schedule: rate(5 minutes)
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref DynamoDBTable
SNSTopic:
Type: "AWS::SNS::Topic"
Properties:
DisplayName: CryptoAlert
Subscription:
-
Endpoint: !Ref PhoneNumber
Protocol: "sms"
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
-
AttributeName: CoinId
AttributeType: S
-
AttributeName: TimeStamp
AttributeType: N
KeySchema:
-
AttributeName: CoinId
KeyType: HASH
-
AttributeName: TimeStamp
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5