Skip to content

Commit

Permalink
azurerm_app_service - adding support for HTTP2
Browse files Browse the repository at this point in the history
```
$ acctests azurerm TestAccAzureRMAppService_http2Enabled
=== RUN   TestAccAzureRMAppService_http2Enabled
--- PASS: TestAccAzureRMAppService_http2Enabled (98.54s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	98.568s
```
  • Loading branch information
tombuildsstuff committed Apr 14, 2018
1 parent f65f01f commit 2cdb9bb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
14 changes: 14 additions & 0 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func resourceArmAppService() *schema.Resource {
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},

"http2_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"java_version": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -597,6 +603,10 @@ func expandAppServiceSiteConfig(d *schema.ResourceData) web.SiteConfig {
siteConfig.JavaContainerVersion = utils.String(v.(string))
}

if v, ok := config["http2_enabled"]; ok {
siteConfig.HTTP20Enabled = utils.Bool(v.(bool))
}

if v, ok := config["local_mysql_enabled"]; ok {
siteConfig.LocalMySQLEnabled = utils.Bool(v.(bool))
}
Expand Down Expand Up @@ -678,6 +688,10 @@ func flattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} {
result["local_mysql_enabled"] = *input.LocalMySQLEnabled
}

if input.HTTP20Enabled != nil {
result["http2_enabled"] = *input.HTTP20Enabled
}

result["managed_pipeline_mode"] = string(input.ManagedPipelineMode)

if input.PhpVersion != nil {
Expand Down
52 changes: 52 additions & 0 deletions azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ func TestAccAzureRMAppService_32Bit(t *testing.T) {
})
}

func TestAccAzureRMAppService_http2Enabled(t *testing.T) {
resourceName := "azurerm_app_service.test"
ri := acctest.RandInt()
config := testAccAzureRMAppService_http2Enabled(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.http2_enabled", "true"),
),
},
},
})
}

func TestAccAzureRMAppService_alwaysOn(t *testing.T) {
resourceName := "azurerm_app_service.test"
ri := acctest.RandInt()
Expand Down Expand Up @@ -909,6 +930,37 @@ resource "azurerm_app_service" "test" {
`, rInt, location, rInt, rInt)
}

func testAccAzureRMAppService_http2Enabled(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 {
http2_enabled = true
}
}
`, rInt, location, rInt, rInt)
}

func testAccAzureRMAppService_appSettings(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ The following arguments are supported:

* `https_only` - (Optional) Can the App Service only be accessed via HTTPS? Defaults to `false`. Changing this forces a new resource to be created.

* `http2_enabled` - (Optional) Is HTTP2 Enabled on this App Service? Defaults to `false`. Changing this forces a new resource to be created.

* `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.
Expand Down

0 comments on commit 2cdb9bb

Please sign in to comment.