多个保管库身份验证后端上的数据查找索引无效
Invalid Index on data lookup on multiple vault auth backend
我正在编写一个 terraform 模块创建一个具有多个别名的实体。我无法查找别名身份验证后端。我错过了什么吗?非常感谢任何帮助。
data "vault_auth_backend" "b" {
provider = vault.this
for_each = {
for alias in var.entity.aliases :
alias.type => alias
}
path = each.value.auth_path
}
resource "vault_identity_entity_alias" "alias" {
provider = vault.this
for_each = {
for alias in var.entity.aliases :
alias.name => alias
}
name = each.key
mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
canonical_id = vault_identity_entity.entity.id
}
Terraform 计划输出:
Error: Invalid index
on .terraform/modules/vault_dba_entity/main.tf line 31, in resource "vault_identity_entity_alias" "alias":
31: mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
|----------------
| data.vault_auth_backend.b is object with 2 attributes
| each.key is "ldap-team-foo"
The given key does not identify an element in this collection value.
Error: Invalid index
on .terraform/modules/vault_dba_entity/main.tf line 31, in resource "vault_identity_entity_alias" "alias":
31: mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
|----------------
| data.vault_auth_backend.b is object with 2 attributes
| each.key is "aws-team-foo"
你的 for_each
块不一样:在 vault_auth_backend
中你使用别名的 type
作为键,而在 vault_identity_entity_alias
中你是使用其 name
。然后您尝试使用名称在 vault_auth_backend
中查找,这将不起作用,因为它使用 type
作为其键。
将 vault_auth_backend
更改为使用 alias.name => alias
而不是 alias.type => alias
。
我正在编写一个 terraform 模块创建一个具有多个别名的实体。我无法查找别名身份验证后端。我错过了什么吗?非常感谢任何帮助。
data "vault_auth_backend" "b" {
provider = vault.this
for_each = {
for alias in var.entity.aliases :
alias.type => alias
}
path = each.value.auth_path
}
resource "vault_identity_entity_alias" "alias" {
provider = vault.this
for_each = {
for alias in var.entity.aliases :
alias.name => alias
}
name = each.key
mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
canonical_id = vault_identity_entity.entity.id
}
Terraform 计划输出:
Error: Invalid index
on .terraform/modules/vault_dba_entity/main.tf line 31, in resource "vault_identity_entity_alias" "alias":
31: mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
|----------------
| data.vault_auth_backend.b is object with 2 attributes
| each.key is "ldap-team-foo"
The given key does not identify an element in this collection value.
Error: Invalid index
on .terraform/modules/vault_dba_entity/main.tf line 31, in resource "vault_identity_entity_alias" "alias":
31: mount_accessor = lookup(data.vault_auth_backend.b[each.key], "accessor", null)
|----------------
| data.vault_auth_backend.b is object with 2 attributes
| each.key is "aws-team-foo"
你的 for_each
块不一样:在 vault_auth_backend
中你使用别名的 type
作为键,而在 vault_identity_entity_alias
中你是使用其 name
。然后您尝试使用名称在 vault_auth_backend
中查找,这将不起作用,因为它使用 type
作为其键。
将 vault_auth_backend
更改为使用 alias.name => alias
而不是 alias.type => alias
。