Importing digital ocean droplet

133 views
Skip to first unread message

Tekchand Dagar

unread,
May 14, 2019, 2:29:34 AM5/14/19
to Terraform
Hello Team,

How we can import a digitalocean droplet which was created manually. Below is my config:

resource "digitalocean_droplet" "manually" {
  name = "manually"
  region = "BLR1"
  image = "Ubuntu 16.04.6 x64"
  }


And i am running the below command:

import digitalocean_droplet.manually 143846668

But i am getting below error:

Error: digitalocean_droplet.manually (import id: 143846668): import digitalocean_droplet.manually (id: 143846668): invalid droplet id: Error retrieving droplet: GET https://api.digitalocean.com/v2/droplets/143846668: 401 Unable to authenticate you.

As per error its seems authentication issue. Because i didn't provide do_token. But later when i am running above command with variable do_token its not working again.

I have tried below command as well:

terraform import digitalocean_droplet.manually -var do_token="8974d358dc1d5391deed5999db714d56ceed2cae6570775474d3f2756799584c"

Can you please help me how we can import digitalocean droplet using import command in terraform.

Thanks
Tek Chand

Personal

unread,
May 14, 2019, 4:31:25 AM5/14/19
to Terraform
What does your provider block fro DigitalOcean look like?

--
Lowe Schmidt | +46 723 867 157
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/805b499e-99ab-4d60-ad6a-ace5e9a659e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tekchand Dagar

unread,
May 14, 2019, 4:41:35 AM5/14/19
to Terraform
Hello Schmidt,

My provider block is look like below:

provider "digitalocean" {
  token = "${var.do_token}"
}
To unsubscribe from this group and stop receiving emails from it, send an email to terrafo...@googlegroups.com.

Tekchand Dagar

unread,
May 14, 2019, 5:55:36 AM5/14/19
to Terraform
Hello Schmidt,

Now i am able to import but when running plan its showing destroy and then recreate replacement. But we can't afford destroy for our server because it will delete all data and configuration.

Can you please help me why terraform destroying it and then recreating? 

Andrew Jeffree

unread,
May 14, 2019, 6:13:54 AM5/14/19
to terrafo...@googlegroups.com
When running a plan it should show what is causing it to want to destroy. You may need to import additional values or similar for it to match the desired state.

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/4d5d4b9e-a999-4cda-807d-9838b9c087dd%40googlegroups.com.

Tekchand Dagar

unread,
May 14, 2019, 6:34:06 AM5/14/19
to Terraform
Hello Andrew,

Thank you for your response. 

After importing i have checked the values in .tfstate file and pick the values from there and put in my main.tf file. Now its not showing any changes and its showing infrastructure is up to date.

Seems now we are in good state.

Thanks.

Reply all
Reply to author
Forward
0 new messages