From 0ba4ba3d393bb0a76df7a48b2d5013f4ed813ddf Mon Sep 17 00:00:00 2001 From: jbinko Date: Wed, 17 Jun 2020 00:04:49 +0200 Subject: [PATCH 1/4] app_service_environment resource - allow for the argument --- .../web/app_service_environment_resource.go | 5 +++++ .../docs/r/app_service_environment.html.markdown | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/azurerm/internal/services/web/app_service_environment_resource.go b/azurerm/internal/services/web/app_service_environment_resource.go index 295a5b2eb568..f13bf9f41282 100644 --- a/azurerm/internal/services/web/app_service_environment_resource.go +++ b/azurerm/internal/services/web/app_service_environment_resource.go @@ -24,6 +24,10 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) +const ( + InternalLoadBalancingModeWebPublishing web.InternalLoadBalancingMode = "Web, Publishing" +) + func resourceArmAppServiceEnvironment() *schema.Resource { return &schema.Resource{ Create: resourceArmAppServiceEnvironmentCreate, @@ -66,6 +70,7 @@ func resourceArmAppServiceEnvironment() *schema.Resource { string(web.InternalLoadBalancingModeNone), string(web.InternalLoadBalancingModePublishing), string(web.InternalLoadBalancingModeWeb), + string(InternalLoadBalancingModeWebPublishing), }, false), }, diff --git a/website/docs/r/app_service_environment.html.markdown b/website/docs/r/app_service_environment.html.markdown index 033eafe99d14..eb66de6ecf66 100644 --- a/website/docs/r/app_service_environment.html.markdown +++ b/website/docs/r/app_service_environment.html.markdown @@ -41,11 +41,12 @@ resource "azurerm_subnet" "gateway" { } resource "azurerm_app_service_environment" "example" { - name = "example-ase" - subnet_id = azurerm_subnet.ase.id - pricing_tier = "I2" - front_end_scale_factor = 10 - user_whitelisted_ip_ranges = ["11.22.33.44/32", "55.66.77.0/24"] + name = "example-ase" + subnet_id = azurerm_subnet.ase.id + pricing_tier = "I2" + front_end_scale_factor = 10 + internal_load_balancing_mode = "Web, Publishing" + user_whitelisted_ip_ranges = ["11.22.33.44/32", "55.66.77.0/24"] } ``` @@ -58,7 +59,9 @@ resource "azurerm_app_service_environment" "example" { ~> **NOTE** a /24 or larger CIDR is required. Once associated with an ASE this size cannot be changed. -* `internal_load_balancing_mode` - (Optional) Specifies which endpoints to serve internally in the Virtual Network for the App Service Environment. Possible values are `None`, `Web` and `Publishing`. Defaults to `None`. +* `internal_load_balancing_mode` - (Optional) Specifies which endpoints to serve internally in the Virtual Network for the App Service Environment. Possible values are `None`, `Web`, `Publishing` and combined value `"Web, Publishing"`. Defaults to `None`. + +~> **NOTE** You should prefer to select value either `None` or combined value `"Web, Publishing"` as the other values might become deprecated in the future. * `pricing_tier` - (Optional) Pricing tier for the front end instances. Possible values are `I1`, `I2` and `I3`. Defaults to `I1`. From d26d322d747e4a05bdd3eba9c008085b5428a07b Mon Sep 17 00:00:00 2001 From: jbinko Date: Mon, 22 Jun 2020 18:05:03 +0200 Subject: [PATCH 2/4] Added - ForceNew: true for internal_load_balancing_mode --- .../internal/services/web/app_service_environment_resource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/internal/services/web/app_service_environment_resource.go b/azurerm/internal/services/web/app_service_environment_resource.go index f13bf9f41282..e55d689975e4 100644 --- a/azurerm/internal/services/web/app_service_environment_resource.go +++ b/azurerm/internal/services/web/app_service_environment_resource.go @@ -65,6 +65,7 @@ func resourceArmAppServiceEnvironment() *schema.Resource { "internal_load_balancing_mode": { Type: schema.TypeString, Optional: true, + ForceNew: true, Default: string(web.InternalLoadBalancingModeNone), ValidateFunc: validation.StringInSlice([]string{ string(web.InternalLoadBalancingModeNone), From 9a640fb8b7957cb6f4eb160c7c7ea0843d931393 Mon Sep 17 00:00:00 2001 From: jbinko Date: Tue, 23 Jun 2020 00:11:35 +0200 Subject: [PATCH 3/4] Added unit test for internal_load_balancing_mode attribute --- .../app_service_environment_resource_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/azurerm/internal/services/web/tests/app_service_environment_resource_test.go b/azurerm/internal/services/web/tests/app_service_environment_resource_test.go index 3828fc8ed968..fe2e2e431a62 100644 --- a/azurerm/internal/services/web/tests/app_service_environment_resource_test.go +++ b/azurerm/internal/services/web/tests/app_service_environment_resource_test.go @@ -379,3 +379,39 @@ resource "azurerm_subnet" "gateway" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func TestAccAzureRMAppServiceEnvironment_internalLoadBalancer(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMAppServiceEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAppServiceEnvironment_internalLoadBalancerAndWhitelistedIpRanges(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceEnvironmentExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "internal_load_balancing_mode", "Web, Publishing"), + ), + }, + data.ImportStep(), + }, + }) +} + +func testAccAzureRMAppServiceEnvironment_internalLoadBalancerAndWhitelistedIpRanges(data acceptance.TestData) string { + template := testAccAzureRMAppServiceEnvironment_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_app_service_environment" "test" { + name = "acctest-ase-%d" + subnet_id = azurerm_subnet.ase.id + pricing_tier = "I1" + front_end_scale_factor = 5 + internal_load_balancing_mode = "Web, Publishing" + user_whitelisted_ip_ranges = ["11.22.33.44/32", "55.66.77.0/24"] +} +`, template, data.RandomInteger) +} From 8e4434feabcc9aab7f6bcabcb4fded763d4940df Mon Sep 17 00:00:00 2001 From: jbinko Date: Tue, 23 Jun 2020 09:43:20 +0200 Subject: [PATCH 4/4] Removal of possible deprecation note, moving test definition to match code layout --- .../app_service_environment_resource_test.go | 40 +++++++++---------- .../r/app_service_environment.html.markdown | 2 - 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/azurerm/internal/services/web/tests/app_service_environment_resource_test.go b/azurerm/internal/services/web/tests/app_service_environment_resource_test.go index fe2e2e431a62..94b571467460 100644 --- a/azurerm/internal/services/web/tests/app_service_environment_resource_test.go +++ b/azurerm/internal/services/web/tests/app_service_environment_resource_test.go @@ -159,6 +159,26 @@ func TestAccAzureRMAppServiceEnvironment_withCertificatePfx(t *testing.T) { }) } +func TestAccAzureRMAppServiceEnvironment_internalLoadBalancer(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMAppServiceEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAppServiceEnvironment_internalLoadBalancerAndWhitelistedIpRanges(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceEnvironmentExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "internal_load_balancing_mode", "Web, Publishing"), + ), + }, + data.ImportStep(), + }, + }) +} + func testCheckAzureRMAppServiceEnvironmentExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { client := acceptance.AzureProvider.Meta().(*clients.Client).Web.AppServiceEnvironmentsClient @@ -380,26 +400,6 @@ resource "azurerm_subnet" "gateway" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func TestAccAzureRMAppServiceEnvironment_internalLoadBalancer(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMAppServiceEnvironmentDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMAppServiceEnvironment_internalLoadBalancerAndWhitelistedIpRanges(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAppServiceEnvironmentExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "internal_load_balancing_mode", "Web, Publishing"), - ), - }, - data.ImportStep(), - }, - }) -} - func testAccAzureRMAppServiceEnvironment_internalLoadBalancerAndWhitelistedIpRanges(data acceptance.TestData) string { template := testAccAzureRMAppServiceEnvironment_template(data) return fmt.Sprintf(` diff --git a/website/docs/r/app_service_environment.html.markdown b/website/docs/r/app_service_environment.html.markdown index eb66de6ecf66..5b3a7b5a2446 100644 --- a/website/docs/r/app_service_environment.html.markdown +++ b/website/docs/r/app_service_environment.html.markdown @@ -61,8 +61,6 @@ resource "azurerm_app_service_environment" "example" { * `internal_load_balancing_mode` - (Optional) Specifies which endpoints to serve internally in the Virtual Network for the App Service Environment. Possible values are `None`, `Web`, `Publishing` and combined value `"Web, Publishing"`. Defaults to `None`. -~> **NOTE** You should prefer to select value either `None` or combined value `"Web, Publishing"` as the other values might become deprecated in the future. - * `pricing_tier` - (Optional) Pricing tier for the front end instances. Possible values are `I1`, `I2` and `I3`. Defaults to `I1`. * `front_end_scale_factor` - (Optional) Scale factor for front end instances. Possible values are between `5` and `15`. Defaults to `15`.