aptible / terraform-provider-aptible

The official Terraform provider for Aptible Deploy
https://registry.terraform.io/providers/aptible/aptible/latest
10 stars 13 forks source link

Import does not function for App resources #49

Closed zellio closed 3 years ago

zellio commented 3 years ago

When attempting to import an aptible_app resource the process fails with:

╷
│ 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.
│
│
╵

Reproduction:

Pre-work:

$ aptible apps:create --environment test-env test-app

Terraform code:

terraform {
  required_providers {
    aptible = {
      source  = "aptible/aptible"
      version = "~>0.1"
    }
  }
}

data "aptible_environment" "test-env" {
  handle = "test-env"
}

resource "aptible_app" "test-app" {
  env_id = data.aptible_environment.test-env.env_id
  handle = "test-app"
  config = {}
}

Execution:

$ terraform import aptible_app.test-app test-app
aptible_app.test-app: Importing from ID "test-app"...
╷
│ 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.
│
│
╵

Additional Notes: from TF_LOG=trace

aptible_app.test-app: Importing from ID "test-app"...
2021-08-13T13:11:29.673-0400 [TRACE] vertex "aptible_app.test-app": starting visit (*terraform.NodeAbstractResource)
2021-08-13T13:11:29.673-0400 [TRACE] GRPCProvider: ImportResourceState
2021-08-13T13:11:29.673-0400 [TRACE] vertex "aptible_app.test-app": visit complete
2021-08-13T13:11:29.673-0400 [TRACE] vertex "aptible_app.test-app": starting visit (*terraform.NodeAbstractResource)
2021-08-13T13:11:29.673-0400 [TRACE] vertex "aptible_app.test-app": visit complete
2021-08-13T13:11:29.673-0400 [INFO]  provider.terraform-provider-aptible_v0.1.4: 2021/08/13 13:11:29 Getting App with ID: 0: timestamp=2021-08-13T13:11:29.673-0400
2021-08-13T13:11:30.075-0400 [TRACE] vertex "aptible_app.test-app (import id \"test-app\")": visit complete
2021-08-13T13:11:30.075-0400 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/aptible/aptible\"] (close)" errored, so skipping
2021-08-13T13:11:30.075-0400 [TRACE] dag/walk: upstream of "root" errored, so skipping
╷
│ 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.
│
│
╵

2021-08-13T13:11:30.076-0400 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2021-08-13T13:11:30.076-0400 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2021-08-13T13:11:30.078-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-08-13T13:11:30.081-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/aptible/aptible/0.1.4/darwin_amd64/terraform-provider-aptible_v0.1.4 pid=88333
zellio commented 3 years ago

Imports require IDs not handles.

robertfairhead commented 3 years ago

It looks like you figured the issue. To document this for future users, we note that you have to use the ID in the import documentation. How to get that may be unclear, so here's the steps if needed:

I apologize for the delay in responding to your ticket!