-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.yaml
105 lines (96 loc) · 3.76 KB
/
template.yaml
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
# This is in conversation with emphasizing the null functional difference
# of smart contracts and serverless architectures. Suppostion: smart
# contracts are popular because you don't have to run servers
# This solution provides a functional-facsimile to the developer at
# $0.00 cost as a result of the economies of scale of the services this
# portable architecture (Serverless Application Model [SAM]) provides.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >-
XRPL-Price-Persist-Oracle
https://github.com/yyolk/xrpl-price-persist-oracle
Parameters:
ScheduleInterval:
Type: Number
Description: >-
Frequency in minutes
Default: 1
MinValue: 1
XRPLNodeJsonRpcUrl:
Type: String
Description: >-
The endpoint to use to connect to the XRPL, this can be a custom node endpoint.
The default is a Testnet node endpoint, use https://xrplcluster.com (or your own node) for Livenet
Default: https://s.altnet.rippletest.net:51234/
XRPLNodeEnvironment:
Type: String
Description: >-
Is this the Testnet or Livenet? This is used for development,
if the node is in the Testnet the oracle will TrustSet
to FOO. If on the Livenet, the oracle will TrustSet to USD.
AllowedValues:
- Testnet
- Mainnet
Default: Testnet
WalletSecret:
Type: String
NoEcho: True
Description: >-
This is the wallet seed's secret for persisting the price.
This wallet's seed will be used to sign transactions.
For more information see
https://github.com/yyolk/xrpl-price-persist-oracle-sam#note-on-noecho-cloudformation-parameter-for-wallet-secret-seed
GitCommit:
Type: String
Default: ""
Description: >-
This input is fed directly to the function's environment variables that can be deployed publicly.
This is fed in during deployment (such as a public gh-action) which can then be atomically verified through the public,
distributed-ledger known as the XRPL
# This SHA can then be included in the attached memos or as a live endpoint providing it's deployed SHA.
# This can provide verification through timed events in trustless and public platforms, with the results deployed to the block chain.
Conditions:
# https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html
# "For a singular value the unit must be singular (for example, rate(1 day)),
# otherwise plural (for example, rate(5 days))."
OneMinute: !Equals
- !Ref ScheduleInterval
- 1
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
# we should always be below this, emprically, this runs at ~30 seconds
Timeout: 40
MemorySize: 128
Resources:
OracleFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: oracle/
Handler: contract.handler
Runtime: python3.9
Environment:
Variables:
WALLET_SECRET: !Ref WalletSecret
XRPL_JSON_RPC_URL: !Ref XRPLNodeJsonRpcUrl
XRPL_NODE_ENVIRONMENT: !Ref XRPLNodeEnvironment
GIT_COMMIT: !Ref GitCommit
Events:
OracleInvokeInterval:
Type: Schedule
Properties:
Schedule: !If
- OneMinute
- rate(1 minute)
- !Sub "rate(${ScheduleInterval} minutes)"
Description: The interval this function will be invoked
Enabled: true
Policies:
- CloudWatchPutMetricPolicy: {}
Outputs:
OracleFunction:
Description: "Oracle Function ARN"
Value: !GetAtt OracleFunction.Arn
OracleFunctionIamRole:
Description: "Implicit IAM Role created for Oracle Function"
Value: !GetAtt OracleFunctionRole.Arn