gpt4 book ai didi

azure - 如何让 terraform 自动导入所有 "already exists"资源?

转载 作者:行者123 更新时间:2023-12-02 05:52:20 34 4
gpt4 key购买 nike

当我运行 terraform apply -auto-approve 时,出现以下错误:

Error: A resource with the ID "/subscriptions/.../resourceGroups/RG-SCUSTFStorage" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_resource_group" for more information.

我知道我需要运行 terraform import 将资源导入到我的工作空间。问题是我需要一次为所有缺失的资源指定一个资源 ID。

有什么方法可以让 terraform import 自动导入所有“已存在”资源,而无需一次输入一个资源 ID?

最佳答案

不幸的是,您只能手动将现有资源与资源ID一一导入:

The import command doesn’t automatically generate the configuration tomanage the infrastructure, though. Because of this, importing existinginfrastructure into Terraform is a multi-step process.

更多详情here 。我建议您使用remote state storage对于部署前的所有 Terraform 脚本。如果您没有包含所有已部署资源的状态文件,则只能一一导入。

关于azure - 如何让 terraform 自动导入所有 "already exists"资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64581092/

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