diff --git a/func/sanitech-telemetry.tf b/func/sanitech-telemetry.tf new file mode 100644 index 0000000..af6666d --- /dev/null +++ b/func/sanitech-telemetry.tf @@ -0,0 +1,34 @@ +provider "aws" { + region = "us-east-1" +} + +resource "aws_cloudwatch_log_group" "sanitech_telemetry" { + name = "sanitech-telemetry" +} + +resource "aws_cloudwatch_log_stream" "sanitech_telemetry" { + name = "sanitech-telemetry" + log_group_name = aws_cloudwatch_log_group.sanitech_telemetry.name +} + +resource "aws_iot_thing" "sanitech_device" { + name = "sanitech-device" +} + +resource "aws_iot_topic_rule" "sanitech_telemetry" { + name = "sanitech-telemetry" + topic_rule_payload = jsonencode({ + sql = "SELECT * FROM 'sanitech/telemetry'" + actions = [{ + cloudwatch = { + log_group_name = aws_cloudwatch_log_group.sanitech_telemetry.name + log_stream_name = aws_cloudwatch_log_stream.sanitech_telemetry.name + } + }] + }) +} + +resource "aws_iot_topic_subscription" "sanitech_telemetry" { + topic = "sanitech/telemetry" + thing = aws_iot_thing.sanitech_device.name +}