Skip to content

Commit

Permalink
Add 'Seperator' property to AWS IoT Firehose Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bdoepf committed Aug 30, 2018
1 parent a47ddea commit d0464c9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion aws/resource_aws_iot_topic_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func resourceAwsIotTopicRule() *schema.Resource {
Required: true,
ValidateFunc: validateArn,
},
"separator": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateIoTTopicRuleFirehoseSeparator,
},
},
},
},
Expand Down Expand Up @@ -413,12 +418,16 @@ func createTopicRulePayload(d *schema.ResourceData) *iot.TopicRulePayload {

for _, a := range firehoseActions {
raw := a.(map[string]interface{})
actions[i] = &iot.Action{
act := &iot.Action{
Firehose: &iot.FirehoseAction{
DeliveryStreamName: aws.String(raw["delivery_stream_name"].(string)),
RoleArn: aws.String(raw["role_arn"].(string)),
},
}
if v, ok := raw["separator"].(string); ok && v != "" {
act.Firehose.Separator = aws.String(raw["separator"].(string))
}
actions[i] = act
i++
}

Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_iot_topic_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ resource "aws_iot_topic_rule" "rule" {
firehose {
delivery_stream_name = "mystream"
role_arn = "${aws_iam_role.iot_role.arn}"
separator = "\n"
}
}
`, rName)
Expand Down
1 change: 1 addition & 0 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,7 @@ func flattenIoTRuleFirehoseActions(actions []*iot.Action) []map[string]interface
if v != nil {
result["role_arn"] = *v.RoleArn
result["delivery_stream_name"] = *v.DeliveryStreamName
result["separator"] = *v.Separator

results = append(results, result)
}
Expand Down
13 changes: 13 additions & 0 deletions aws/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,19 @@ func validateIoTTopicRuleElasticSearchEndpoint(v interface{}, k string) (ws []st
return
}

func validateIoTTopicRuleFirehoseSeparator(v interface{}, s string) ([]string, []error) {
switch v.(string) {
case
",",
"\t",
"\n",
"\r\n":
return nil, nil
}

return nil, []error{fmt.Errorf("Separator must be one of ',' (comma), '\t' (tab) '\n' (newline) or '\r\n' (Windows newline)")}
}

func validateCognitoRoleMappingsAmbiguousRoleResolutionAgainstType(v map[string]interface{}) (errors []error) {
t := v["type"].(string)
isRequired := t == cognitoidentity.RoleMappingTypeToken || t == cognitoidentity.RoleMappingTypeRules
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/iot_topic_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ The `firehose` object takes the following arguments:

* `delivery_stream_name` - (Required) The delivery stream name.
* `role_arn` - (Required) The IAM role ARN that grants access to the Amazon Kinesis Firehose stream.
* `separator` - (Optional) A character separator that is used to separate records written to the Firehose stream. Valid values are: '\n' (newline), '\t' (tab), '\r\n' (Windows newline), ',' (comma).

The `kinesis` object takes the following arguments:

Expand Down

0 comments on commit d0464c9

Please sign in to comment.