From d7a7eb46442fab8318dc63a3ea2bcf22a130adb9 Mon Sep 17 00:00:00 2001 From: stack72 Date: Mon, 18 Jan 2016 17:47:37 +0000 Subject: [PATCH] Adds an acceptance test to the ARM Availability Set to show that tagging and updating of tags work as expected Also updated the documentation for azure rm availability set to demonstrate this --- .../resource_arm_availability_set_test.go | 67 +++++++++++++++++++ .../azurerm/r/availability_set.html.markdown | 5 ++ 2 files changed, 72 insertions(+) diff --git a/builtin/providers/azurerm/resource_arm_availability_set_test.go b/builtin/providers/azurerm/resource_arm_availability_set_test.go index edbaf2589..fb392795f 100644 --- a/builtin/providers/azurerm/resource_arm_availability_set_test.go +++ b/builtin/providers/azurerm/resource_arm_availability_set_test.go @@ -32,6 +32,40 @@ func TestAccAzureRMAvailabilitySet_basic(t *testing.T) { }) } +func TestAccAzureRMAvailabilitySet_withTags(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAvailabilitySetDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAzureRMVAvailabilitySet_withTags, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAvailabilitySetExists("azurerm_availability_set.test"), + resource.TestCheckResourceAttr( + "azurerm_availability_set.test", "tags.#", "2"), + resource.TestCheckResourceAttr( + "azurerm_availability_set.test", "tags.environment", "Production"), + resource.TestCheckResourceAttr( + "azurerm_availability_set.test", "tags.cost_center", "MSFT"), + ), + }, + + resource.TestStep{ + Config: testAccAzureRMVAvailabilitySet_withUpdatedTags, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAvailabilitySetExists("azurerm_availability_set.test"), + resource.TestCheckResourceAttr( + "azurerm_availability_set.test", "tags.#", "1"), + resource.TestCheckResourceAttr( + "azurerm_availability_set.test", "tags.environment", "staging"), + ), + }, + }, + }) +} + func TestAccAzureRMAvailabilitySet_withDomainCounts(t *testing.T) { resource.Test(t, resource.TestCase{ @@ -121,6 +155,39 @@ resource "azurerm_availability_set" "test" { } ` +var testAccAzureRMVAvailabilitySet_withTags = ` +resource "azurerm_resource_group" "test" { + name = "acceptanceTestResourceGroup1" + location = "West US" +} +resource "azurerm_availability_set" "test" { + name = "acceptanceTestAvailabilitySet1" + location = "West US" + resource_group_name = "${azurerm_resource_group.test.name}" + + tags { + environment = "Production" + cost_center = "MSFT" + } +} +` + +var testAccAzureRMVAvailabilitySet_withUpdatedTags = ` +resource "azurerm_resource_group" "test" { + name = "acceptanceTestResourceGroup1" + location = "West US" +} +resource "azurerm_availability_set" "test" { + name = "acceptanceTestAvailabilitySet1" + location = "West US" + resource_group_name = "${azurerm_resource_group.test.name}" + + tags { + environment = "staging" + } +} +` + var testAccAzureRMVAvailabilitySet_withDomainCounts = ` resource "azurerm_resource_group" "test" { name = "acceptanceTestResourceGroup1" diff --git a/website/source/docs/providers/azurerm/r/availability_set.html.markdown b/website/source/docs/providers/azurerm/r/availability_set.html.markdown index 84064aacf..cd60368d0 100644 --- a/website/source/docs/providers/azurerm/r/availability_set.html.markdown +++ b/website/source/docs/providers/azurerm/r/availability_set.html.markdown @@ -22,6 +22,10 @@ resource "azurerm_availability_set" "test" { name = "acceptanceTestAvailabilitySet1" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" + + tags { + environment = "Production" + } } ``` @@ -40,6 +44,7 @@ The following arguments are supported: * `platform_update_domain_count` - (Optional) Specifies the number of update domains that are used. Defaults to 5. * `platform_fault_domain_count` - (Optional) Specifies the number of fault domains that are used. Defaults to 3. +* `tags` - (Optional) A mapping of tags to assign to the resource. ## Attributes Reference