From 4a6ef1f7fc09db3c2267c8a08339ae94bf734267 Mon Sep 17 00:00:00 2001 From: Philipp Jauert Date: Tue, 27 Nov 2018 20:46:24 +0100 Subject: [PATCH] metric_timestamp is an optional parameter and should not send to aws if empty --- aws/resource_aws_iot_topic_rule.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_iot_topic_rule.go b/aws/resource_aws_iot_topic_rule.go index 36500a6d43df..a8e50044e6e6 100644 --- a/aws/resource_aws_iot_topic_rule.go +++ b/aws/resource_aws_iot_topic_rule.go @@ -359,16 +359,19 @@ func createTopicRulePayload(d *schema.ResourceData) *iot.TopicRulePayload { // Add Cloudwatch Metric actions for _, a := range cloudwatchMetricActions { raw := a.(map[string]interface{}) - actions[i] = &iot.Action{ + act := &iot.Action{ CloudwatchMetric: &iot.CloudwatchMetricAction{ MetricName: aws.String(raw["metric_name"].(string)), MetricNamespace: aws.String(raw["metric_namespace"].(string)), MetricUnit: aws.String(raw["metric_unit"].(string)), MetricValue: aws.String(raw["metric_value"].(string)), RoleArn: aws.String(raw["role_arn"].(string)), - MetricTimestamp: aws.String(raw["metric_timestamp"].(string)), }, } + if v, ok := raw["metric_timestamp"].(string); ok && v != "" { + act.CloudwatchMetric.MetricTimestamp = aws.String(v) + } + actions[i] = act i++ }