From 74fd78c885999339e6c3dc2dacf48e356d5e0915 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 26 Sep 2023 11:20:09 +0800 Subject: [PATCH] add name property for network service tag --- .../network_service_tags_data_source.go | 7 +++++ .../network_service_tags_data_source_test.go | 28 +++++++++++++++++++ .../docs/d/network_service_tags.html.markdown | 2 ++ 3 files changed, 37 insertions(+) diff --git a/internal/services/network/network_service_tags_data_source.go b/internal/services/network/network_service_tags_data_source.go index f4b953b8133d..94c20e1682ce 100644 --- a/internal/services/network/network_service_tags_data_source.go +++ b/internal/services/network/network_service_tags_data_source.go @@ -33,6 +33,11 @@ func dataSourceNetworkServiceTags() *pluginsdk.Resource { Required: true, }, + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "location_filter": commonschema.LocationOptional(), "address_prefixes": { @@ -91,6 +96,8 @@ func dataSourceNetworkServiceTagsRead(d *pluginsdk.ResourceData, meta interface{ } if location.NormalizeNilable(props.Region) == locationFilter { + d.Set("name", value.Name) + addressPrefixes := make([]string, 0) if props.AddressPrefixes != nil { addressPrefixes = *props.AddressPrefixes diff --git a/internal/services/network/network_service_tags_data_source_test.go b/internal/services/network/network_service_tags_data_source_test.go index 7cbf21ac7574..ffee8e37412e 100644 --- a/internal/services/network/network_service_tags_data_source_test.go +++ b/internal/services/network/network_service_tags_data_source_test.go @@ -20,6 +20,25 @@ func TestAccDataSourceAzureRMServiceTags_basic(t *testing.T) { { Config: r.basic(), Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("name").Exists(), + check.That(data.ResourceName).Key("address_prefixes.#").Exists(), + check.That(data.ResourceName).Key("ipv4_cidrs.#").Exists(), + check.That(data.ResourceName).Key("ipv6_cidrs.#").Exists(), + ), + }, + }) +} + +func TestAccDataSourceAzureRMServiceTags_tagName(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_network_service_tags", "test") + r := NetworkServiceTagsDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.tagName(), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("id").HasValue("westus2-Storage"), + check.That(data.ResourceName).Key("name").HasValue("Storage.WestUS2"), check.That(data.ResourceName).Key("address_prefixes.#").Exists(), check.That(data.ResourceName).Key("ipv4_cidrs.#").Exists(), check.That(data.ResourceName).Key("ipv6_cidrs.#").Exists(), @@ -36,6 +55,7 @@ func TestAccDataSourceAzureRMServiceTags_region(t *testing.T) { { Config: r.region(), Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("name").Exists(), check.That(data.ResourceName).Key("address_prefixes.#").Exists(), check.That(data.ResourceName).Key("ipv4_cidrs.#").Exists(), check.That(data.ResourceName).Key("ipv6_cidrs.#").Exists(), @@ -58,3 +78,11 @@ func (NetworkServiceTagsDataSource) region() string { location_filter = "australiacentral" }` } + +func (NetworkServiceTagsDataSource) tagName() string { + return `data "azurerm_network_service_tags" "test" { + location = "westus2" + service = "Storage" + location_filter = "westus2" +}` +} diff --git a/website/docs/d/network_service_tags.html.markdown b/website/docs/d/network_service_tags.html.markdown index c554a10fc2f8..c7d145c73501 100644 --- a/website/docs/d/network_service_tags.html.markdown +++ b/website/docs/d/network_service_tags.html.markdown @@ -46,6 +46,8 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of this Service Tags block. +* `name` - The name of this Service Tags block. + * `address_prefixes` - List of address prefixes for the service type (and optionally a specific region). * `ipv4_cidrs` - List of IPv4 addresses for the service type (and optionally a specific region)