diff --git a/internal/services/search/search_service_data_source.go b/internal/services/search/search_service_data_source.go index 84f24a68fea4..8111ac0e912d 100644 --- a/internal/services/search/search_service_data_source.go +++ b/internal/services/search/search_service_data_source.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/adminkeys" "github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/querykeys" "github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/services" @@ -84,6 +85,8 @@ func dataSourceSearchService() *pluginsdk.Resource { }, "identity": commonschema.SystemAssignedIdentityComputed(), + + "tags": commonschema.TagsDataSource(), }, } } @@ -133,6 +136,10 @@ func dataSourceSearchServiceRead(d *pluginsdk.ResourceData, meta interface{}) er if err = d.Set("identity", identity.FlattenSystemAssigned(model.Identity)); err != nil { return fmt.Errorf("setting `identity`: %s", err) } + + if err := tags.FlattenAndSet(d, model.Tags); err != nil { + return fmt.Errorf("setting `tags`: %+v", err) + } } primaryKey := "" diff --git a/internal/services/search/search_service_data_source_test.go b/internal/services/search/search_service_data_source_test.go index b30c8f96858a..8b6a90886d5f 100644 --- a/internal/services/search/search_service_data_source_test.go +++ b/internal/services/search/search_service_data_source_test.go @@ -29,6 +29,7 @@ func TestAccDataSourceSearchService_basic(t *testing.T) { check.That(data.ResourceName).Key("identity.0.type").Exists(), check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), check.That(data.ResourceName).Key("identity.0.tenant_id").Exists(), + check.That(data.ResourceName).Key("tags.environment").HasValue("production"), ), }, }) @@ -54,6 +55,10 @@ resource "azurerm_search_service" "test" { identity { type = "SystemAssigned" } + + tags = { + environment = "production" + } } data "azurerm_search_service" "test" { diff --git a/website/docs/d/search_service.html.markdown b/website/docs/d/search_service.html.markdown index 5f9fbe4e7c3f..d1e0a2b8eb37 100644 --- a/website/docs/d/search_service.html.markdown +++ b/website/docs/d/search_service.html.markdown @@ -50,6 +50,8 @@ In addition to the Arguments listed above - the following Attributes are exporte * `replica_count` - The number of replica's which have been created. +* `tags` - A mapping of tags assigned to the resource. + * `identity` - An `identity` block as defined below. ---