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

bugfix: can't update iot topic rule with kafka destination #33360

Closed

Conversation

mbbush
Copy link
Contributor

@mbbush mbbush commented Sep 7, 2023

Description

When updating an aws_iot_topic_rule with a destination of type kafka, the d *schema.ResourceData passed into the resourceTopicRuleUpdate function contains a diff that would create a second kafka action, which has all zero/null/empty values for every property. This then fails schema validation, and the update fails.

I fixed it by updating the expandKafkaAction function to filter out this erroneous action.

I duplicated the bug with an acceptance test, which failed before my fix, and now passes. I also updated the test coverage for the other action types to include an update.

Relations

Closes #24742

References

The source fork is owned by an organization, and as far as I can tell from the linked documentation, that means there's no way to allow maintainers to edit the PR. If I'm wrong on that, and it is possible, let me know.

Output from Acceptance Testing

% make testacc TESTS=TestAccIoTTopicRule_ PKG=iot
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/iot/... -v -count 1 -parallel 20 -run='TestAccIoTTopicRule_'  -timeout 180m
=== RUN   TestAccIoTTopicRule_basic
=== PAUSE TestAccIoTTopicRule_basic
=== RUN   TestAccIoTTopicRule_disappears
=== PAUSE TestAccIoTTopicRule_disappears
=== RUN   TestAccIoTTopicRule_tags
=== PAUSE TestAccIoTTopicRule_tags
=== RUN   TestAccIoTTopicRule_cloudWatchAlarm
=== PAUSE TestAccIoTTopicRule_cloudWatchAlarm
=== RUN   TestAccIoTTopicRule_cloudWatchLogs
=== PAUSE TestAccIoTTopicRule_cloudWatchLogs
=== RUN   TestAccIoTTopicRule_cloudWatchMetric
=== PAUSE TestAccIoTTopicRule_cloudWatchMetric
=== RUN   TestAccIoTTopicRule_dynamoDB
=== PAUSE TestAccIoTTopicRule_dynamoDB
=== RUN   TestAccIoTTopicRule_dynamoDBv2
=== PAUSE TestAccIoTTopicRule_dynamoDBv2
=== RUN   TestAccIoTTopicRule_elasticSearch
=== PAUSE TestAccIoTTopicRule_elasticSearch
=== RUN   TestAccIoTTopicRule_firehose
=== PAUSE TestAccIoTTopicRule_firehose
=== RUN   TestAccIoTTopicRule_Firehose_separator
=== PAUSE TestAccIoTTopicRule_Firehose_separator
=== RUN   TestAccIoTTopicRule_Firehose_batch_mode
=== PAUSE TestAccIoTTopicRule_Firehose_batch_mode
=== RUN   TestAccIoTTopicRule_http
=== PAUSE TestAccIoTTopicRule_http
=== RUN   TestAccIoTTopicRule_IoT_analytics
=== PAUSE TestAccIoTTopicRule_IoT_analytics
=== RUN   TestAccIoTTopicRule_IoT_analytics_batch_mode
=== PAUSE TestAccIoTTopicRule_IoT_analytics_batch_mode
=== RUN   TestAccIoTTopicRule_IoT_events
=== PAUSE TestAccIoTTopicRule_IoT_events
=== RUN   TestAccIoTTopicRule_IoT_events_batch_mode
=== PAUSE TestAccIoTTopicRule_IoT_events_batch_mode
=== RUN   TestAccIoTTopicRule_kafka
=== PAUSE TestAccIoTTopicRule_kafka
=== RUN   TestAccIoTTopicRule_kinesis
=== PAUSE TestAccIoTTopicRule_kinesis
=== RUN   TestAccIoTTopicRule_lambda
=== PAUSE TestAccIoTTopicRule_lambda
=== RUN   TestAccIoTTopicRule_republish
=== PAUSE TestAccIoTTopicRule_republish
=== RUN   TestAccIoTTopicRule_republishWithQos
=== PAUSE TestAccIoTTopicRule_republishWithQos
=== RUN   TestAccIoTTopicRule_s3
=== PAUSE TestAccIoTTopicRule_s3
=== RUN   TestAccIoTTopicRule_sns
=== PAUSE TestAccIoTTopicRule_sns
=== RUN   TestAccIoTTopicRule_sqs
=== PAUSE TestAccIoTTopicRule_sqs
=== RUN   TestAccIoTTopicRule_Step_functions
=== PAUSE TestAccIoTTopicRule_Step_functions
=== RUN   TestAccIoTTopicRule_Timestream
=== PAUSE TestAccIoTTopicRule_Timestream
=== RUN   TestAccIoTTopicRule_errorAction
=== PAUSE TestAccIoTTopicRule_errorAction
=== RUN   TestAccIoTTopicRule_updateKinesisErrorAction
=== PAUSE TestAccIoTTopicRule_updateKinesisErrorAction
=== CONT  TestAccIoTTopicRule_basic
=== CONT  TestAccIoTTopicRule_IoT_events
=== CONT  TestAccIoTTopicRule_updateKinesisErrorAction
=== CONT  TestAccIoTTopicRule_errorAction
=== CONT  TestAccIoTTopicRule_republish
=== CONT  TestAccIoTTopicRule_republishWithQos
=== CONT  TestAccIoTTopicRule_Step_functions
=== CONT  TestAccIoTTopicRule_IoT_events_batch_mode
=== CONT  TestAccIoTTopicRule_sqs
=== CONT  TestAccIoTTopicRule_Timestream
=== CONT  TestAccIoTTopicRule_elasticSearch
=== CONT  TestAccIoTTopicRule_IoT_analytics_batch_mode
=== CONT  TestAccIoTTopicRule_IoT_analytics
=== CONT  TestAccIoTTopicRule_http
=== CONT  TestAccIoTTopicRule_Firehose_batch_mode
=== CONT  TestAccIoTTopicRule_Firehose_separator
=== CONT  TestAccIoTTopicRule_lambda
=== CONT  TestAccIoTTopicRule_kinesis
=== CONT  TestAccIoTTopicRule_kafka
=== CONT  TestAccIoTTopicRule_firehose
--- PASS: TestAccIoTTopicRule_lambda (38.19s)
=== CONT  TestAccIoTTopicRule_cloudWatchLogs
--- PASS: TestAccIoTTopicRule_basic (38.46s)
=== CONT  TestAccIoTTopicRule_dynamoDBv2
--- PASS: TestAccIoTTopicRule_republishWithQos (59.82s)
=== CONT  TestAccIoTTopicRule_dynamoDB
--- PASS: TestAccIoTTopicRule_IoT_events (61.24s)
=== CONT  TestAccIoTTopicRule_cloudWatchMetric
--- PASS: TestAccIoTTopicRule_errorAction (68.46s)
=== CONT  TestAccIoTTopicRule_sns
--- PASS: TestAccIoTTopicRule_IoT_analytics_batch_mode (87.58s)
=== CONT  TestAccIoTTopicRule_tags
--- PASS: TestAccIoTTopicRule_IoT_analytics (88.20s)
=== CONT  TestAccIoTTopicRule_cloudWatchAlarm
--- PASS: TestAccIoTTopicRule_elasticSearch (91.41s)
=== CONT  TestAccIoTTopicRule_s3
--- PASS: TestAccIoTTopicRule_Firehose_batch_mode (91.50s)
=== CONT  TestAccIoTTopicRule_disappears
--- PASS: TestAccIoTTopicRule_updateKinesisErrorAction (92.51s)
--- PASS: TestAccIoTTopicRule_Step_functions (93.61s)
--- PASS: TestAccIoTTopicRule_sqs (93.84s)
--- PASS: TestAccIoTTopicRule_kinesis (93.95s)
--- PASS: TestAccIoTTopicRule_Timestream (94.04s)
--- PASS: TestAccIoTTopicRule_IoT_events_batch_mode (94.22s)
--- PASS: TestAccIoTTopicRule_Firehose_separator (94.99s)
--- PASS: TestAccIoTTopicRule_republish (95.09s)
--- PASS: TestAccIoTTopicRule_firehose (95.11s)
--- PASS: TestAccIoTTopicRule_disappears (23.97s)
--- PASS: TestAccIoTTopicRule_dynamoDBv2 (77.22s)
--- PASS: TestAccIoTTopicRule_cloudWatchLogs (81.02s)
--- PASS: TestAccIoTTopicRule_http (121.75s)
--- PASS: TestAccIoTTopicRule_dynamoDB (70.89s)
--- PASS: TestAccIoTTopicRule_cloudWatchMetric (70.11s)
--- PASS: TestAccIoTTopicRule_kafka (137.49s)
--- PASS: TestAccIoTTopicRule_sns (71.98s)
--- PASS: TestAccIoTTopicRule_cloudWatchAlarm (57.63s)
--- PASS: TestAccIoTTopicRule_s3 (55.61s)
--- PASS: TestAccIoTTopicRule_tags (63.10s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/iot	150.778s

...

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added the size/XL Managed by automation to categorize the size of a PR. label Sep 7, 2023
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Hey @mbbush 👋 Thank you very much for your contribution! At times, our maintainers need to make direct edits to pull requests in order to help get it ready to be merged. Your current settings do not allow maintainers to make such edits. To help facilitate this, update your pull request to allow such edits as described in GitHub's Allowing changes to a pull request branch created from a fork documentation. (If you're using a fork owned by an organization, your organization may not allow you to change this setting. If that is the case, let us know.)

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/iot Issues and PRs that pertain to the iot service. labels Sep 7, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 7, 2023
@mbbush mbbush changed the title B aws iot topic rule kafka update fix bugfix: can't update iot topic rule with kafka destination Sep 7, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @mbbush 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@mbbush mbbush force-pushed the b-aws_iot_topic_rule_kafka-update-fix branch from 852a51c to bb181d4 Compare September 7, 2023 23:47
@mbbush mbbush marked this pull request as ready for review September 7, 2023 23:51
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Sep 8, 2023
@ewbankkit
Copy link
Contributor

@mbbush Thanks for the contribution 🎉 👏.
As I was unable to push to this fork I merged via #33380.

@mbbush
Copy link
Contributor Author

mbbush commented Sep 11, 2023

Thank you @ewbankkit! I like all your edits, and I'm thrilled this was able to be merged promptly.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/iot Issues and PRs that pertain to the iot service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_iot_topic_rule can't update kafka action
2 participants