Terraform 策略导入错误

发布于 2025-01-16 15:22:09 字数 445 浏览 5 评论 0原文

我有一堆现有的 Vault 策略,具有以下命名约定

  • org1.bu1
  • org1.bu2
  • ....
  • org1.buN

我想使用 terraform 管理这些策略,但是当我尝试使用 terraform 导入这些 Vault 策略时,

terraform import vault_policy.org1.bu1 org1.bu1

我得到了跟随错误

Error: Invalid address
│
│   on <import-address> line 1:
│    1: vault_policy.org1.bu1
│
│ Resource instance key must be given in square brackets.

I have a bunch of existing Vault policies with the following naming conventions

  • org1.bu1
  • org1.bu2
  • ....
  • org1.buN

I would like to manage these policies using terraform, however when I try to import these vault policies using terraform

terraform import vault_policy.org1.bu1 org1.bu1

I get the following error

Error: Invalid address
│
│   on <import-address> line 1:
│    1: vault_policy.org1.bu1
│
│ Resource instance key must be given in square brackets.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘亓 2025-01-23 15:22:09

这是我拥有的、导致问题的Vault_policy 资源。

resource "vault_policy" "org1.bu1" {
  name   = "org1.bu1"
  ....
}

然后我将其更改为

resource "vault_policy" "org1_bu1" {
  name   = "org1.bu1"
  ....
}
terraform import vault_policy.org1_bu1 org1.bu1

这解决了问题并使我能够导入现有策略

Here is the vault_policy resource that I had and which caused the issue.

resource "vault_policy" "org1.bu1" {
  name   = "org1.bu1"
  ....
}

I then changed it to

resource "vault_policy" "org1_bu1" {
  name   = "org1.bu1"
  ....
}
terraform import vault_policy.org1_bu1 org1.bu1

And this fixed the issue and enabled me to import the existing policy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文