Terraform version: 0.11.8
Go runtime version: go1.10.1
provider.azurerm v1.18.0
azurerm_app_service_plan
locals {
env_name = "dev"
app_name = "thing"
name = "${var.area_prefix}-${local.env_name}-${local.app_name}-app-service-plan"
default_tags = {
env = "${local.env_name}"
area = "${var.area_prefix}"
application = "${local.app_name}"
app_version = "${var.app_version}"
deploy_timestamp = "${timestamp()}"
}
}
resource "azurerm_app_service_plan" "app_service_plan" {
name = "${local.name}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
tags = "${merge(local.default_tags, var.tags)}"
kind = "${var.kind}"
sku {
tier = "${var.sku["tier"]}"
size = "${var.sku["size"]}"
capacity = "${var.sku["capacity"]}"
}
}
Tags should appear on the app service plan inside the portal, but they do not.
terraform applyhi @alastairtree
Thanks for opening this issue :)
Taking a quick look into this the Terraform Configuration above looks correct - would it be possible to confirm if the App Service Plan already existed in Azure and hasn't been imported into Terraform?
Thanks!
The missing tags happen if you create a new app service plan, or try and update an existing one and add tags - the tags never get assigned to the app service plan.
hi @alastairtree
Thanks for getting back to me here. Taking a quick look into this using the following configuration:
provider "azurerm" {
version = "=1.18.0"
}
resource "azurerm_resource_group" "test" {
name = "tom-devrg"
location = "West Europe"
}
resource "azurerm_app_service_plan" "test" {
name = "tom-devasp"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
tags = {
"hello" = "world"
}
}
resource "azurerm_app_service" "test" {
name = "tomdev-appservice"
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 {
dotnet_framework_version = "v4.0"
scm_type = "LocalGit"
}
app_settings {
"SOME_KEY" = "some-value"
}
connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
}
tags = {
"hello" = "world"
}
}
adds the following tags to the App Service Plan:

I've tested adding and removing these multiple times and they get added/removed as expected (after refreshing the portal). Would you be able to take a look and see if the Terraform Configuration defined above works for you?
Since this is a question about Terraform Configuration rather than a bug in Terraform - I'm going to close this issue for the moment (however we'll continue responding ๐)
Thanks!
Hmmm, it seems the exact same deployment code now adds the tags were missing before. Perhaps the Azure APIs were fixed. Either way, thanks for investigating, all seems fine now.
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!