Skip to content

Commit

Permalink
azurerm_log_analytics_solution - add support of tags (#9048)
Browse files Browse the repository at this point in the history
Co-authored-by: kt <[email protected]>

Fixes #8751
  • Loading branch information
magodo authored Oct 29, 2020
1 parent 7cf63e3 commit 22babdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -89,6 +91,8 @@ func resourceArmLogAnalyticsSolution() *schema.Resource {
},
},
},

"tags": tags.Schema(),
},
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/log_analytics_solution.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 22babdc

Please sign in to comment.