argoproj-labs/terraform-provider-argocd

Failure to import an existing argocd application

pedrojflores opened this issue · 1 comments

Terraform version: 1.9.1
ArgoCD provider version: 6.1.1
ArgoCD version: v2.11.1+9f40df0

Affected Resource(s)

  • argocd_application

Terraform Configuration Files

resource "argocd_application" "airbyte" {
  provider = argocd

  metadata {
    name      = "airbyte"
    namespace = "airbyte"
  }

  spec {
    project = "default"

    destination {
      server    = "https://kubernetes.default.svc"
      namespace = "airbyte"
    }

    source {
      repo_url        = "https://airbytehq.github.io/helm-charts"
      chart           = "airbyte"
      target_revision = "0.248.5"
      helm {
        release_name = "airbyte"
        values = yamlencode({
          "global" : {
            "airbyteUrl" : "<redacted>"
          },
          "webapp" : {
            "ingress" : {
              "enabled" : true,
              "className" : "alb",
              "annotations" : {
                "alb.ingress.kubernetes.io/scheme" : "internal",
                "alb.ingress.kubernetes.io/target-type" : "ip",
                "alb.ingress.kubernetes.io/backend-protocol" : "HTTP",
                "alb.ingress.kubernetes.io/listen-ports" : "[{\"HTTPS\":80}, {\"HTTPS\":443}]",
                "alb.ingress.kubernetes.io/ssl-redirect" : "443",
                "alb.ingress.kubernetes.io/certificate-arn" : "<redacted>",
                "ingress.kubernetes.io/ssl-redirect" : "true"
              },
              "hosts" : [
                {
                  "host" : "<redacted>",
                  "paths" : [
                    {
                      "path" : "/",
                      "pathType" : "Prefix"
                    }
                  ]
                }
              ]
            }
          }
        })
      }
    }
  }
}

Issue Description

When trying to import an existing argocd application into the terraform resource Terraform fails to do so and complains about me trying to import a resource that doesn't exist

> terraform import -var-file vars_development_us-east-1.tfvars argocd_application.airbyte airbyte:airbyte
argocd_application.airbyte: Importing from ID "airbyte:airbyte"...
argocd_application.airbyte: Import prepared!
  Prepared argocd_application for import
argocd_application.airbyte: Refreshing state... [id=airbyte:airbyte]
╷
│ Error: Cannot import non-existent remote object
│
│ While attempting to import an existing object to "argocd_application.airbyte", 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.

However the resource does exist

argocd app get airbyte
Name:               airbyte
Project:            default
Server:             https://kubernetes.default.svc
Namespace:          airbyte
URL:               <redacted>
Repo:               https://airbytehq.github.io/helm-charts
Target:             0.248.5
Path:
SyncWindow:         Sync Allowed
Sync Policy:        <none>
Sync Status:        Synced to 0.248.5
Health Status:      Healthy
...
...

Debug Output

https://gist.github.com/pedrojflores/7a8f1602d209f36bd5300cb3c10345ef

Panic Output

No crash.log available as the provider does not crash

Steps to Reproduce

  1. Define resource as described above
  2. terraform import -var-file vars_dev.tfvars argocd_application.airbyte airbyte:airbyte

Expected Behavior

The expected behavior here would be that the resource is imported successfully

Actual Behavior

Terraform complains about the resource I'm trying to import does not exist

Important Factoids

  1. The Argo CD instance is hosted in EKS
  2. Access to the Argo CD instance is exposed via an ALB ingress
  3. The terraform provider is using admin credentials (username and password) to connect to the Argo CD instance
  4. I'm able to deploy other resources to Argo CD. I'm just not being able to import this application.

References

n/a

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.