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

Add 'Seperator' property to AWS IoT Firehose Rule #5734

Merged

Conversation

bdoepf
Copy link
Contributor

@bdoepf bdoepf commented Aug 30, 2018

Fixes #5733

Changes proposed in this pull request:

  • Add 'separator' property to AWS IoT Core Firehose topic rule action.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSIoTTopicRule_firehose'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccAWSIoTTopicRule_firehose -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSIoTTopicRule_firehose
--- PASS: TestAccAWSIoTTopicRule_firehose (29.68s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	29.698s

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/iot Issues and PRs that pertain to the iot service. labels Aug 30, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this @bdoepf! 🚀 This was off to a good start and just needed some extra bits to finish up appropriately (since dealing with whitespace characters is a pain 😄 ), which I took care of in a followup commit so we can get this released today.

While verifying this change, I found it would generate a panic for any configuration that was missing the new separator argument by removing the separator argument from the existing test configuration. This is fixed now.

So looks good now (with new testing):

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSIoTTopicRule_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIoTTopicRule_ -timeout 120m
=== RUN   TestAccAWSIoTTopicRule_importbasic
--- PASS: TestAccAWSIoTTopicRule_importbasic (10.57s)
=== RUN   TestAccAWSIoTTopicRule_basic
--- PASS: TestAccAWSIoTTopicRule_basic (8.47s)
=== RUN   TestAccAWSIoTTopicRule_cloudwatchalarm
--- PASS: TestAccAWSIoTTopicRule_cloudwatchalarm (9.02s)
=== RUN   TestAccAWSIoTTopicRule_cloudwatchmetric
--- PASS: TestAccAWSIoTTopicRule_cloudwatchmetric (9.31s)
=== RUN   TestAccAWSIoTTopicRule_elasticsearch
--- PASS: TestAccAWSIoTTopicRule_elasticsearch (9.43s)
=== RUN   TestAccAWSIoTTopicRule_firehose
--- PASS: TestAccAWSIoTTopicRule_firehose (9.35s)
=== RUN   TestAccAWSIoTTopicRule_firehose_separator
--- PASS: TestAccAWSIoTTopicRule_firehose_separator (14.01s)
=== RUN   TestAccAWSIoTTopicRule_kinesis
--- PASS: TestAccAWSIoTTopicRule_kinesis (9.69s)
=== RUN   TestAccAWSIoTTopicRule_lambda
--- PASS: TestAccAWSIoTTopicRule_lambda (8.47s)
=== RUN   TestAccAWSIoTTopicRule_republish
--- PASS: TestAccAWSIoTTopicRule_republish (8.10s)
=== RUN   TestAccAWSIoTTopicRule_s3
--- PASS: TestAccAWSIoTTopicRule_s3 (9.82s)
=== RUN   TestAccAWSIoTTopicRule_sns
--- PASS: TestAccAWSIoTTopicRule_sns (8.18s)
=== RUN   TestAccAWSIoTTopicRule_sqs
--- PASS: TestAccAWSIoTTopicRule_sqs (8.20s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	123.374s

return nil, nil
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When printing this error, it is returning the whitespace and not the intended characters:

aws_iot_topic_rule.rule: Separator must be one of ',' (comma), '	' (tab) '
        ' (newline) or '
        ' (Windows newline)

They need to be escaped appropriately. 👍

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API will omit this value in the response if parameter is not provided in the configuration and cause a panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2e9cb09]

goroutine 406 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.flattenIoTRuleFirehoseActions(0xc0000c9058, 0x1, 0x1, 0x379df40, 0xc000669520, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:2815 +0x1e9

We should prefer to use the AWS SDK provided functions to dereference pointers instead, e.g. result["separator"] = aws.StringValue(v.Separator)

@bflad bflad added this to the v1.36.0 milestone Sep 12, 2018
@bflad bflad merged commit d0464c9 into hashicorp:master Sep 12, 2018
bflad added a commit that referenced this pull request Sep 12, 2018
* Prevent panic with omitted firehose separator in API response
* Escape whitespace characters in firehose separator ValidateFunc error message
* Add separate test for firehose separator

```
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSIoTTopicRule_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIoTTopicRule_ -timeout 120m
=== RUN   TestAccAWSIoTTopicRule_importbasic
--- PASS: TestAccAWSIoTTopicRule_importbasic (10.57s)
=== RUN   TestAccAWSIoTTopicRule_basic
--- PASS: TestAccAWSIoTTopicRule_basic (8.47s)
=== RUN   TestAccAWSIoTTopicRule_cloudwatchalarm
--- PASS: TestAccAWSIoTTopicRule_cloudwatchalarm (9.02s)
=== RUN   TestAccAWSIoTTopicRule_cloudwatchmetric
--- PASS: TestAccAWSIoTTopicRule_cloudwatchmetric (9.31s)
=== RUN   TestAccAWSIoTTopicRule_elasticsearch
--- PASS: TestAccAWSIoTTopicRule_elasticsearch (9.43s)
=== RUN   TestAccAWSIoTTopicRule_firehose
--- PASS: TestAccAWSIoTTopicRule_firehose (9.35s)
=== RUN   TestAccAWSIoTTopicRule_firehose_separator
--- PASS: TestAccAWSIoTTopicRule_firehose_separator (14.01s)
=== RUN   TestAccAWSIoTTopicRule_kinesis
--- PASS: TestAccAWSIoTTopicRule_kinesis (9.69s)
=== RUN   TestAccAWSIoTTopicRule_lambda
--- PASS: TestAccAWSIoTTopicRule_lambda (8.47s)
=== RUN   TestAccAWSIoTTopicRule_republish
--- PASS: TestAccAWSIoTTopicRule_republish (8.10s)
=== RUN   TestAccAWSIoTTopicRule_s3
--- PASS: TestAccAWSIoTTopicRule_s3 (9.82s)
=== RUN   TestAccAWSIoTTopicRule_sns
--- PASS: TestAccAWSIoTTopicRule_sns (8.18s)
=== RUN   TestAccAWSIoTTopicRule_sqs
--- PASS: TestAccAWSIoTTopicRule_sqs (8.20s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	123.374s
```
bflad added a commit that referenced this pull request Sep 12, 2018
@bflad
Copy link
Contributor

bflad commented Sep 13, 2018

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

@bdoepf
Copy link
Contributor Author

bdoepf commented Sep 15, 2018

@bflad Thanks for your detailed review and fixing the open issues 👍 :-)

@ghost
Copy link

ghost commented Apr 3, 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 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/iot Issues and PRs that pertain to the iot service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IoT Rule Firehose Action - add separator property
2 participants