Terraform-provider-azurerm: App service plan fails to create tags

Created on 7 Nov 2018  ยท  5Comments  ยท  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform version: 0.11.8
Go runtime version: go1.10.1
provider.azurerm v1.18.0

Affected Resource(s)

azurerm_app_service_plan

Terraform Configuration Files


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"]}"
  }
}

Expected Behavior

Tags should appear on the app service plan inside the portal, but they do not.

  1. terraform apply
question servicapp-service

All 5 comments

hi @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:

screenshot 2018-11-08 at 11 47 49

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!

Was this page helpful?
0 / 5 - 0 ratings