From 545f2f2780f54a8f6ea821b63f6d1b8e6d3b9576 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 16 Jul 2018 12:40:08 +0300 Subject: [PATCH] resource/app_service: Add support for running Containers (#1578) Fixes: #580 --- azurerm/helpers/schema/app_service.go | 13 +++++ azurerm/resource_arm_app_service_test.go | 60 +++++++++++++++++++++++- website/docs/d/app_service.html.markdown | 2 + website/docs/r/app_service.html.markdown | 5 +- 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/azurerm/helpers/schema/app_service.go b/azurerm/helpers/schema/app_service.go index 95d4f13fb31d..2c6ada7da5ab 100644 --- a/azurerm/helpers/schema/app_service.go +++ b/azurerm/helpers/schema/app_service.go @@ -179,6 +179,11 @@ func AppServiceSiteConfigSchema() *schema.Schema { string(web.FtpsOnly), }, false), }, + "linux_fx_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, }, }, } @@ -225,6 +230,10 @@ func ExpandAppServiceSiteConfig(input interface{}) web.SiteConfig { siteConfig.JavaContainerVersion = utils.String(v.(string)) } + if v, ok := config["linux_fx_version"]; ok { + siteConfig.LinuxFxVersion = utils.String(v.(string)) + } + if v, ok := config["http2_enabled"]; ok { siteConfig.HTTP20Enabled = utils.Bool(v.(bool)) } @@ -394,6 +403,10 @@ func FlattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} { result["websockets_enabled"] = *input.WebSocketsEnabled } + if input.LinuxFxVersion != nil { + result["linux_fx_version"] = *input.LinuxFxVersion + } + result["scm_type"] = string(input.ScmType) result["ftps_state"] = string(input.FtpsState) diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index 6f6fc1404406..ca3930a3b8b5 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -813,7 +813,6 @@ func TestAccAzureRMAppService_ftpsState(t *testing.T) { resourceName := "azurerm_app_service.test" ri := acctest.RandInt() config := testAccAzureRMAppService_ftpsState(ri, testLocation()) - resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -830,6 +829,29 @@ func TestAccAzureRMAppService_ftpsState(t *testing.T) { }) } +func TestAccAzureRMAppService_linuxFxVersion(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_linuxFxVersion(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, "site_config.0.always_on", "true"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.linux_fx_version", "DOCKER|(golang:latest)"), + resource.TestCheckResourceAttr(resourceName, "app_settings.WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false"), + ), + }, + }, + }) +} + func testCheckAzureRMAppServiceDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).appServicesClient @@ -1747,3 +1769,39 @@ resource "azurerm_app_service" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMAppService_linuxFxVersion(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}" + + site_config { + always_on = true + linux_fx_version = "DOCKER|(golang:latest)" + } + + app_settings { + "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false" + } +} +`, rInt, location, rInt, rInt) +} diff --git a/website/docs/d/app_service.html.markdown b/website/docs/d/app_service.html.markdown index 992ce512638e..a4a6462ecae0 100644 --- a/website/docs/d/app_service.html.markdown +++ b/website/docs/d/app_service.html.markdown @@ -101,6 +101,8 @@ output "app_service_id" { * `ftps_state` - State of FTP / FTPS service for this AppService. +* `linux_fx_version` - Linux App Framework and version for the AppService. + --- `ip_restriction` exports the following: diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 3e14495f4379..6330b2dd5cf4 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -173,10 +173,13 @@ The following arguments are supported: * `remote_debugging_version` - (Optional) Which version of Visual Studio should the Remote Debugger be compatible with? Possible values are `VS2012`, `VS2013`, `VS2015` and `VS2017`. * `scm_type` - (Optional) The type of Source Control enabled for this App Service. Possible values include `None` and `LocalGit`. Defaults to `None`. * `use_32_bit_worker_process` - (Optional) Should the App Service run in 32 bit mode, rather than 64 bit mode? -* `ftps_state` - (Optional) State of FTP / FTPS service for this AppService. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`. ~> **NOTE:** when using an App Service Plan in the `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. +* `ftps_state` - (Optional) State of FTP / FTPS service for this AppService. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`. + +* `linux_fx_version` - (Optional) Linux App Framework and version for the AppService, e.g. `DOCKER|(golang:latest)`. + * `websockets_enabled` - (Optional) Should WebSockets be enabled? ~> **NOTE:** Additional Source Control types will be added in the future, once support for them has been added in the Azure SDK for Go.