Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty metric_timestamp causes the iot topic rule to not be executed when using cloudwatch metrics as action #6354

Closed
MattBlack85 opened this issue Nov 5, 2018 · 3 comments · Fixed by #6618
Labels
bug Addresses a defect in current functionality. service/iot Issues and PRs that pertain to the iot service.
Milestone

Comments

@MattBlack85
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.11.10, provider aws 1.29.0

Affected Resource(s)

  • aws_iot_topic_rule

Terraform Configuration Files

resource "aws_iot_topic_rule" "shadow_rejection_errors" {
 name = "shadow_rejected_error"
 description = "Add a metric to cloudwatch if any shadow fails update"
 enabled = true
 sql = "SELECT *, topic(3) as device_id FROM '$aws/things/+/shadow/update/rejected'"
 sql_version = "2016-03-23"

 cloudwatch_metric {
   metric_name = "Rejected"
   metric_namespace = "Shadow"
   metric_value = "1"
   metric_unit = "Count"
   role_arn = "${var.iot_metrics_to_cloudwatch_arn}"
 }
}

Debug Output

https://gist.github.com/MattBlack85/d0f0a72811cb661a6acdce7f29717778

Panic Output

None

Expected Behavior

If a rule is created that will put a metric into cloudwatch and the optional parameter metric_timestamp is not provided, the rule should execute correctly with the default timestamp assigned by AWS

Actual Behavior

When calling the AWS API an empty string is sent as metric_timestamp, this make AWS thinks that that empty string is the timestamp we want to use and the rule is not executed.
If the rule is created manually on the console it works and if we get the details from the AWS API we got:

{
    "ruleArn": "arn:aws:iot:eu-west-2:XXXXXXXX:rule/shadow_rejected_error",
    "rule": {
        "ruleName": "shadow_rejected_error",
        "sql": "SELECT *, topic(3) as device_id FROM '$aws/things/+/shadow/update/rejected'",
        "description": "Add a metric to cloudwatch if any shadow fails update",
        "actions": [
            {
                "cloudwatchMetric": {
                    "roleArn": "arn:aws:iam::XXXXXXX:role/iot_metrics_to_cloudwatch",
                    "metricNamespace": "Shadow",
                    "metricName": "Rejected",
                    "metricValue": "1",
                    "metricUnit": "Count"
                }
            }
        ],
        "ruleDisabled": false,
        "awsIotSqlVersion": "2016-03-23"
    }
}

If I create it using terraform the API returns:

{
    "ruleArn": "arn:aws:iot:eu-west-2:647260456021:rule/shadow_rejected_error",
    "rule": {
        "ruleName": "shadow_rejected_error",
        "sql": "SELECT *, topic(3) as device_id FROM '$aws/things/+/shadow/update/rejected'",
        "description": "Add a metric to cloudwatch if any shadow fails update",
        "actions": [
            {
                "cloudwatchMetric": {
                    "roleArn": "arn:aws:iam::647260456021:role/iot_metrics_to_cloudwatch",
                    "metricNamespace": "Shadow",
                    "metricName": "Rejected",
                    "metricValue": "1",
                    "metricUnit": "Count",
                    "metricTimestamp": ""
                }
            }
        ],
        "ruleDisabled": false,
        "awsIotSqlVersion": "2016-03-23"
    }
}

Steps to Reproduce

  1. terraform apply

Important Factoids

None

References

  • #0000
@bflad bflad added the service/iot Issues and PRs that pertain to the iot service. label Nov 5, 2018
@bflad bflad added the bug Addresses a defect in current functionality. label Dec 2, 2018
@bflad bflad added this to the v1.51.0 milestone Dec 2, 2018
@bflad
Copy link
Contributor

bflad commented Dec 2, 2018

The fix for this has been merged and will release with version 1.51.0 of the AWS provider, likely middle of this week. 👍

@bflad
Copy link
Contributor

bflad commented Dec 5, 2018

This has been released in version 1.51.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/iot Issues and PRs that pertain to the iot service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants