-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
81 lines (74 loc) · 3.42 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
myb-kasa-electricity-reporter
Serverless capabilities for capturing and monitoring TP-Link Kasa smart plug electricity data
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Environment:
Variables:
# If RUN_MODE is "test", all functions supporting the test mode will run in test mode
RUN_MODE: "production"
# If VERBOSE_OUTPUT is "true", all functions supporting the setting will print out verbosely
# be aware that this could include secrets and sensitive information
# VERBOSE_OUTPUT: "true"
# Customize this value to whatever you want - your Kasa plugs will need to have this text
# somewhere in their name. For example, a Kasa plug named "My Miner Plug" would match
DEVICES_LIKE: "miner"
# Visit https://www.tplinkcloud.com/ to register an account
# Note that the API is not officially supported for custom use
# Username is just an email
TPLINK_KASA_USERNAME: '{{resolve:ssm:/tplink_kasa/username:1}}'
TPLINK_KASA_PASSWORD: '{{resolve:ssm:/tplink_kasa/password:1}}'
TPLINK_KASA_API_URL: https://wap.tplinkcloud.com
NEWRELIC_ACCOUNT_ID: '{{resolve:ssm:/newrelic/account_id:1}}'
NEWRELIC_INSIGHTS_INSERT_API_KEY: '{{resolve:ssm:/newrelic/insights/insert_api_key:1}}'
NEWRELIC_INSIGHTS_QUERY_API_URL: https://insights-api.newrelic.com
NEWRELIC_INSIGHTS_INSERT_API_URL: https://insights-collector.newrelic.com
Resources:
# More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
KasaCurrentElecFn:
Type: AWS::Serverless::Function
Properties:
CodeUri: kasa_electricity_reporter_function
Handler: kasa_electricity_reporter.app.lambda_handler
Runtime: python3.8
# TODO - this takes a really long time, need to use
# async processing
Timeout: 30
Environment:
Variables:
MEASURE_CADENCE: "current"
Events:
CWSchedule:
Type: Schedule
Properties:
# Syntax for this can be found here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html
Schedule: cron(0/5 * * * ? *)
Name: KasaElecCurrentReportSchedule
Description: execution schedule for the current electricity report
Enabled: True
KasaDailyElecFn:
Type: AWS::Serverless::Function
Properties:
CodeUri: kasa_electricity_reporter_function
Handler: kasa_electricity_reporter.app.lambda_handler
Runtime: python3.8
Timeout: 30
Environment:
Variables:
MEASURE_CADENCE: "day"
# This measures data starting from two days ago. This makes sure the
# data has "settled" and doesn't have any weird timezone issues
MEASURE_OFFSET: "2"
Events:
CWSchedule:
Type: Schedule
Properties:
# Syntax for this can be found here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html
Schedule: cron(0 0 * * ? *)
Name: KasaElecDailyReportSchedule
Description: execution schedule for the daily electricity report
Enabled: True