Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_function_app - support for ftps_state #5169

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions azurerm/resource_arm_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ func resourceArmFunctionApp() *schema.Resource {
string(web.OneFullStopTwo),
}, false),
},
"ftps_state": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(web.AllAllowed),
string(web.Disabled),
string(web.FtpsOnly),
}, false),
},
"cors": azure.SchemaWebCorsSettings(),
},
},
Expand Down Expand Up @@ -740,6 +750,10 @@ func expandFunctionAppSiteConfig(d *schema.ResourceData) web.SiteConfig {
siteConfig.MinTLSVersion = web.SupportedTLSVersions(v.(string))
}

if v, ok := config["ftps_state"]; ok {
siteConfig.FtpsState = web.FtpsState(v.(string))
}

return siteConfig
}

Expand Down Expand Up @@ -777,6 +791,7 @@ func flattenFunctionAppSiteConfig(input *web.SiteConfig) []interface{} {
}

result["min_tls_version"] = string(input.MinTLSVersion)
result["ftps_state"] = string(input.FtpsState)

result["cors"] = azure.FlattenWebCorsSettings(input.Cors)

Expand Down
67 changes: 67 additions & 0 deletions azurerm/resource_arm_function_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,33 @@ func TestAccAzureRMFunctionApp_minTlsVersion(t *testing.T) {
})
}

func TestAccAzureRMFunctionApp_ftpsState(t *testing.T) {
resourceName := "azurerm_function_app.test"
ri := tf.AccRandTimeInt()
rs := strings.ToLower(acctest.RandString(11))
config := testAccAzureRMFunctionApp_ftpsState(ri, rs, testLocation())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMFunctionAppDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "site_config.0.ftps_state", "AllAllowed"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testCheckAzureRMFunctionAppDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).Web.AppServicesClient

Expand Down Expand Up @@ -1808,3 +1835,43 @@ resource "azurerm_function_app" "test" {
}
`, rInt, location, rString, rInt, rInt)
}

func testAccAzureRMFunctionApp_ftpsState(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}"

site_config {
ftps_state = "AllAllowed"
}
}
`, rInt, location, rString, rInt, rInt)
}
2 changes: 2 additions & 0 deletions website/docs/r/function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ The following arguments are supported:

* `min_tls_version` - (Optional) The minimum supported TLS version for the function app. Possible values are `1.0`, `1.1`, and `1.2`. Defaults to `1.2` for new function apps.

* `ftps_state` - (Optional) State of FTP / FTPS service for this function app. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`.

* `cors` - (Optional) A `cors` block as defined below.

---
Expand Down