-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
When attempting config-driven import of existing infrastructure into tfstate for catalystcenter_global_pool objects, terraform fails with error.
│Error: Cannot import non-existent remote object
│
│ While attempting to import an existing object to "catalystcenter_global_pool.this[\"glob_etu_3_v666_1\"]", the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or use
│ "terraform apply" to create a new remote object for this resource.
Example of import:
locals{
_imp_global_pools = {
"glob_etu_3_v666_1" = { id = "934f6100-7ef7-47e6-95a2-a22865c72e64"} ,
}
}
import {
for_each = local._imp_global_pools
id = each.value.id
to = catalystcenter_global_pool.this[each.key]
}
resource "catalystcenter_global_pool" "this" {
provider = catalystcenter
for_each = var.ip_pools
parameters {
settings {
ippool {
ip_address_space = each.value.ip_address_space
ip_pool_cidr = each.value.ip_pool_cidr
ip_pool_name = each.key
type = each.value.type
}
}
}
}
Our tfvars:
"ip_pools": {
"glob_etu_3_v666_1": {
"ip_address_space": "IPv4",
"ip_pool_cidr": "10.0.0.0/23",
"type": "generic",
},
}
It is not clear from documentation what "id=string" is, but debuglogs does not show any attempt of any read-operation regardless of what id we specify. The following is from debug logs:
2024-09-24T15:11:14.869+0200 [DEBUG] ReferenceTransformer: "catalystcenter_ip_pool.this[\"glob_etu_3_v666_1\"]" references: []
2024-09-24T15:11:15.187+0200 [DEBUG] Resource instance state not found for node "catalystcenter_global_pool.this[\"glob_etu_3_v666_1\"]", instance catalystcenter_global_pool.this["glob_etu_3_v666_1"]
Manual API GET response is ok for the global pools, and the pools exist in catalystCenter (example http get response below)
{
"response": {
"ipPoolName": "glob_etu_3_v666_1",
"dhcpServerIps": [],
"gateways": [],
"createTime": 1725618214533,
"lastUpdateTime": 1725618238245,
"totalIpAddressCount": 512,
"usedIpAddressCount": 512,
"parentUuid": "root",
"owner": "ipam",
"shared": true,
"overlapping": false,
"configureExternalDhcp": false,
"usedPercentage": "100",
"clientOptions": {},
"ipPoolType": "generic",
"unavailableIpAddressCount": 0,
"availableIpAddressCount": 0,
"totalAssignableIpAddressCount": 510,
"dnsServerIps": [],
"hasSubpools": false,
"defaultAssignedIpAddressCount": 2,
"context": [
{
"owner": "ipam",
"contextKey": "type",
"contextValue": "generic"
}
],
"ipv6": false,
"id": "934f6100-7ef7-47e6-95a2-a22865c72e64",
"ipPoolCidr": "10.0.0.0/23"
},
"version": "1.0"
}
Config-driven import is essential to be able to migrate from the older dnacenter-provider to the new catalystcenter-provider as these resources cannot be destroyed/recreated in production environments.
- Cisco Catalyst Center version and patch: 2.3.7.6-70319
- Terraform version: 1.9.5
- Cisco Catalyst Center provider version: 1.0.0-beta
- OS Version: Ubnutu 22.04
Metadata
Metadata
Assignees
Labels
No labels