Azure 如何让terraform导入所有;“已经存在”;自动分配资源?

Azure 如何让terraform导入所有;“已经存在”;自动分配资源?,azure,terraform,terraform-provider-azure,Azure,Terraform,Terraform Provider Azure,当我运行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 res

当我运行
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导入自动导入所有“已存在”的资源,而无需一次输入一个资源ID?

不幸的是,您只能使用资源ID手动逐个导入现有资源:

“导入”命令不会自动生成要导入的配置 不过,管理基础设施。因此,导入现有的 基础设施到地形是一个多步骤的过程

更多细节。我建议您在部署之前使用所有Terraform脚本。如果没有包含所有已部署资源的状态文件,则只能逐个导入它们