From 5eeda57b97a06b8f5b837277efbe30682cfb0109 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:40:28 +0800 Subject: [PATCH 1/6] `azurerm_orbital_contact_profile`: fix creation without `event_hub_uri` --- internal/services/orbital/contact_profile_resource.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/services/orbital/contact_profile_resource.go b/internal/services/orbital/contact_profile_resource.go index f5d94a097026..3baae8c9cdd4 100644 --- a/internal/services/orbital/contact_profile_resource.go +++ b/internal/services/orbital/contact_profile_resource.go @@ -136,9 +136,15 @@ func (r ContactProfileResource) Create() sdk.ResourceFunc { SubnetId: model.NetworkConfigurationSubnetId, } + // The service only accept `null` or non-empty value, empty string will cause a 400 response + var eventHubUri *string + if model.EventHubUri != "" { + eventHubUri = pointer.To(model.EventHubUri) + } + contactProfilesProperties := contactprofile.ContactProfilesProperties{ AutoTrackingConfiguration: pointer.To(autoTrackingConfiguration), - EventHubUri: pointer.To(model.EventHubUri), + EventHubUri: eventHubUri, Links: links, MinimumElevationDegrees: pointer.To(model.MinimumElevationDegrees), MinimumViableContactDuration: pointer.To(model.MinimumVariableContactDuration), From 208f329779f937734eec2d9f00202aefbe5d8035 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:45:47 +0800 Subject: [PATCH 2/6] update code --- internal/services/orbital/contact_profile_resource.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/services/orbital/contact_profile_resource.go b/internal/services/orbital/contact_profile_resource.go index 3baae8c9cdd4..2e45ca281dc5 100644 --- a/internal/services/orbital/contact_profile_resource.go +++ b/internal/services/orbital/contact_profile_resource.go @@ -266,12 +266,18 @@ func (r ContactProfileResource) Update() sdk.ResourceFunc { SubnetId: state.NetworkConfigurationSubnetId, } + // The service only accept `null` or non-empty value, empty string will cause a 400 response + var eventHubUri *string + if state.EventHubUri != "" { + eventHubUri = pointer.To(state.EventHubUri) + } + if metadata.ResourceData.HasChangesExcept("name", "resource_group_name") { contactProfile := contactprofile.ContactProfile{ Location: state.Location, Properties: contactprofile.ContactProfilesProperties{ AutoTrackingConfiguration: pointer.To(autoTrackingConfiguration), - EventHubUri: pointer.To(state.EventHubUri), + EventHubUri: eventHubUri, Links: contactProfileLinks, MinimumElevationDegrees: pointer.To(state.MinimumElevationDegrees), MinimumViableContactDuration: pointer.To(state.MinimumVariableContactDuration), From 069cd53e9f0e534f01a64a4af6d590b2c310574c Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:17:45 +0800 Subject: [PATCH 3/6] update test case --- internal/services/orbital/contact_profile_resource_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index 5c1f20249c7e..4ff5147c630b 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -233,6 +233,12 @@ resource "azurerm_eventhub" "test" { message_retention = 1 } +resource "azurerm_role_assignment" "test" { + scope = azurerm_eventhub.test.id + role_definition_name = "Azure Event Hubs Data Sender" + principal_id = "4fa46669-56c9-44e7-a69b-182480b952a8" +} + resource "azurerm_orbital_contact_profile" "test" { name = "testcontactprofile-%d" resource_group_name = azurerm_resource_group.test.name From 8ebf3f6150934c0ae630cd4118f6470d19f9277b Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:07:40 +0800 Subject: [PATCH 4/6] update testcase --- internal/services/orbital/contact_profile_resource_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index 4ff5147c630b..b02a9ed515c3 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -233,10 +233,14 @@ resource "azurerm_eventhub" "test" { message_retention = 1 } +data "azuread_service_principal" "test" { + display_name = "Azure Orbital Resource Provider" +} + resource "azurerm_role_assignment" "test" { scope = azurerm_eventhub.test.id role_definition_name = "Azure Event Hubs Data Sender" - principal_id = "4fa46669-56c9-44e7-a69b-182480b952a8" + principal_id = data.azuread_service_principal.test.application_id } resource "azurerm_orbital_contact_profile" "test" { From 4b7b24f56df4b6acf3ff363dbc8cd36018579637 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:00:35 +0800 Subject: [PATCH 5/6] update test case --- internal/services/orbital/contact_profile_resource_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index b02a9ed515c3..e1dfa4a363dc 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -240,7 +240,7 @@ data "azuread_service_principal" "test" { resource "azurerm_role_assignment" "test" { scope = azurerm_eventhub.test.id role_definition_name = "Azure Event Hubs Data Sender" - principal_id = data.azuread_service_principal.test.application_id + principal_id = data.azuread_service_principal.test.object_id } resource "azurerm_orbital_contact_profile" "test" { @@ -270,6 +270,8 @@ resource "azurerm_orbital_contact_profile" "test" { polarization = "RHCP" } network_configuration_subnet_id = azurerm_subnet.test.id + + depends_on = [azurerm_role_assignment.test] } `, template, data.RandomInteger, data.RandomInteger, data.RandomInteger) } From 8b8f2c888638379031ef0e883a37da5da187bbda Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:39:53 +0800 Subject: [PATCH 6/6] update test --- internal/services/orbital/contact_profile_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index e1dfa4a363dc..d06843396ae8 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -256,7 +256,7 @@ resource "azurerm_orbital_contact_profile" "test" { name = "channelname" bandwidth_mhz = 100 center_frequency_mhz = 101 - demodulation_configuration = "na" + demodulation_configuration = "aqua_direct_broadcast" modulation_configuration = "AQUA_UPLINK_BPSK" end_point { end_point_name = "AQUA_command"