Azure apim-使用```API操作''API操作后已经存在了`
在我的Azure APIM中,我试图将API操作添加到API中,以便可以通过Terraform向其添加策略。除了 azurerm_api_management_api_operation
零件外,所有功能都很好。基本上,它出现了众所周知的Terraform错误 ID的资源已经存在..
。
我的Terraform的一个片段是:
resource "azurerm_api_management_api" "business_api_v1" {
name = "business-api-v1"
resource_group_name = data.azurerm_resource_group.app_rg.name
api_management_name = module.api.name
revision = "1"
display_name = "Business API v1"
path = "business-data/v1"
protocols = ["https"]
version = "v1"
version_set_id = azurerm_api_management_api_version_set.business-api-version-set.id
import {
content_format = "openapi+json"
content_value = <<JSON
<...content of json open API spec...>
JSON
}
}
resource "azurerm_api_management_api_operation" "search_businesses_v1" {
operation_id = "tf-search-businesses"
api_name = azurerm_api_management_api.business_api_v1.name
api_management_name = module.api.name
resource_group_name = data.azurerm_resource_group.app_rg.name
display_name = "Search Businesses"
method = "GET"
url_template = "/businesses"
description = "Search Businesses by name"
}
我不知所措,为什么Terraform创建它然后给出错误:
A resource with the ID "/subscriptions/<sub_id>/resourceGroups/<resource_group>/providers/Microsoft.ApiManagement/service/abcd/apis/business-api-v1/operations/tf-search-businesses" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_api_management_api_operation" for more information.
我几次删除了我的API(&amp;基础资源),并运行了 plan> plan
>和应用
阶段。在应用过程中,
阶段创建资源后会引发错误。 100%确定没有其他人创建它,我尝试在尝试解决此问题时多次重命名 name
属性。
有人知道可能是什么问题吗?谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每当创建资源时,Azure及其状态就会发生变化。
门户网站,Terraform状态可能与真实状态匹配。
由于将被带到Terraform管理控制下,因此请尝试通过核对@Markus所说的现有更改来匹配Terraform的导入,并通过核对管理的访问。
或
手动更改后端。
您的Terraform状态文件。
可以使用
Terraform状态MV
完成此实际一个,您可以使用
Terraform State rm {resource}
类似问题:
azure and its state changes whenever resources are created .
portal, the terraform state may have not matched with the real state.
As they are to be brought under terraform management control , do try to terraform import to match the existing changes as said by @markus by checking with the access from management.
or
manually change the backend.
your Terraform state file.
It can be done using
terraform state mv
actual one ,you can use
terraform state rm {name of resource}
Similar issues:
already exists" - DEV Community