Skip to content

Commit

Permalink
resource/app_service: Add support for running Containers (#1578)
Browse files Browse the repository at this point in the history
Fixes: #580
  • Loading branch information
stack72 authored and tombuildsstuff committed Jul 16, 2018
1 parent dcab4cc commit 545f2f2
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
13 changes: 13 additions & 0 deletions azurerm/helpers/schema/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func AppServiceSiteConfigSchema() *schema.Schema {
string(web.FtpsOnly),
}, false),
},
"linux_fx_version": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
}
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)

Expand Down
60 changes: 59 additions & 1 deletion azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions website/docs/d/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

1 comment on commit 545f2f2

@rifaterdemsahin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this means terraform now support web app for containers?

Please sign in to comment.