rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 216 forks source link

[BUG] secret cannot be imported #1279

Open artm opened 6 months ago

artm commented 6 months ago

Rancher Server Setup

Information about the Cluster

User Information

Provider Information

Describe the bug

resource "rancher2_secret" "keycloak_admin" {
  project_id   = data.rancher2_project.default.id
  namespace_id = rancher2_namespace.keycloak.id
  name         = "keycloak-admin"
  data = {
  ...
$ kubectl get secret keycloak-admin -n keycloak
NAME             TYPE     DATA   AGE
keycloak-admin   Opaque   1      77d

$ terraform import rancher2_secret.keycloak_admin "keycloak.$clusterid:$projectid.keycloak-admin"
...
│ Error: nil entry in ImportState results. This is always a bug with
│ the resource that is being imported. Please report this as
│ a bug to Terraform.

Actual Result

See above

Expected Result

rancher2_recret imported

Additional context

According to the documentation the import syntax should be

$ terraform import rancher2_secret.foo <namespace_id>.<project_id>.<secret_id>

terraform plan outputs:

 ...
  # rancher2_secret.keycloak_admin will be created
  + resource "rancher2_secret" "keycloak_admin" {
      + annotations  = (known after apply)
      + data         = (sensitive value)
      + id           = (known after apply)
      + labels       = (known after apply)
      + name         = "keycloak-admin"
      + namespace_id = "keycloak"
      + project_id   = "c-84kdv:p-jrhfg"
    }
 ...

so I seem to be using correct values for the ids