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

azurerm_monitor_action_group - fix event_hub_receiver when dependent event_hub is not in the same resource group #17335

Merged
merged 5 commits into from
Sep 9, 2022

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Jun 22, 2022

fix #17091

  • In terraform config, when the azurerm_monitor_action_group and its dependency azurerm_event_hub are in different resource groups. A terraform plan command right after terraform apply will still show changes exist. This bug happened by replace event_hub_name, event_hub_namespace ,and subscription_id with event_hub_id in terraform schema, and when perform Read() function, use the Action Group's resource group to construct the event_hub_id and then write it to the state (see source code), but event_hub_id has a different resource group.
  • To fix this, use seperate properties(event_hub_name, event_hub_namespace ,and subscription_id) in terraform schema which is same with REST API.
  • see also: original PR, swagger file
Test Result
TF_ACC=1 go test -v ./internal/services/monitor -run=TestAccMonitorActionGroup_ -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccMonitorActionGroup_basic
=== PAUSE TestAccMonitorActionGroup_basic
=== RUN   TestAccMonitorActionGroup_requiresImport
=== PAUSE TestAccMonitorActionGroup_requiresImport
=== RUN   TestAccMonitorActionGroup_emailReceiver
=== PAUSE TestAccMonitorActionGroup_emailReceiver
=== RUN   TestAccMonitorActionGroup_itsmReceiver
=== PAUSE TestAccMonitorActionGroup_itsmReceiver
=== RUN   TestAccMonitorActionGroup_azureAppPushReceiver
=== PAUSE TestAccMonitorActionGroup_azureAppPushReceiver
=== RUN   TestAccMonitorActionGroup_smsReceiver
=== PAUSE TestAccMonitorActionGroup_smsReceiver
=== RUN   TestAccMonitorActionGroup_webhookReceiver
=== PAUSE TestAccMonitorActionGroup_webhookReceiver
=== RUN   TestAccMonitorActionGroup_automationRunbookReceiver
=== PAUSE TestAccMonitorActionGroup_automationRunbookReceiver
=== RUN   TestAccMonitorActionGroup_voiceReceiver
=== PAUSE TestAccMonitorActionGroup_voiceReceiver
=== RUN   TestAccMonitorActionGroup_logicAppReceiver
=== PAUSE TestAccMonitorActionGroup_logicAppReceiver
=== RUN   TestAccMonitorActionGroup_azureFunctionReceiver
=== PAUSE TestAccMonitorActionGroup_azureFunctionReceiver
=== RUN   TestAccMonitorActionGroup_armRoleReceiver
=== PAUSE TestAccMonitorActionGroup_armRoleReceiver
=== RUN   TestAccMonitorActionGroup_eventHubReceiver
=== PAUSE TestAccMonitorActionGroup_eventHubReceiver
=== RUN   TestAccMonitorActionGroup_complete
=== PAUSE TestAccMonitorActionGroup_complete
=== RUN   TestAccMonitorActionGroup_disabledUpdate
=== PAUSE TestAccMonitorActionGroup_disabledUpdate
=== RUN   TestAccMonitorActionGroup_singleReceiverUpdate
=== PAUSE TestAccMonitorActionGroup_singleReceiverUpdate
=== RUN   TestAccMonitorActionGroup_multipleReceiversUpdate
=== PAUSE TestAccMonitorActionGroup_multipleReceiversUpdate
=== CONT  TestAccMonitorActionGroup_basic
=== CONT  TestAccMonitorActionGroup_logicAppReceiver
=== CONT  TestAccMonitorActionGroup_smsReceiver
=== CONT  TestAccMonitorActionGroup_multipleReceiversUpdate
--- PASS: TestAccMonitorActionGroup_smsReceiver (176.22s)
=== CONT  TestAccMonitorActionGroup_singleReceiverUpdate
--- PASS: TestAccMonitorActionGroup_basic (177.45s)
=== CONT  TestAccMonitorActionGroup_disabledUpdate
--- PASS: TestAccMonitorActionGroup_logicAppReceiver (188.07s)
=== CONT  TestAccMonitorActionGroup_complete
--- PASS: TestAccMonitorActionGroup_multipleReceiversUpdate (437.50s)
=== CONT  TestAccMonitorActionGroup_eventHubReceiver
--- PASS: TestAccMonitorActionGroup_disabledUpdate (271.34s)
=== CONT  TestAccMonitorActionGroup_armRoleReceiver
--- PASS: TestAccMonitorActionGroup_complete (366.55s)
=== CONT  TestAccMonitorActionGroup_azureFunctionReceiver
--- PASS: TestAccMonitorActionGroup_armRoleReceiver (154.52s)
=== CONT  TestAccMonitorActionGroup_automationRunbookReceiver
--- PASS: TestAccMonitorActionGroup_eventHubReceiver (260.93s)
=== CONT  TestAccMonitorActionGroup_voiceReceiver
--- PASS: TestAccMonitorActionGroup_azureFunctionReceiver (218.85s)
=== CONT  TestAccMonitorActionGroup_webhookReceiver
--- PASS: TestAccMonitorActionGroup_automationRunbookReceiver (206.60s)
=== CONT  TestAccMonitorActionGroup_requiresImport
=== CONT  TestAccMonitorActionGroup_azureAppPushReceiver
--- PASS: TestAccMonitorActionGroup_voiceReceiver (142.67s)
--- PASS: TestAccMonitorActionGroup_webhookReceiver (88.95s)
=== CONT  TestAccMonitorActionGroup_itsmReceiver
--- PASS: TestAccMonitorActionGroup_azureAppPushReceiver (96.10s)
=== CONT  TestAccMonitorActionGroup_emailReceiver
--- PASS: TestAccMonitorActionGroup_requiresImport (172.85s)
--- PASS: TestAccMonitorActionGroup_itsmReceiver (212.75s)
--- PASS: TestAccMonitorActionGroup_emailReceiver (156.27s)
--- PASS: TestAccMonitorActionGroup_singleReceiverUpdate (1208.86s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/monitor       1385.119s

@teowa teowa changed the title Fix azurerm_monitor_action_group event_hub_receiver azurerm_monitor_action_group - fix event_hub_receiver when dependent event_hub is not in the same resource group Aug 18, 2022
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

How does the service know what eventhub to use as cannot you not have eventhubs with the same name in 2 different resource groups? if you create a test with the same named eventhub in two different resource groups what happens then?

@teowa
Copy link
Contributor Author

teowa commented Aug 22, 2022

How does the service know what eventhub to use as cannot you not have eventhubs with the same name in 2 different resource groups? if you create a test with the same named eventhub in two different resource groups what happens then?

Hi @katbyte , thanks for review, the eventhub ID is like /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventHub/namespaces/namespace1/eventhubs/eventhub1, in which the eventhub namespace name (e.g. namespace1) is unique. From doc, eventhub namespace is used to concat a domain name(//<my namespace>.servicebus.windows.net):
image I also test that we cannot create same named eventhub namespace in two different subscription.

So with event_hub_namespace and event_hub_name, service can comfirm a specific eventhub. It is ok for same named eventhub in two different resource groups (in two different namespace), it is also OK for same named eventhub in same resource group but in two different eventhub namespaces.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

👍

Have some test failures to fix and then this should be good:
image

@teowa
Copy link
Contributor Author

teowa commented Aug 31, 2022

I have submitted another PR #18190 to fix the failed tests.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 🚜

@katbyte katbyte merged commit 65fc056 into hashicorp:main Sep 9, 2022
@github-actions github-actions bot added this to the v3.22.0 milestone Sep 9, 2022
@github-actions
Copy link

github-actions bot commented Sep 9, 2022

This functionality has been released in v3.22.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@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 contributions.
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 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azurerm_monitor_action_group_data_source constructs incorrect event_hub_id
2 participants