gpt4 book ai didi

azure - 如何使用 terraform 创建多个 azure 广告用户?

转载 作者:行者123 更新时间:2023-12-02 06:56:56 24 4
gpt4 key购买 nike

我正在尝试使用 terraform 创建多个用户。目前我将它们声明为本地用户,但稍后我将使用 json 文件在我的 azuread 环境中创建多个用户。

这是我如何声明本地人:

locals {
users = [
[
"user1",
"Example User1",
"Password@1234#"
],
[
"user2",
"Example User2",
"Password@09876#"
]
]
}

但是当我使用下面的代码时出现错误:

resource "azuread_user" "test" {
for_each = local.users

user_principal_name = "${each.value[0]}@tenantname.OnMicrosoft.com"
display_name = each.value[1]
mail_nickname = each.value[0]
password = each.value[2]
}

错误:


│ Error: Invalid for_each argument

│ on main.tf line 18, in resource "azuread_user" "test":
│ 18: for_each = local.users
│ ├────────────────
│ │ local.users is tuple with 2 elements

│ The given "for_each" argument value is unsuitable: the "for_each" argument must be a map, or set of strings, and you have provided a value of type tuple.

非常感谢有关如何解决此问题的任何帮助?

最佳答案

您必须将其转换为 map :

resource "azuread_user" "test" {

for_each = {for idx, user in local.users: idx => user}

user_principal_name = "${each.value[0]}@M365B109047.OnMicrosoft.com"
display_name = each.value[1]
mail_nickname = each.value[0]
password = each.value[2]
}

关于azure - 如何使用 terraform 创建多个 azure 广告用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69703495/

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