diff --git a/internal/services/orbital/contact_profile_resource.go b/internal/services/orbital/contact_profile_resource.go index f5d94a097026..2e45ca281dc5 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), @@ -260,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), diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index 5c1f20249c7e..d06843396ae8 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -233,6 +233,16 @@ 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 = data.azuread_service_principal.test.object_id +} + resource "azurerm_orbital_contact_profile" "test" { name = "testcontactprofile-%d" resource_group_name = azurerm_resource_group.test.name @@ -246,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" @@ -260,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) }