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 aptible resources under terraform management #100

Open ilokhvytska-medrhythms opened 1 year ago

ilokhvytska-medrhythms commented 1 year ago

terraform import -input=false -var-file=environ/dev/terraform.tfvars aptible_database.coretx-psql coretx-dev-psql

Result:

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

I tried differend combination, like env_id/db_id, env_id:db_id, env_name/db_name, env_name:db_name.

madhuravius commented 1 year ago

Sorry to hear you're having some issues with this. Maybe it's the id you're using (the id by itself), it should be a number?

I was able to test and import doing the following with a sample test script. I followed these instructions

relevant portion of my TF file

resource "aptible_database" "pg" {
  env_id = data.aptible_environment.example.env_id
  handle = "example"
  database_type = "postgresql"
  container_size = 512
  disk_size = 10
}

i created it:

terraform plan
terraform apply

then i removed it from my local state

terraform state rm aptible_database.pg
cat terraform.tfstate
# verified it is no longer in my state file

terraform import aptible_database.pg 106610 # got the ID from the dashboard

and it worked without issue:

image