Importing multiple digitalocean droplets

166 views
Skip to first unread message

Martin Cleaver

unread,
Aug 29, 2016, 5:19:08 PM8/29/16
to Terraform
Hi,


Import

Droplets can be imported using the droplet id, e.g.

terraform import digitalocean_droplet.mydroplet 100823
My existing set up has 5 nodes. 

How do I import multiple nodes?

Do I do multiple `import` commands? That results in:
* Can't import digitalocean_droplet.mydroplet, would collide with an existing resource.
 
I assume this digitalocean_droplet.mydroplet reference is a reference to the class of the resource I'm pulling in rather than the identity of the node

The resulting .tfstate document includes:

    "modules": [

        {

            "path": [

                "root"

            ],

            "outputs": {},

            "resources": {

                "digitalocean_droplet.mydroplet": {

                    "type": "digitalocean_droplet",

                    "depends_on": [],

                    "primary": {

                        "id": "9553791",

                        "attributes": {


Or am I supposed to import, and then rename the resource by editing the tfstate file and then edit the subsequent ones?

I tried alternate syntaxes such as multiple IDs on the line... to not avail.

Thanks,
   Martin.

Martin Cleaver

unread,
Aug 29, 2016, 6:49:29 PM8/29/16
to Terraform
Ok. Solved it on IRC, thanks to cornfeedhobo

The solution is:

The thing I missed was that digitalocean_droplet.mydroplet comprises a class "digitalocean_droplet" and an address "mydroplet"

So solution is:

terraform import digitalocean_droplet.droplet1 100823
terraform import digitalocean_droplet.droplet1 100824

Martin Cleaver

unread,
Aug 29, 2016, 7:11:41 PM8/29/16
to Terraform
Or rather:

terraform import digitalocean_droplet.droplet1 100121
terraform
import digitalocean_droplet.droplet2 100824

M.
Reply all
Reply to author
Forward
0 new messages