gpt4 book ai didi

terraform - 如何导入 terraform 策略附件?

转载 作者:行者123 更新时间:2023-12-05 00:48:44 25 4
gpt4 key购买 nike

我们的主要目标是将一些资源移动到不同的 terraform 状态文件。我正在尝试导入资源的策略附件,但似乎它不支持导入策略附件。我收到一个错误。

如果不支持,其他选择是什么?

我正在尝试导入此政策

 + aws_iam_role_policy_attachment.gitlab_as_attach
id: <computed>
policy_arn: "arn:aws:iam::xxxxxxxxxxxx:policy/gitlab_as_policy"
role: "gitlab_prod"

错误:
terraform import aws_iam_role_policy_attachment.gitlab_as_attach arn:aws:iam::xxxxxxxxx:policy/gitlab_as_policy
aws_iam_role_policy_attachment.gitlab_as_attach: Importing from ID "arn:aws:iam::xxxxxxxx:policy/gitlab_as_policy"...
Error importing: 1 error(s) occurred:

* aws_iam_role_policy_attachment.gitlab_as_attach (import id: arn:aws:iam::xxxxxxxxxx:policy/gitlab_as_policy): import aws_iam_role_policy_attachment.gitlab_as_attach (id: arn:aws:iam::xxxxxxxxxx:policy/gitlab_as_policy): resource aws_iam_role_policy_attachment doesn't support import

地形版本:
Terraform v0.11.0
+ provider.aws v1.5.0

最佳答案

此问题已在 1.37.0 中为 provider.aws 插件修复。升级与 terraform 相关的插件和模块。

要升级插件,请运行以下命令

terraform init -upgrade

要升级模块,请运行以下命令
terraform get -update

有关更多信息,请查看与 terraform 相关的缺陷和增强功能

https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md#1370-september-19-2018

我今天为 aws_iam_role_policy_attachment 运行了导入,它成功了。

terraform import -provider=aws.{example} aws_iam_role_policy_attachment.role-attach-1 {test-role}/arn:aws:iam::aws:policy/ReadOnlyAccess
aws_iam_role_policy_attachment.role-attach-1: Importing from ID "{test-role}/arn:aws:iam::aws:policy/ReadOnlyAccess"...
aws_iam_role_policy_attachment.role-attach-1: Import complete!
Imported aws_iam_role_policy_attachment (ID: {test-role}-arn:aws:iam::aws:policy/ReadOnlyAccess)
aws_iam_role_policy_attachment.role-attach-1: Refreshing state... (ID: {test-role}-arn:aws:iam::aws:policy/ReadOnlyAccess)


我希望这有帮助。

关于terraform - 如何导入 terraform 策略附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48970322/

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