diff --git a/azurerm/internal/services/loganalytics/resource_arm_log_analytics_linked_service.go b/azurerm/internal/services/loganalytics/resource_arm_log_analytics_linked_service.go index a97b22fc6eda..7cf97810b9d7 100644 --- a/azurerm/internal/services/loganalytics/resource_arm_log_analytics_linked_service.go +++ b/azurerm/internal/services/loganalytics/resource_arm_log_analytics_linked_service.go @@ -58,32 +58,11 @@ func resourceArmLogAnalyticsLinkedService() *schema.Resource { }, "resource_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: azure.ValidateResourceID, - ConflictsWith: []string{"linked_service_properties.0"}, - }, - - "linked_service_properties": { - Type: schema.TypeList, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{"resource_id"}, - MaxItems: 1, - Deprecated: "This property has been deprecated in favour of the 'resource_id' property and will be removed in version 2.0 of the provider", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: azure.ValidateResourceID, - }, - }, - }, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceID, }, // Exported properties @@ -122,13 +101,6 @@ func resourceArmLogAnalyticsLinkedServiceCreateUpdate(d *schema.ResourceData, me } resourceId := d.Get("resource_id").(string) - if resourceId == "" { - props := d.Get("linked_service_properties").([]interface{}) - resourceId = expandLogAnalyticsLinkedServiceProperties(props) - if resourceId == "" { - return fmt.Errorf("A `resource_id` must be specified either using the `resource_id` field at the top level or within the `linked_service_properties` block") - } - } t := d.Get("tags").(map[string]interface{}) parameters := operationalinsights.LinkedService{ @@ -187,11 +159,6 @@ func resourceArmLogAnalyticsLinkedServiceRead(d *schema.ResourceData, meta inter d.Set("resource_id", props.ResourceID) } - linkedServiceProperties := flattenLogAnalyticsLinkedServiceProperties(resp.LinkedServiceProperties) - if err := d.Set("linked_service_properties", linkedServiceProperties); err != nil { - return fmt.Errorf("Error setting `linked_service_properties`: %+v", err) - } - return tags.FlattenAndSet(d, resp.Tags) } @@ -220,27 +187,3 @@ func resourceArmLogAnalyticsLinkedServiceDelete(d *schema.ResourceData, meta int return nil } - -func expandLogAnalyticsLinkedServiceProperties(input []interface{}) string { - if len(input) == 0 { - return "" - } - - props := input[0].(map[string]interface{}) - return props["resource_id"].(string) -} - -func flattenLogAnalyticsLinkedServiceProperties(input *operationalinsights.LinkedServiceProperties) []interface{} { - if input == nil { - return []interface{}{} - } - - properties := make(map[string]interface{}) - - // resource id linked service - if resourceID := input.ResourceID; resourceID != nil { - properties["resource_id"] = interface{}(*resourceID) - } - - return []interface{}{properties} -} diff --git a/azurerm/internal/services/loganalytics/tests/resource_arm_log_analytics_linked_service_test.go b/azurerm/internal/services/loganalytics/tests/resource_arm_log_analytics_linked_service_test.go index d2bf0d4afb05..4b5e593d18ac 100644 --- a/azurerm/internal/services/loganalytics/tests/resource_arm_log_analytics_linked_service_test.go +++ b/azurerm/internal/services/loganalytics/tests/resource_arm_log_analytics_linked_service_test.go @@ -3,7 +3,6 @@ package tests import ( "fmt" "net/http" - "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -85,43 +84,6 @@ func TestAccAzureRMLogAnalyticsLinkedService_complete(t *testing.T) { }) } -// Deprecated - remove in 2.0 -func TestAccAzureRMLogAnalyticsLinkedService_noResourceID(t *testing.T) { - data := acceptance.BuildTestData(t, "ignored", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMLogAnalyticsLinkedServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMLogAnalyticsLinkedService_noResourceID(data), - ExpectError: regexp.MustCompile("A `resource_id` must be specified either using the `resource_id` field at the top level or within the `linked_service_properties` block"), - }, - }, - }) -} - -// Deprecated - remove in 2.0 -func TestAccAzureRMLogAnalyticsLinkedService_linkedServiceProperties(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_log_analytics_linked_service", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMLogAnalyticsLinkedServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMLogAnalyticsLinkedService_linkedServiceProperties(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMLogAnalyticsLinkedServiceExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) -} - func testCheckAzureRMLogAnalyticsLinkedServiceDestroy(s *terraform.State) error { conn := acceptance.AzureProvider.Meta().(*clients.Client).LogAnalytics.LinkedServicesClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext