Git Product home page Git Product logo

terraform-aws-iot-topic-rule's Introduction

terraform-aws-iot-topic-rule

This module is used to create a aws iot rule with actions. It dynamically creates IAM permissions required by the action

Note: Not all actions/errors are supported by [Terraform] (https://www.terraform.io/docs/providers/aws/r/iot_topic_rule.html) when this was written.

Supported Actions

  • cloudwatch_alarm
  • cloudwatch_metric
  • dynamodb
  • elasticsearch
  • firehose
  • kinesis
  • lambda
  • republish
  • s3
  • sns
  • cloudwatch_logs (Only IAM and Log groups are created, Action is not yet supported)

Usage

  • Notifying SNSInvoking Lambda, CW alarm actions
module "iot_rule" {
  name        = "iotTestRule"
  description = "Rule created by TF module"
  sql_query   = "select * from \"mytopic/test\""
  source      = "Quinovas/terraform-aws-iot-topic-rule/aws"

  sns = [
    {
      message_format = "RAW"
      target_arn     = "arn:aws:sns:us-east-1:111222333444:sns-topic"
    }
  ]

  lambda = ["my-function-1", "my-function-2"]

  cloudwatch_alarm = [
    {
      alarm_name   = "iot-alarm"
      state_reason = "iotRule1"
      state_value  = "OK"
    }
   ]
}
  • Inserting message data to Dynamodb table, Cloudwatch and writing Errors to Cloudwatch
module "iot_rule" {
  name        = "iotTestRule"
  description = "Rule created by TF module"
  sql_query   = "select * from \"mytopic/test\""
  source      = "Quinovas/terraform-aws-iot-topic-rule/aws"

  message_data_logs = true
  error_logs        = true

  dynamodb = [{
    hash_key_field  = "message"
    hash_key_type   = null
    hash_key_value  = "$message"
    payload_field   = "Payload"
    range_key_field = null
    range_key_type  = null
    range_key_value = null
    table_name      = "test-iot"
  }]
}

Authors

Module is maintained by QuiNovas

License

Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/). See LICENSE for full details.

terraform-aws-iot-topic-rule's People

Contributors

vchinnakotla avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-aws-iot-topic-rule's Issues

Republish error

Hi :) I'm trying to apply below configuration and get an error:

provider "aws" {

}

module "iot_rule" {
  name = "operationResponse"
  sql_query = "SELECT * FROM othertopic"
  source = "QuiNovas/iot-topic-rule/aws"
  version = "1.0.4"
  error_logs = false
  republish = [{topic = "mytopic"}]
}

Error

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.iot_rule.aws_iam_policy.republish[0]: Creating...
module.iot_rule.aws_iam_role.iot_role: Creating...
module.iot_rule.aws_iam_policy.republish[0]: Creation complete after 2s [id=arn:aws:iam::039321617281:policy/operationResponse-iot-republish]
module.iot_rule.aws_iam_role.iot_role: Creation complete after 3s [id=operationResponse-iot-role]
module.iot_rule.aws_iam_role_policy_attachment.republish[0]: Creating...
module.iot_rule.aws_iot_topic_rule.rule: Creating...
module.iot_rule.aws_iam_role_policy_attachment.republish[0]: Creation complete after 1s [id=operationResponse-iot-role-20210527151223164500000001]
╷
│ Error: error creating IoT Topic Rule (operationResponse): InvalidRequestException: iot.amazonaws.com is unable to perform: sts:AssumeRole on resource: arn:aws:iam::039321617281:role/operationResponse-iot-role
│
│   with module.iot_rule.aws_iot_topic_rule.rule,
│   on .terraform/modules/iot_rule/main.tf line 1, in resource "aws_iot_topic_rule" "rule":
│    1: resource "aws_iot_topic_rule" "rule" {
│
╵

Could you help me? Maybe @vchinnakotla could you help?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.