【问题标题】:AzureAD // Terraform Cycle Error UndefinedAzureAD // Terraform 循环错误未定义
【发布时间】:2019-09-05 09:56:06
【问题描述】:

我想使用 Azuread Provider 创建一个应用注册,并将 applictionid 输出用于我的 appservice 中的配置。每次我计划时,我都会收到一条错误消息。如果我删除配置行,一切正常。

我尝试将 App-Registration 放入一个模块并使用输出,但我得到了同样的错误。

有人给点建议吗?

//Azure App Registration
  resource "azuread_application" "appregistration" {
  name                       = "${var.state}Site-${var.typ}-ar"
  reply_urls                 = ["https://${azurerm_app_service.appservice.default_site_hostname}/signin-callback"]
  available_to_other_tenants = false
  oauth2_allow_implicit_flow = true
}
resource "azuread_application_password" "AppRegistrationPwd" {
  application_object_id = "${azuread_application.appregistration.id}"
  value                 = "SOMECODE"
  end_date              = "2020-01-01T01:02:03Z"
}
resource "azuread_service_principal" "serviceprincipal" {
  application_id                = "${azuread_application.appregistration.application_id}"
  app_role_assignment_required  = false
}

应用服务

resource "azurerm_app_service" "appservice" {
    name = "${var.state}-Site-${var.typ}-as"
    location = "${var.location}"
    resource_group_name = "${azurerm_app_service_plan.serviceplan.resource_group_name}"
    app_service_plan_id = "${azurerm_app_service_plan.serviceplan.id}"

    site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

    app_settings = {
    "AzureAd:ClientId"  = "${azuread_service_principal.serviceprincipal.application_id}"


  }



  }

错误:

Error: Cycle: module.devcentralhub.azuread_service_principal.serviceprincipal, module.devcentralhub.azurerm_app_service.appservice, module.devcentralhub.azuread_application.appregistration

【问题讨论】:

  • 我想我明白了。问题是“哪个”在先。 Appservice 需要 ClientID,Application Service 需要来自 appservice 的主 URL,对吧?

标签: azure terraform


【解决方案1】:

您的理解和您的评论一样,资源azurerm_app_service需要application_id来自资源azuread_service_principal,而资源azuread_service_principal需要reply_urls中的应用服务名称,所以会导致循环。

要打破循环,您可以通过${var.state}-Site-${var.typ}-as.azurewebsites.net 指定${azurerm_app_service.appservice.default_site_hostname},因为通常这两个值是相同的。

在您的代码中更改为reply_urls = ["https://${var.state}-Site-${var.typ}-as.azurewebsites.net/signin-callback"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 2019-10-24
    • 1970-01-01
    相关资源
    最近更新 更多