Skip to content

Commit

Permalink
azurerm_function_app - make pre_warmed_instance_count computed to u…
Browse files Browse the repository at this point in the history
…se azure's default (#9069)

This resolves #9066 by setting the default prewarmed pre_warmed_instance_count to 1
  • Loading branch information
RiverPhillips authored Dec 29, 2020
1 parent 4a6edf2 commit 47911d2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions azurerm/internal/services/web/function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func schemaAppServiceFunctionAppSiteConfig() *schema.Schema {
"pre_warmed_instance_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 10),
},

Expand Down
57 changes: 57 additions & 0 deletions azurerm/internal/services/web/function_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,22 @@ func TestAccFunctionApp_preWarmedInstanceCount(t *testing.T) {
})
}

func TestAccAzureRMFunctionApp_computedPreWarmedInstanceCount(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_function_app", "test")
r := FunctionAppResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.computedPreWarmedInstanceCount(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.pre_warmed_instance_count").HasValue("1"),
),
},
data.ImportStep(),
})
}

func TestAccFunctionApp_oneIpRestriction(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_function_app", "test")
r := FunctionAppResource{}
Expand Down Expand Up @@ -2303,6 +2319,47 @@ resource "azurerm_function_app" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func (r FunctionAppResource) computedPreWarmedInstanceCount(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
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"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
kind = "elastic"
sku {
tier = "ElasticPremium"
size = "EP1"
}
}
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
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func (r FunctionAppResource) oneIpRestriction(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit 47911d2

Please sign in to comment.