无法在azurerm_app_service中获取site_credential.username

时间:2018-12-07 09:54:34

标签: terraform azure-web-app-service azure-keyvault

我有我的应用服务:

resource "azurerm_app_service" "appservice" {

  name = name",
  location = "${var.location}",
  resource_group_name = "${azurerm_resource_group.resourcegroup.name}",
  app_service_plan_id = "${azurerm_app_service_plan.appserviceplan.id}"
    app_settings{
        ...
    }
    site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

}

然后我尝试将site_credential.username添加为key_vault_secret

resource "azurerm_key_vault_secret" "key_vault_secret_publish_profile_username" {
  name = "username"

  value = "${azurerm_app_service.appservice.site_credential.username}"
  vault_uri = "${azurerm_key_vault.keyvault.vault_uri}"
}

地形计划还可以,当我尝试“ terraform apply”时,它将返回以下错误:

发生1个错误:

  • azurerm_key_vault_secret.key_vault_secret_publish_profile_username:资源'azurerm_app_service.appservice'不具有变量'azurerm_app_service.appservice.site_credential.username'的属性'site_credential.username'

Terraform文档规定scm_type必须设置为“ LocalGit” => https://www.terraform.io/docs/providers/azurerm/r/app_service.html

1 个答案:

答案 0 :(得分:0)

尝试一下:

resource "azurerm_key_vault_secret" "key_vault_secret_publish_profile_username" {
  name = "username"

  value = "${azurerm_app_service.appservice.site_credential.0.username}"
  vault_uri = "${azurerm_key_vault.keyvault.vault_uri}"
}