Terraform v0.12.28
+ provider.azurerm v2.18.0
+ provider.random v2.3.0
azurerm_app_service_planazurerm_function_appterraform {
required_version = "~> 0.12.28"
required_providers {
azurerm = "= 2.18.0"
random = "~> 2.3"
}
}
provider "azurerm" {
features {}
}
provider "random" {
}
resource "azurerm_resource_group" "asp_test" {
name = "asp_test"
location = "West Europe"
}
resource "random_string" "function_storage_suffix" {
length = 8
upper = false
special = false
keepers = {
resource_group = azurerm_resource_group.asp_test.id
}
}
resource "random_string" "function_app_suffix" {
length = 8
upper = false
special = false
keepers = {
resource_group = azurerm_resource_group.asp_test.id
}
}
resource "azurerm_storage_account" "function_storage" {
name = "function${random_string.function_storage_suffix.result}"
resource_group_name = azurerm_resource_group.asp_test.name
location = azurerm_resource_group.asp_test.location
account_tier = "Standard"
account_replication_type = "LRS"
enable_https_traffic_only = true
identity {
type = "SystemAssigned"
}
}
resource "azurerm_app_service_plan" "app_service_plan" {
name = "asp_test"
location = azurerm_resource_group.asp_test.location
resource_group_name = azurerm_resource_group.asp_test.name
kind = "FunctionApp"
reserved = true
sku {
tier = "Dynamic"
size = "Y1"
}
}
resource "azurerm_function_app" "function_app" {
name = "function-app-${random_string.function_app_suffix.result}"
location = azurerm_resource_group.asp_test.location
resource_group_name = azurerm_resource_group.asp_test.name
app_service_plan_id = azurerm_app_service_plan.app_service_plan.id
storage_connection_string = azurerm_storage_account.function_storage.primary_connection_string
os_type = "linux"
}
The given config should create a Function App on an App Service plan of the type linux consumption. The config works as expected with the azurerm provider pinned to version 2.17.0
The apply step fails with the following error message:
Error: `reserved` has to be set to false when kind isn't set to `Linux`
on main.tf line 52, in resource "azurerm_app_service_plan" "app_service_plan":
52: resource "azurerm_app_service_plan" "app_service_plan" {
The check responsible for this error message was introduced into version 2.18.0 of the azurerm provider through #7661. Apparently this was done to remediate a different issue.
terraform applyThe essential parts of the example config were copied from the linux example in the azurerm provider docs on function apps. If it is desired behaviour that this config does not work in 2.18.0 , and there is a different way to create linux consumption plans in terraform, this document should be updated.
FYI - for now I am getting around this issue by setting kind = "linux" and using the following lifecycle block in my azurerm_app_service_plan resource:
lifecycle {
ignore_changes = [
kind
]
}
If I do not ignore the kind property this is what I see in my subsequent plan operations:
Terraform will perform the following actions:
# azurerm_app_service_plan.asp_function must be replaced
-/+ resource "azurerm_app_service_plan" "asp_function" {
~ id = "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.Web/serverfarms/<APP_SERVICE_PLAN_NAME>" -> (known after apply)
- is_xenon = false -> null
~ kind = "functionapp" -> "Linux" # forces replacement
location = "southcentralus"
~ maximum_elastic_worker_count = 1 -> (known after apply)
~ maximum_number_of_workers = 0 -> (known after apply)
name = "<APP_SERVICE_PLAN_NAME>"
- per_site_scaling = false -> null
reserved = true
resource_group_name = "<RESOURCE_GROUP_NAME>"
tags = {
"Component" = "<APP_NAME>"
"Environment" = "Prod"
}
~ sku {
~ capacity = 0 -> (known after apply)
size = "Y1"
tier = "Dynamic"
}
}
I've just tested by downgrading to Azurerm v2.17.0 and I don't have the issue. The issue seems to be related to this commit on v2.18.0
@jmapro the original issue description contains a link to the PR that introduced it, if you didn't see it.
Hi All, I have submitted a PR to revert the commit, Hope it could unblock you soon
This has been released in version 2.21.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:
provider "azurerm" {
version = "~> 2.21.0"
}
# ... other configuration ...
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
FYI - for now I am getting around this issue by setting
kind = "linux"and using the following lifecycle block in my azurerm_app_service_plan resource:If I do not ignore the kind property this is what I see in my subsequent plan operations: