From a0d4c33732dfc9550c66862ad2c7d9a35fa2aced Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 5 Apr 2018 22:24:06 +0200 Subject: [PATCH 1/5] `azurerm_app_service` - support for `https_only` --- azurerm/resource_arm_app_service.go | 9 +++++ azurerm/resource_arm_app_service_test.go | 49 ++++++++++++++++++++++++ website/docs/r/app_service.html.markdown | 2 + 3 files changed, 60 insertions(+) diff --git a/azurerm/resource_arm_app_service.go b/azurerm/resource_arm_app_service.go index 10864b23bee0..863847cbe683 100644 --- a/azurerm/resource_arm_app_service.go +++ b/azurerm/resource_arm_app_service.go @@ -181,6 +181,12 @@ func resourceArmAppService() *schema.Resource { Computed: true, }, + "https_only": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "enabled": { Type: schema.TypeBool, Optional: true, @@ -310,6 +316,7 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error location := azureRMNormalizeLocation(d.Get("location").(string)) appServicePlanId := d.Get("app_service_plan_id").(string) enabled := d.Get("enabled").(bool) + httpsOnly := d.Get("https_only").(bool) tags := d.Get("tags").(map[string]interface{}) siteConfig := expandAppServiceSiteConfig(d) @@ -320,6 +327,7 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error SiteProperties: &web.SiteProperties{ ServerFarmID: utils.String(appServicePlanId), Enabled: utils.Bool(enabled), + HTTPSOnly: utils.Bool(httpsOnly), SiteConfig: &siteConfig, }, } @@ -501,6 +509,7 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error { d.Set("app_service_plan_id", props.ServerFarmID) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("enabled", props.Enabled) + d.Set("https_only", props.HTTPSOnly) d.Set("default_site_hostname", props.DefaultHostName) d.Set("outbound_ip_addresses", props.OutboundIPAddresses) } diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index e8333ff67546..8c5fce4d1169 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -152,6 +152,27 @@ func TestAccAzureRMAppService_alwaysOn(t *testing.T) { }) } +func TestAccAzureRMAppService_httpsOnly(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_httpsOnly(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "https_only", "true"), + ), + }, + }, + }) +} + func TestAccAzureRMAppService_appSettings(t *testing.T) { resourceName := "azurerm_app_service.test" ri := acctest.RandInt() @@ -829,6 +850,34 @@ resource "azurerm_app_service" "test" { `, rInt, location, rInt, rInt) } +func testAccAzureRMAppService_httpsOnly(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + https_only = true +} +`, rInt, location, rInt, rInt) +} + func testAccAzureRMAppService_32Bit(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index d032cf74b1c3..8991f0ef1e60 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -125,6 +125,8 @@ The following arguments are supported: * `enabled` - (Optional) Is the App Service Enabled? Changing this forces a new resource to be created. +* `https_only` - (Optional) Can the App Service only be accessed via HTTPS? Defaults to `false`. + * `site_config` - (Optional) A `site_config` object as defined below. * `tags` - (Optional) A mapping of tags to assign to the resource. Changing this forces a new resource to be created. From 6312b1528f3ad917226177032863312e8f08828b Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 5 Apr 2018 22:26:29 +0200 Subject: [PATCH 2/5] `d/app_service_plan`: support for https_only --- azurerm/data_source_app_service.go | 6 ++++++ website/docs/d/app_service.html.markdown | 2 ++ 2 files changed, 8 insertions(+) diff --git a/azurerm/data_source_app_service.go b/azurerm/data_source_app_service.go index a7278d0597ec..3073fa993fe5 100644 --- a/azurerm/data_source_app_service.go +++ b/azurerm/data_source_app_service.go @@ -118,6 +118,11 @@ func dataSourceArmAppService() *schema.Resource { Computed: true, }, + "https_only": { + Type: schema.TypeBool, + Computed: true, + }, + "enabled": { Type: schema.TypeBool, Computed: true, @@ -259,6 +264,7 @@ func dataSourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error d.Set("app_service_plan_id", props.ServerFarmID) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("enabled", props.Enabled) + d.Set("https_only", props.HTTPSOnly) d.Set("default_site_hostname", props.DefaultHostName) d.Set("outbound_ip_addresses", props.OutboundIPAddresses) } diff --git a/website/docs/d/app_service.html.markdown b/website/docs/d/app_service.html.markdown index 0e57109bcd85..fa4a54efc9c2 100644 --- a/website/docs/d/app_service.html.markdown +++ b/website/docs/d/app_service.html.markdown @@ -45,6 +45,8 @@ output "app_service_id" { * `enabled` - Is the App Service Enabled? +* `https_only` - Can the App Service only be accessed via HTTPS? + * `site_config` - A `site_config` object as defined below. * `tags` - A mapping of tags to assign to the resource. From 5c98bba4d0ac9c1357f30ee7746aa40c0732ca2f Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 5 Apr 2018 22:30:22 +0200 Subject: [PATCH 3/5] `r/app_service_slot`: support for `https_only` --- azurerm/resource_arm_app_service_slot.go | 9 +++ azurerm/resource_arm_app_service_slot_test.go | 57 +++++++++++++++++++ website/docs/r/app_service_slot.html.markdown | 2 + 3 files changed, 68 insertions(+) diff --git a/azurerm/resource_arm_app_service_slot.go b/azurerm/resource_arm_app_service_slot.go index e5e2122e370d..b7386388656d 100644 --- a/azurerm/resource_arm_app_service_slot.go +++ b/azurerm/resource_arm_app_service_slot.go @@ -190,6 +190,12 @@ func resourceArmAppServiceSlot() *schema.Resource { ForceNew: true, }, + "https_only": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "enabled": { Type: schema.TypeBool, Optional: true, @@ -265,6 +271,7 @@ func resourceArmAppServiceSlotCreate(d *schema.ResourceData, meta interface{}) e appServiceName := d.Get("app_service_name").(string) appServicePlanId := d.Get("app_service_plan_id").(string) enabled := d.Get("enabled").(bool) + httpsOnly := d.Get("https_only").(bool) tags := d.Get("tags").(map[string]interface{}) siteConfig := expandAppServiceSiteConfig(d) @@ -275,6 +282,7 @@ func resourceArmAppServiceSlotCreate(d *schema.ResourceData, meta interface{}) e SiteProperties: &web.SiteProperties{ ServerFarmID: utils.String(appServicePlanId), Enabled: utils.Bool(enabled), + HTTPSOnly: utils.Bool(httpsOnly), SiteConfig: &siteConfig, }, } @@ -426,6 +434,7 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err d.Set("app_service_plan_id", props.ServerFarmID) d.Set("client_affinity_enabled", props.ClientAffinityEnabled) d.Set("enabled", props.Enabled) + d.Set("https_only", props.HTTPSOnly) d.Set("default_site_hostname", props.DefaultHostName) } diff --git a/azurerm/resource_arm_app_service_slot_test.go b/azurerm/resource_arm_app_service_slot_test.go index cb9282daf600..ed84d8526382 100644 --- a/azurerm/resource_arm_app_service_slot_test.go +++ b/azurerm/resource_arm_app_service_slot_test.go @@ -181,6 +181,27 @@ func TestAccAzureRMAppServiceSlot_enabled(t *testing.T) { }) } +func TestAccAzureRMAppServiceSlot_httpsOnly(t *testing.T) { + resourceName := "azurerm_app_service_slot.test" + ri := acctest.RandInt() + config := testAccAzureRMAppServiceSlot_httpsOnly(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceSlotDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceSlotExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "https_only", "true"), + ), + }, + }, + }) +} + func TestAccAzureRMAppServiceSlot_localMySql(t *testing.T) { resourceName := "azurerm_app_service_slot.test" ri := acctest.RandInt() @@ -867,6 +888,42 @@ resource "azurerm_app_service_slot" "test" { `, rInt, location, rInt, rInt, rInt) } +func testAccAzureRMAppServiceSlot_httpsOnly(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" +} + +resource "azurerm_app_service_slot" "test" { + name = "acctestASSlot-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + app_service_name = "${azurerm_app_service.test.name}" + https_only = true +} +`, rInt, location, rInt, rInt, rInt) +} + func testAccAzureRMAppServiceSlot_localMySql(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index f6fffa41876f..dabf00bb04c1 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -162,6 +162,8 @@ The following arguments are supported: * `enabled` - (Optional) Is the App Service Slot Enabled? Changing this forces a new resource to be created. +* `https_only` - (Optional) Can the App Service Slot only be accessed via HTTPS? Defaults to `false`. + * `site_config` - (Optional) A `site_config` object as defined below. * `tags` - (Optional) A mapping of tags to assign to the resource. Changing this forces a new resource to be created. From 0b96ee46ca8dc44113701b1d0d00e995071407b7 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 5 Apr 2018 22:35:43 +0200 Subject: [PATCH 4/5] `r/function_app`: support for https_only --- azurerm/resource_arm_function_app.go | 6 +++ azurerm/resource_arm_function_app_test.go | 59 +++++++++++++++++++++++ website/docs/r/function_app.html.markdown | 4 +- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_function_app.go b/azurerm/resource_arm_function_app.go index a4dd7770a152..7b51d2d8e2ac 100644 --- a/azurerm/resource_arm_function_app.go +++ b/azurerm/resource_arm_function_app.go @@ -132,6 +132,12 @@ func resourceArmFunctionApp() *schema.Resource { ForceNew: true, }, + "https_only": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "site_config": { Type: schema.TypeList, Optional: true, diff --git a/azurerm/resource_arm_function_app_test.go b/azurerm/resource_arm_function_app_test.go index 0b32d22cc05f..f35f35d7f84e 100644 --- a/azurerm/resource_arm_function_app_test.go +++ b/azurerm/resource_arm_function_app_test.go @@ -255,6 +255,29 @@ func TestAccAzureRMFunctionApp_3264bit(t *testing.T) { }) } +func TestAccAzureRMFunctionApp_httpsOnly(t *testing.T) { + resourceName := "azurerm_function_app.test" + ri := acctest.RandInt() + rs := strings.ToLower(acctest.RandString(11)) + location := testLocation() + config := testAccAzureRMFunctionApp_httpsOnly(ri, rs, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMFunctionAppDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMFunctionAppExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "https_only", "true"), + ), + }, + }, + }) +} + func TestAccAzureRMFunctionApp_consumptionPlan(t *testing.T) { resourceName := "azurerm_function_app.test" ri := acctest.RandInt() @@ -683,6 +706,42 @@ resource "azurerm_function_app" "test" { `, rInt, location, rString, rInt, rInt) } +func testAccAzureRMFunctionApp_httpsOnly(rInt int, rString string, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestsa%s" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_function_app" "test" { + name = "acctest-%d-func" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + storage_connection_string = "${azurerm_storage_account.test.primary_connection_string}" + https_only = true +} +`, rInt, location, rString, rInt, rInt) +} + func testAccAzureRMFunctionApp_consumptionPlan(rInt int, rString string, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 4d9c58d4a191..10be524f012e 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -101,9 +101,11 @@ The following arguments are supported: * `connection_string` - (Optional) An `connection_string` block as defined below. +* `client_affinity_enabled` - (Optional) Should the Function App send session affinity cookies, which route client requests in the same session to the same instance? Changing this forces a new resource to be created. + * `enabled` - (Optional) Is the Function App enabled? Changing this forces a new resource to be created. -* `client_affinity_enabled` - (Optional) Should the Function App send session affinity cookies, which route client requests in the same session to the same instance? Changing this forces a new resource to be created. +* `https_only` - (Optional) Can the Function App only be accessed via HTTPS? Defaults to `false`. * `version` - (Optional) The runtime version associated with the Function App. Possible values are `~1` and `beta`. Defaults to `~1`. From e85b78db2c6b75dc5febcf134aaede32944f8eb4 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 5 Apr 2018 22:36:45 +0200 Subject: [PATCH 5/5] ForceNew-ing the fields to work around API bugs --- azurerm/resource_arm_app_service.go | 4 ++++ azurerm/resource_arm_app_service_slot.go | 4 ++++ azurerm/resource_arm_function_app.go | 4 ++++ website/docs/r/app_service.html.markdown | 2 +- website/docs/r/app_service_slot.html.markdown | 2 +- website/docs/r/function_app.html.markdown | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_app_service.go b/azurerm/resource_arm_app_service.go index 863847cbe683..1817b2c03d08 100644 --- a/azurerm/resource_arm_app_service.go +++ b/azurerm/resource_arm_app_service.go @@ -185,6 +185,10 @@ func resourceArmAppService() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + ForceNew: true, }, "enabled": { diff --git a/azurerm/resource_arm_app_service_slot.go b/azurerm/resource_arm_app_service_slot.go index b7386388656d..0b6f8cbe2529 100644 --- a/azurerm/resource_arm_app_service_slot.go +++ b/azurerm/resource_arm_app_service_slot.go @@ -194,6 +194,10 @@ func resourceArmAppServiceSlot() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + ForceNew: true, }, "enabled": { diff --git a/azurerm/resource_arm_function_app.go b/azurerm/resource_arm_function_app.go index 7b51d2d8e2ac..ae87588a1f73 100644 --- a/azurerm/resource_arm_function_app.go +++ b/azurerm/resource_arm_function_app.go @@ -136,6 +136,10 @@ func resourceArmFunctionApp() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + ForceNew: true, }, "site_config": { diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 8991f0ef1e60..7d27dc467325 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -125,7 +125,7 @@ The following arguments are supported: * `enabled` - (Optional) Is the App Service Enabled? Changing this forces a new resource to be created. -* `https_only` - (Optional) Can the App Service only be accessed via HTTPS? Defaults to `false`. +* `https_only` - (Optional) Can the App Service only be accessed via HTTPS? Defaults to `false`. Changing this forces a new resource to be created. * `site_config` - (Optional) A `site_config` object as defined below. diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index dabf00bb04c1..85913967465d 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -162,7 +162,7 @@ The following arguments are supported: * `enabled` - (Optional) Is the App Service Slot Enabled? Changing this forces a new resource to be created. -* `https_only` - (Optional) Can the App Service Slot only be accessed via HTTPS? Defaults to `false`. +* `https_only` - (Optional) Can the App Service Slot only be accessed via HTTPS? Defaults to `false`. Changing this forces a new resource to be created. * `site_config` - (Optional) A `site_config` object as defined below. diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 10be524f012e..1e056ab1be4b 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -105,7 +105,7 @@ The following arguments are supported: * `enabled` - (Optional) Is the Function App enabled? Changing this forces a new resource to be created. -* `https_only` - (Optional) Can the Function App only be accessed via HTTPS? Defaults to `false`. +* `https_only` - (Optional) Can the Function App only be accessed via HTTPS? Defaults to `false`. Changing this forces a new resource to be created. * `version` - (Optional) The runtime version associated with the Function App. Possible values are `~1` and `beta`. Defaults to `~1`.