gpt4 book ai didi

azure - json.Marshal() : json: error calling MarshalJSON for type msgraph. 应用程序

转载 作者:行者123 更新时间:2023-12-04 16:36:25 26 4
gpt4 key购买 nike

必须进行哪些特定语法或配置更改才能解决以下 terraform 无法创建 azure_application 实例的错误?

代码:

运行 terraform apply 时触发错误的 terraform 代码如下:

variable "tenantId" { }
variable "clientId" { }
variable "clientSecret" { }
variable "instanceName" { }

terraform {
required_providers {
azuread = {
source = "hashicorp/azuread"
version = "2.5.0"
}
}
}

provider "azuread" {
tenant_id = var.tenantId
client_id = var.clientId
client_secret = var.clientSecret
}

resource "azuread_application" "appRegistration" {
display_name = var.instanceName
app_role {
allowed_member_types = ["User", "Application"]
description = "Admins can manage roles and perform all task actions"
display_name = "Admin"
enabled = true
id = "1b19509b-32b1-4e9f-b71d-4992aa991967"
value = "admin"
}
}

错误:

使用 terraform apply 运行上述代码所产生的错误和日志输出是:

2021/10/05 17:47:18 [DEBUG] module.ad-admin.azuread_application.appRegistration:
apply errored, but we're indicating that via the Error pointer rather than returning it:
Could not create application: json.Marshal():
json: error calling MarshalJSON for type msgraph.Application:
json: error calling MarshalJSON for type *msgraph.Owners: marshaling Owners: encountered DirectoryObject with nil ODataId

2021/10/05 17:47:18 [TRACE] EvalMaybeTainted: module.ad-admin.azuread_application.appRegistration encountered an error during creation, so it is now marked as tainted
2021/10/05 17:47:18 [TRACE] EvalWriteState: removing state object for module.ad-admin.azuread_application.appRegistration
2021/10/05 17:47:18 [TRACE] EvalApplyProvisioners: azuread_application.appRegistration has no state, so skipping provisioners
2021/10/05 17:47:18 [TRACE] EvalMaybeTainted: module.ad-admin.azuread_application.appRegistration encountered an error during creation, so it is now marked as tainted
2021/10/05 17:47:18 [TRACE] EvalWriteState: removing state object for module.ad-admin.azuread_application.appRegistration
2021/10/05 17:47:18 [TRACE] vertex "module.ad-admin.azuread_application.appRegistration": visit complete

2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.output.application_id (expand)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.azuread_service_principal.appRegistrationSP" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "output.application_id" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.output.appId (expand)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.azuread_service_principal_password.appRegistrationSP_pwd" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "output.appId" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.azurerm_role_assignment.appRegistrationSP_role_assignment_vault" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.azurerm_role_assignment.appRegistrationSP_role_assignment" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.provider[\"registry.terraform.io/hashicorp/azuread\"] (close)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin.provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "module.ad-admin (close)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2021/10/05 17:47:18 [TRACE] dag/walk: upstream of "root" errored, so skipping
2021/10/05 17:47:18 [TRACE] statemgr.Filesystem: creating backup snapshot at terraform.tfstate.backup
2021/10/05 17:47:18 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 391
2021/10/05 17:47:18 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2021/10/05 17:47:18 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info

Error: Could not create application

on ..\..\..\..\modules\ad-admin\active-directory.tf line 69, in resource "azuread_application" "appRegistration":
69: resource "azuread_application" "appRegistration" {

json.Marshal(): json: error calling MarshalJSON for type msgraph.Application:
json: error calling MarshalJSON for type *msgraph.Owners: marshaling Owners:
2021/10/05 17:47:18 [TRACE] statemgr.Filesystem: unlocked by closing terraform.tfstate
encountered DirectoryObject with nil ODataId

terraform -version 给出:

Terraform v1.0.8在 windows_amd64 上

最佳答案

这是一个错误,报告为 GitHub 问题:

OP中问题的解决方案是将required_providers block 中的版本从2.5.0升级到2.6.0上面OP中的代码如下:

terraform {
required_providers {
azuread = {
source = "hashicorp/azuread"
version = "2.6.0"
}
}
}

关于azure - json.Marshal() : json: error calling MarshalJSON for type msgraph. 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69459069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com