Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Source: azurerm_network_service_tags - add name property #23382

Merged
merged 1 commit into from Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/services/network/network_service_tags_data_source.go
Expand Up @@ -33,6 +33,11 @@ func dataSourceNetworkServiceTags() *pluginsdk.Resource {
Required: true,
},

"name": {
Type: pluginsdk.TypeString,
Computed: true,
},

"location_filter": commonschema.LocationOptional(),

"address_prefixes": {
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions internal/services/network/network_service_tags_data_source_test.go
Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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"
}`
}
2 changes: 2 additions & 0 deletions website/docs/d/network_service_tags.html.markdown
Expand Up @@ -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)
Expand Down