From 196dc3a8c7285fe2a448a9b5f38b4b82daf33da4 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:38:18 +0800 Subject: [PATCH] `azurerm_orbital_contact_profile`: fix creation without `event_hub_uri` --- .../orbital/contact_profile_resource.go | 8 ++++++- .../orbital/contact_profile_resource_test.go | 22 +++++++++++++++++++ internal/services/orbital/helper.go | 1 - 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/internal/services/orbital/contact_profile_resource.go b/internal/services/orbital/contact_profile_resource.go index f5d94a0970269..3baae8c9cdd41 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), diff --git a/internal/services/orbital/contact_profile_resource_test.go b/internal/services/orbital/contact_profile_resource_test.go index 5c1f20249c7ec..2aa72fccdee95 100644 --- a/internal/services/orbital/contact_profile_resource_test.go +++ b/internal/services/orbital/contact_profile_resource_test.go @@ -49,6 +49,28 @@ func TestAccContactProfile_multipleChannels(t *testing.T) { }) } +func TestAccContactProfile_addChannel(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_orbital_contact_profile", "test") + r := ContactProfileResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.multipleChannels(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccContactProfile_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_orbital_contact_profile", "test") r := ContactProfileResource{} diff --git a/internal/services/orbital/helper.go b/internal/services/orbital/helper.go index 3b23d2a18c138..ec9a7fc28bac3 100644 --- a/internal/services/orbital/helper.go +++ b/internal/services/orbital/helper.go @@ -89,7 +89,6 @@ func ChannelSchema() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, Required: true, - ForceNew: true, MinItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*schema.Schema{