crossplane-contrib / provider-upjet-azure

Azure Provider for Crossplane.
https://marketplace.upbound.io/providers/upbound/provider-family-azure/
Apache License 2.0
61 stars 75 forks source link

[Bug]: ReconcileError: Cannot import existing resource #828

Open 1aziz opened 2 weeks ago

1aziz commented 2 weeks ago

Is there an existing issue for this?

Affected Resource(s)

cache.azure.upbound.io/v1beta1 - RedisLinkedServer

Resource MRs required to reproduce the bug

apiVersion: cache.azure.upbound.io/v1beta1
kind: RedisLinkedServer
metadata:
  annotations:
    crossplane.io/external-name: >-
      /subscriptions/***/resourceGroups/rg-stage-blue/providers/Microsoft.Cache/redis/redis-stage-blue-trading/linkedServers/redis-stage-green-trading
  labels:
    subscription: prod
  name: redislinkedserver-stage-blue-trading
spec:
  deletionPolicy: Orphan
  forProvider:
    linkedRedisCacheId: >-
      /subscriptions/***/resourceGroups/rg-stage-green/providers/Microsoft.Cache/redis/redis-stage-green-trading
    linkedRedisCacheLocation: westeurope
    resourceGroupName: rg-stage-blue
    serverRole: Secondary
    targetRedisCacheName: redis-stage-blue-trading
  providerConfigRef:
    name: azure-prod

Steps to Reproduce

No actions applicable. The ReconcileError was thrown automatically.

What happened?

When Crossplane tries to reconcile my RedisLinkedServer resource, I recieve the following error:

create failed: async create failed: failed to create the resource: [{0 A resource with the ID "/subscriptions/***/resourceGroups/rg-stage-blue/providers/Microsoft.Cache/redis/redis-stage-blue-trading/linkedServers/redis-stage-green-trading" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_redis_linked_server" for more information. []}]

I am not what really happens. I did not change anything in the manifest and suddenly we're getting this error! The resource is healthy on the Azure side.

Provider version: xpkg.upbound.io/upbound/provider-azure-cache:v

Relevant Error Output Snippet

create failed: async create failed: failed to create the resource: [{0 A resource with the ID "/subscriptions/***/resourceGroups/rg-stage-blue/providers/Microsoft.Cache/redis/redis-stage-blue-trading/linkedServers/redis-stage-green-trading" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_redis_linked_server" for more information. []}]

Crossplane Version

1.17.1

Provider Version

1.1.0

Kubernetes Version

1.28.5

Kubernetes Distribution

AKS

Additional Info

No response

JakobGSvendsen commented 6 days ago

we have same error with cosmos db:

" async create failed: failed to create the resource: [{0 CosmosDB Account dcdb001asct-nl2 already exists, please import the resource via terraform import []}] "

And I tried to add the external-name to see if it imported but no luck. I did earlier deploy a resource with this name, but it has been deleted long time ago.

Can I reset the state file in terraform or somehow fix it otherwise?