From 75f666ce8e30d0c3a98a86d14b3c9229728ffebb Mon Sep 17 00:00:00 2001 From: magodo Date: Wed, 28 Oct 2020 10:53:21 +0800 Subject: [PATCH 1/2] `azurerm_log_analytics_solution` - add support of `tags` --- .../loganalytics/log_analytics_solution_resource.go | 7 ++++++- .../tests/log_analytics_solution_resource_test.go | 4 ++++ website/docs/r/log_analytics_solution.html.markdown | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/loganalytics/log_analytics_solution_resource.go b/azurerm/internal/services/loganalytics/log_analytics_solution_resource.go index 279dd6d26ccf..7d3015f04d39 100644 --- a/azurerm/internal/services/loganalytics/log_analytics_solution_resource.go +++ b/azurerm/internal/services/loganalytics/log_analytics_solution_resource.go @@ -6,6 +6,8 @@ import ( "strings" "time" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -89,6 +91,8 @@ func resourceArmLogAnalyticsSolution() *schema.Resource { }, }, }, + + "tags": tags.Schema(), }, } } @@ -130,6 +134,7 @@ func resourceArmLogAnalyticsSolutionCreateUpdate(d *schema.ResourceData, meta in Properties: &operationsmanagement.SolutionProperties{ WorkspaceResourceID: utils.String(workspaceID), }, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } future, err := client.CreateOrUpdate(ctx, resGroup, name, parameters) @@ -207,7 +212,7 @@ func resourceArmLogAnalyticsSolutionRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting `plan`: %+v", err) } - return nil + return tags.FlattenAndSet(d, resp.Tags) } func resourceArmLogAnalyticsSolutionDelete(d *schema.ResourceData, meta interface{}) error { diff --git a/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go b/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go index 72864d6d23eb..152bf0c30d6d 100644 --- a/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go +++ b/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go @@ -153,6 +153,10 @@ resource "azurerm_log_analytics_solution" "test" { publisher = "Microsoft" product = "OMSGallery/ContainerInsights" } + + tags = { + environment = "Test" + } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } diff --git a/website/docs/r/log_analytics_solution.html.markdown b/website/docs/r/log_analytics_solution.html.markdown index d5efda43f89d..2a987adcf447 100644 --- a/website/docs/r/log_analytics_solution.html.markdown +++ b/website/docs/r/log_analytics_solution.html.markdown @@ -64,6 +64,8 @@ The following arguments are supported: * `plan` - (Required) A `plan` block as documented below. +* `tags` - (Optional) A mapping of tags to assign to the resource. + --- A `plan` block includes: From 9ab42ab56414ae1430b5890e2ce438a7827ccfa7 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 28 Oct 2020 12:54:53 -0700 Subject: [PATCH 2/2] Update azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go --- .../loganalytics/tests/log_analytics_solution_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go b/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go index 152bf0c30d6d..fdbcdcd69f58 100644 --- a/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go +++ b/azurerm/internal/services/loganalytics/tests/log_analytics_solution_resource_test.go @@ -155,7 +155,7 @@ resource "azurerm_log_analytics_solution" "test" { } tags = { - environment = "Test" + Environment = "Test" } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger)