Giter VIP home page Giter VIP logo

digitalocean / terraform-provider-digitalocean Goto Github PK

View Code? Open in Web Editor NEW
490.0 20.0 258.0 22.57 MB

Terraform DigitalOcean provider

Home Page: https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs

License: Mozilla Public License 2.0

Makefile 0.13% Go 99.72% Shell 0.15%
terraform terraform-provider digitalocean hashicorp cloud infrastructure-as-code hacktoberfest

terraform-provider-digitalocean's Introduction

DigitalOcean Terraform Provider

Requirements

  • Terraform 0.10.x
  • Go 1.14 (to build the provider plugin)

Building The Provider

Clone repository to: $GOPATH/src/github.com/digitalocean/terraform-provider-digitalocean

$ mkdir -p $GOPATH/src/github.com/digitalocean; cd $GOPATH/src/github.com/digitalocean
$ git clone [email protected]:digitalocean/terraform-provider-digitalocean

Enter the provider directory and build the provider

$ cd $GOPATH/src/github.com/digitalocean/terraform-provider-digitalocean
$ make build

Using the provider

See the DigitalOcean Provider documentation to get started using the DigitalOcean provider.

Developing the Provider

See CONTRIBUTING.md for information about contributing to this project.

terraform-provider-digitalocean's People

Contributors

andrewsomething avatar apinonformoso avatar appilon avatar aqche avatar armon avatar asaha2 avatar atombrella avatar aybabtme avatar caiofilipini avatar chiefmatestarbuck avatar danaelhe avatar dependabot[bot] avatar dweinshenker avatar eddiezane avatar grubernaut avatar jen20 avatar mitchellh avatar nicholasjackson avatar pearkes avatar permagate avatar phinze avatar radeksimko avatar roidelapluie avatar scotchneat avatar slapula avatar stack72 avatar tdyas avatar tfaga avatar thefossedog avatar tombuildsstuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-digitalocean's Issues

remote-exec is not working as expected

Terraform Version

Terraform v0.11.7

Affected Resource(s)

  • digitalocean_droplet

Terraform Configuration Files

provider "digitalocean" {
  token = "..."
}

# Upload a SSH Key
resource "digitalocean_ssh_key" "default" {
  name       = "Terra SSH Key"
  public_key = "${file("${path.root}/../../ssh/id_rsa.pub")}"
}

# Create a web server
resource "digitalocean_droplet" "main-instance" {
  image              = "wordpress-16-04"
  name               = "web-1"
  region             = "ams3"
  size               = "s-1vcpu-1gb"
  backups            = false
  private_networking = true
  backups            = false
  ipv6               = false
  ssh_keys           = ["${digitalocean_ssh_key.default.fingerprint}"]

  connection {
    user        = "root"
    type        = "ssh"
    private_key = "${file("${path.root}/../../ssh/id_rsa")}"
  }

  provisioner "remote-exec" {
    inline = [ "sleep 30" ]
  }

  provisioner "remote-exec" {
    script = "${path.root}/init-scripts.sh"
  }

Debug Output

https://gist.github.com/atif089/7b0f0217a87cb07f1b409a0a4849d17f#file-tf-log

Expected Behavior

Remote-Exec script should have uploaded and executed

Actual Behavior

Remote-Exec script was not uploaded and the following error was reported

digitalocean_droplet.main-instance: Failed to upload script: lease wait while we get your droplet ready...

Steps to Reproduce

  1. terraform apply

TERRAFORM CRASH when `private_networking = true` after initial droplet creation

Detailed stderr log at https://gist.github.com/petervandenabeele/c9949fa4590086b998683b1184095755
Detailed crash log at
https://gist.github.com/petervandenabeele/0e788d498c5170a3281b208ede11fdff

Version:

Terraform v0.11.3
+ provider.digitalocean v0.1.3
  1. plan + apply of a Droplet without private_networking: OK

  2. Added private_networking = true

  3. plan => correct (?)

 ~ digitalocean_droplet.test
      private_networking: "" => "true"
  1. apply => CRASH "panic: interface conversion: interface {} is bool, not string"

See log gist for detailed crash log

  1. On a more general note, can a DigitalOcean Droplet even be converted to private networking after it is created ?

DC/OS taking hours to create the master

I am trying to create my DC/OS cluster on digitalocean, when I do terraform apply, it creates the master (I can see the machine on digitalocean) but it is taking hours on this step

digitalocean_droplet.dcos_master: Still creating... (1h11m30s elapsed)

can someone help me please

Return NS records from digitalocean_domain

Terraform Version

Terraform v0.11.1
+ provider.digitalocean v0.1.2

Affected Resource(s)

  • digitalocean_domain

Expected Behavior

domain should export generated NS records

Actual Behavior

domain doesn't export any generated NS records

Terraform prints dependency error instead of actual error if reference misconfigured resource

This issue was originally opened by @Noah-Huppert as hashicorp/terraform#15053. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

$ terraform -v
Terraform v0.9.6

Affected Resource(s)

All? Found bug with:

  • digitalocean_floating_ip
  • digitalocean_record

I believe this is a Terraform core issue.

Terraform Configuration Files

resource "digitalocean_floating_ip" "auto_chess" {
    droplet_id = "${digitalocean_droplet.auto_chess.region}" # <-- Important: This field is intentionally wrong, should cause validation error
    region = "${digitalocean_droplet.auto_chess.region}"
}

resource "digitalocean_domain" "noahhuppert_com" {
    name = "noahhuppert.com"
    ip_address = "${digitalocean_droplet.auto_chess.ipv4_address}" # Not important to issue, defined in other file
}

resource "digitalocean_record" "auto_chess" {
    domain = "${digitalocean_domain.noahhuppert_com.name}"
    name = "auto_chess"
    type = "A"
    value = "${digitalocean_floating_ip.auto_chess.ip_address}"
}

Debug Output

Gist

Panic Output

None

Expected Behavior

Terraform should inform the user that the value they provided for digitalocean_floating_ip.auto_chess.droplet_id is incorrect like so:

* module.auto-chess.digitalocean_floating_ip.auto_chess: droplet_id: cannot parse '' as int: strconv.ParseInt: parsing "nyc3": invalid syntax

Actual Behavior

Terraform claims that digitalocean_floating_ip.auto_chess.ip_address is not found. This causes one to start debugging their code for a link/dependency error (Calling terraform graph, adding depends_on to everything, etc...). Instead of debugging their code for an incorrect digitalocean_floating_ip.auto_chess.droplet_id value.

Steps to Reproduce

  1. Create a resource that is misconfigured
    • In the example above this is the digitalocean_floating_ip.auto_chess
    • The droplet_id parameter is intentionally set to be a digitalocean_droplet's region when it is supposed to be an id.
  2. Create another resource that relies on a parameter of that resource
    • In the example above this is the digitialocean_record.auto_chess
    • It relies on digitalocean_floating_ip.auto_chess.ip_address
  3. terraform plan
  4. Receive a incorrect / not-really-showing-root-problem dependency error
  5. Comment out the resource which is using the misconfigured resource
    • In the example above this would mean commenting out the digitalocean_record
  6. Receive the correct validation error about your misconfigured resource

Important Factoids

Error messages and example code are in a module named auto-chess. Not included in the example code is a digitalocean_droplet named auto_chess, this is not important to the issue.

References

None

(Digitalocean) SSH key with "\n" inside

This issue was originally opened by @vaclavdobsicek as hashicorp/terraform#10083. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.7.10 (MAC)

Affected Resource(s)

  • digitalocean

Terraform Configuration Files

    ssh_keys = [ 
      "${var.ssh_fingerprint_axmn}"
    ]

Expected Behavior

There will be one one-lined ssh pub key in the /root/.ssh/authorized_keys

Actual Behavior

The first line is cut in the place of "\n" and the rest of the string is on the second row.
On the third row is the second row repeated again.

Steps to Reproduce

  1. Upload the SSH pub key which contains "\n" into security section in the Digitalocean control panel
  2. Use fingerprint of this key for creating droplet

Example

Source

        {
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiKopHX6PXJz7wilPm72pN2EQhwt0VIdcaokedede2byiGcvVjrY5k7FObEiX201YaCKgCg3A3k3SR/HuG2tH7Drf26uKYQnq+LEsgVxlcjl0lj+1RcKqQOguEJKXfcj3OrL\nIJrX66/Qlc0MDoVIFo1FWB/adYHa4OM= axmn"
        }

Result (authorized_keys on target machine)

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiKopHX6PXJz7wilPm72pN2EQhwt0VIdcaokedede2byiGcvVjrY5k7FObEiX201YaCKgCg3A3k3SR/HuG2tH7Drf26uKYQnq+LEsgVxlcjl0lj+1RcKqQOguEJKXfcj3OrL
IJrX66/Qlc0MDoVIFo1FWB/adYHa4OM= axmn
IJrX66/Qlc0MDoVIFo1FWB/adYHa4OM= axmn

digitalocean_image artifact ID doesn't match what the DO API expects

This issue was originally opened by @Jalle19 as hashicorp/terraform#4807. It was migrated here as part of the provider split. The original body of the issue is below.


If you use image = "${atlas_artifact.foo.id}" on a digitalocean_droplet resource, applying changes will fail with POST https://api.digitalocean.com/v2/droplets: 422 You specified an invalid image for Droplet creation. This is because atlas_artifact.foo.id resolves to something like fra1:123123 when it should resolve to 123123. Changing the Terraform template to use a hardcoded number makes the apply go through normally.

This makes it cumbersome to use DigitalOcean snapshot artifacts. I've tried both 0.6.9 and 0.6.8 and the issue is the same in both.

Changing ip address in digitalocean_domain erases all digitalocean_record s

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

$ terraform -v
Terraform v0.10.8

Affected Resource(s)

  • digitalocean_domain
  • digitalocean_record

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "digitalocean_domain" "example" {
  name       = "example.com"
  ip_address = "1.2.3.4"
}

resource "digitalocean_record" "bar" {
  domain = "${digitalocean_domain.example.name}"

  count = "${length(digitalocean_droplet.droplets.*.id)}"

  type   = "A"
  name   = "${element(digitalocean_droplet.droplets.*.name, count.index)}"
  ttl    = 600
  value  = "${element(digitalocean_droplet.droplets.*.ipv4_address_private, count.index)}"
}

Expected Behavior

when i have the domain example.com with all its "A" records set and I change the ip_address of the digitalocean_domain resource, i expect all the digitalocean_record resources to be left or re-created if necessary.

Actual Behavior

when the digitalocean_domain's ip_address is changed, the entire resource is destroyed, which means all the digitalocean_record items are also lost. but the plan does not catch this and the DNS records are not re-created until a subsequent terraform run. This is not good, especially if you're not paying attention and DNS is left incomplete. :/

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ digitalocean_domain.example (new resource required)
      id:         "example.com" => <computed> (forces new resource)
      ip_address: "1.2.3.4" => "4.5.6.7" (forces new resource)
      name:       "example.com" => "example.com"


Plan: 1 to add, 0 to change, 1 to destroy.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
  2. change ip_address
  3. terraform plan
  4. terraform apply
  5. see missing record entries
  6. terraform plan
  7. terrraform apply
  8. see all the records come back

Important Factoids

Nothing special

Refreshing state fails when floating IP is missing

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.10.8

Affected Resource(s)

  • digitalocean_floating_ip

Expected Behavior

When invoking terraform refresh and a DigitalOcean floating IP is missing, terraform should mark the floating IP in its state as not existing.

Actual Behavior

Terraform fails with an error due to the DigitalOcean API returning 404 for the floating IP.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply for a configuration with a floating IP
  2. Delete the floating IP manually
  3. terraform refresh

Firewall changes rules order after apply

Terraform Version

Terraform v0.10.8 / master

Affected Resource(s)

  • digitalocean_firewall

Terraform Configuration Files

resource "digitalocean_firewall" "foo" {
  name = "foo"

  droplet_ids = []

  inbound_rule = [
    {
      protocol         = "tcp"
      port_range       = "22"
      source_addresses = ["0.0.0.0/0", "::/0"]
    },
  }
  outbound_rule = [
    {
      protocol              = "tcp"
      port_range            = "all"
      destination_addresses = ["0.0.0.0/0", "::/0"]
    },
    {
      protocol              = "udp"
      port_range            = "all"
      destination_addresses = ["0.0.0.0/0", "::/0"]
    },
    {
      protocol              = "icmp"
      destination_addresses = ["0.0.0.0/0", "::/0"]
    },
  ]
}

Expected Behavior

Terraform should preserve order in which rules were created or sort rules in state in stable order which wouldn't change after apply.

I seem to have narrowed it that it only happens when using port_range = "all",
due to it being converted to "0" in state, so that changes hash calculated here

I'll see if I can work on some fix for this.

Actual Behavior

After apply, on next plan run, it tries to reorder the rules, but apply which would do so fails.
After that apply fails, plan shows no changes need to be made.

  ~ digitalocean_firewall.web
      outbound_rule.0.protocol:   "icmp" => "tcp"
      outbound_rule.1.protocol:   "tcp" => "udp"
      outbound_rule.2.protocol:   "udp" => "icmp"

Steps to Reproduce

terraform apply
terraform plan

Renaming "digitalocean_volume" raises "A volume that's attached to a Droplet cannot be deleted"

This issue was originally opened by @ksanderer as hashicorp/terraform#17964. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.11.7
+ provider.digitalocean v0.1.3
+ provider.external v1.0.0

Terraform Configuration Files

https://gist.github.com/ksanderer/30b6d0edd3518ea0a49088a795a5c9a7

Crash Output

Error: Error applying plan:

2 error(s) occurred:

* digitalocean_volume.hcmc_db: 1 error(s) occurred:

* digitalocean_volume.hcmc_db: Error creating Volume: POST https://api.digitalocean.com/v2/volumes: 409 (request "94fbb17b-b2a3-453c-a1d3-afb4d16b80ab") failed to create volume
* digitalocean_volume.hcmc_admin (destroy): 1 error(s) occurred:

* digitalocean_volume.hcmc_admin: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/fddc7fbd-4b70-11e8-a456-0242ac116408: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

After changing digitalocean_volume name terraform should:

  1. detach the old volume
  2. delete the old volume
  3. create the new volume
  4. attach the new volume

Actual Behavior

Terraform trying to delete volume before detaching it from the droplet.

* digitalocean_volume.hcmc_admin: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/fddc7fbd-4b70-11e8-a456-0242ac116408: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. rename digitalocean_volume name foo -> bar
  4. terraform apply

Apply log

digitalocean_volume.foo: Refreshing state... (ID: 7bd24a9e-4b73-11e8-8a8f-0242ac115908)
digitalocean_ssh_key.default: Refreshing state... (ID: 20353441)
digitalocean_droplet.droplet1: Refreshing state... (ID: 91509324)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
  - destroy

Terraform will perform the following actions:

  ~ digitalocean_droplet.droplet1
      volume_ids.#:  "1" => <computed>

  + digitalocean_volume.bar
      id:            <computed>
      droplet_ids.#: <computed>
      name:          "foo"
      region:        "ams3"
      size:          "1"

  - digitalocean_volume.foo


Plan: 1 to add, 1 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

digitalocean_volume.foo: Destroying... (ID: 7bd24a9e-4b73-11e8-8a8f-0242ac115908)
digitalocean_volume.bar: Creating...
  droplet_ids.#: "" => "<computed>"
  name:          "" => "foo"
  region:        "" => "ams3"
  size:          "" => "1"

Error: Error applying plan:

2 error(s) occurred:

* digitalocean_volume.bar: 1 error(s) occurred:

* digitalocean_volume.bar: Error creating Volume: POST https://api.digitalocean.com/v2/volumes: 409 (request "708463e7-7fda-4d75-9b87-9d41537abc75") failed to create volume
* digitalocean_volume.foo (destroy): 1 error(s) occurred:

* digitalocean_volume.foo: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/7bd24a9e-4b73-11e8-8a8f-0242ac115908: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Crashed while creating DigitalOcean NS records

This issue was originally opened by @snick as hashicorp/terraform#15133. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.9.6

Affected Resource(s)

  • digitalocean_domain
  • digitalocean_record

Terraform Configuration Files

resource "digitalocean_domain" "xxx" {
  name = "xxx"
  ip_address = "${digitalocean_droplet.xxx.ipv4_address}"
}

<-- many a, cname, mx records-->

resource "digitalocean_record" "xxx_txt1" {
  domain = "${digitalocean_domain.xxx.name}"
  type = "TXT"
  name = "@"
  value = "google-site-verification=xxx"
  priority = 10
}

Debug Output

https://gist.github.com/snick/1af3abe993a60639a302c5e1f8331a70

Panic Output

https://gist.github.com/snick/08a531a54a1b9193b2184bb44ec369a8

Expected Behavior

Not crashed

Actual Behavior

Crashed

Steps to Reproduce

  1. terraform apply
  2. That's all

Important Factoids

Nope

References

Nope (maybe)

Downscaling with a digitalocean_loadbalancer fails with a HTTP 422 (but works anyway)

This issue was originally opened by @gak as hashicorp/terraform#14105. It was migrated here as part of the provider split. The original body of the issue is below.


After reducing number_of_servers I see that the droplets start being destroyed before being removed from the DO LB. There seems to be a race condition with the DO API and the droplet states.

However, the LB does remove these decommissioned droplets regardless of the error.

Terraform Version

Terraform v0.9.3

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_droplet
  • digitalocean_loadbalancer

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "digitalocean_droplet" "web" {
  count = "${var.number_of_servers}"
  ...
}

resource "digitalocean_loadbalancer" "lb" {
  name = "lb"
  droplet_ids = ["${digitalocean_droplet.web.*.id}"]
  ...
}

Error

digitalocean_droplet.web.0: Refreshing state... (ID: 47499706)
digitalocean_droplet.web.1: Refreshing state... (ID: 47499705)
digitalocean_droplet.web.3: Refreshing state... (ID: 47500688)
digitalocean_droplet.web.2: Refreshing state... (ID: 47500687)
digitalocean_volume.db: Refreshing state... (ID: e6f40e4a-2e2a-11e7-b8de-0242ac113e03)
digitalocean_loadbalancer.lb: Refreshing state... (ID: 47325264-2809-4565-b35d-64afad610c16)
digitalocean_droplet.web.2: Destroying... (ID: 47500687)
digitalocean_droplet.web.3: Destroying... (ID: 47500688)
digitalocean_droplet.web.3: Still destroying... (ID: 47500688, 10s elapsed)
digitalocean_droplet.web.2: Still destroying... (ID: 47500687, 10s elapsed)
digitalocean_droplet.web.3: Destruction complete
digitalocean_droplet.web.2: Destruction complete
digitalocean_loadbalancer.lb: Modifying... (ID: 47325264-2809-4565-b35d-64afad610c16)
  droplet_ids.#: "4" => "2"
  droplet_ids.2: "47500687" => ""
  droplet_ids.3: "47500688" => ""
Error applying plan:

1 error(s) occurred:

* digitalocean_loadbalancer.lb: 1 error(s) occurred:

* digitalocean_loadbalancer.lb: Error updating Load Balancer: PUT https://api.digitalocean.com/v2/load_balancers/47325264-2809-4565-b35d-64afad610c16: 422 (request "42f55289-3f2d-43e9-8bb5-f7f5bc722e02") Load Balancer can't be updated while it processes previous actions

Expected Behavior

Droplets removed from the LB.

Actual Behavior

An error, but droplets removed from the LB anyway.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply with a node count of 4.
  2. terraform apply with a node count of 2.

can't set priority to 0 for mx in digitalocean_record

This issue was originally opened by @dmitryint as hashicorp/terraform#5069. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform v0.6.11

resource "digitalocean_record" "mx_1" {
    domain = "host.com"
    type = "MX"
    priority = 0
    value = "mx.host.com."
}

When I try to set the priority 0 MX record occurs error message.

Failed to create record: POST https://api.digitalocean.com/v2/domains/host.com/records: 422 Priority is not a number and Priority Priority must be an integer between 0 and 65535

When I changing the priority to another number, e.g. 10, then everything is OK.

Same problem with weight

conditional in array is returning a panic error

This issue was originally opened by @rolele as hashicorp/terraform#11342. It was migrated here as part of the provider split. The original body of the issue is below.


I have this terraform script that is meant to create 3 machine: managers.[0-2] and a block storage

I would like the block storage to be attached to the first manager only

    resource "digitalocean_volume" "myvol-01" {
        region      = "sfo2"
        name        = "myvol-01"
        size        = 1
        description = "an example volume"
    }

    resource "digitalocean_droplet" "managers" {
      count = "${var.managers_size}"
      name = "managers.${count.index}"
      ssh_keys = ["${var.ssh_fingerprint}"]
      region = "sfo2"
      image = "centos-7-x64"
      size = "512mb"
      #### volume_ids = ["${digitalocean_volume.myvol-01.id}"]
    }

I do not know how to conditionally attached the volume only to the first machine.
I tried
volume_ids = "${count.index == 0 ? ["${digitalocean_volume.myvol-01.id}"] : false }"
OR this did not work neither:
volume_ids = ["${count.index == 0 ? "${digitalocean_volume.myvol-01.id}" : ""}"]

someone proposed this:
volume_ids = ["${count.index == 0 ? digitalocean_volume.myvol-01.id : ""}"]

but this is returning a panic error

terraform apply                                                                                                                                                                9:44
digitalocean_volume.myvol-01: Refreshing state... (ID: 3857c233-e06d-11e6-9b24-000f533132d0)
digitalocean_volume.myvol-01: Creating...
  description:   "" => "an example volume"
  droplet_ids.#: "" => "<computed>"
  name:          "" => "myvol-01"
  region:        "" => "sfo2"
  size:          "" => "1"
digitalocean_volume.myvol-01: Creation complete
digitalocean_droplet.managers.0: Creating...
  disk:                 "" => "<computed>"
  image:                "" => "centos-7-x64"
  ipv4_address:         "" => "<computed>"
  ipv4_address_private: "" => "<computed>"
  ipv6_address:         "" => "<computed>"
  ipv6_address_private: "" => "<computed>"
  locked:               "" => "<computed>"
  name:                 "" => "managers.0"
  region:               "" => "sfo2"
  resize_disk:          "" => "true"
  size:                 "" => "512mb"
  ssh_keys.#:           "" => "1"
  ssh_keys.0:           "" => "06:61:3d:44:c7:30:64:d4:32:be:f6:e3:4a:65:c7:6c"
  status:               "" => "<computed>"
  vcpus:                "" => "<computed>"
  volume_ids.#:         "" => "1"
  volume_ids.0:         "" => "6c4dbd2c-e0f4-11e6-a17e-000f5339e930"
digitalocean_droplet.managers.1: Creating...
  disk:                 "" => "<computed>"
  image:                "" => "centos-7-x64"
  ipv4_address:         "" => "<computed>"
  ipv4_address_private: "" => "<computed>"
  ipv6_address:         "" => "<computed>"
  ipv6_address_private: "" => "<computed>"
  locked:               "" => "<computed>"
  name:                 "" => "managers.1"
  region:               "" => "sfo2"
  resize_disk:          "" => "true"
  size:                 "" => "512mb"
  ssh_keys.#:           "" => "1"
  ssh_keys.0:           "" => "06:61:3d:44:c7:30:64:d4:32:be:f6:e3:4a:65:c7:6c"
  status:               "" => "<computed>"
  vcpus:                "" => "<computed>"
  volume_ids.#:         "" => "1"
digitalocean_droplet.managers.2: Creating...
  disk:                 "" => "<computed>"
  image:                "" => "centos-7-x64"
  ipv4_address:         "" => "<computed>"
  ipv4_address_private: "" => "<computed>"
  ipv6_address:         "" => "<computed>"
  ipv6_address_private: "" => "<computed>"
  locked:               "" => "<computed>"
  name:                 "" => "managers.2"
  region:               "" => "sfo2"
  resize_disk:          "" => "true"
  size:                 "" => "512mb"
  ssh_keys.#:           "" => "1"
  ssh_keys.0:           "" => "06:61:3d:44:c7:30:64:d4:32:be:f6:e3:4a:65:c7:6c"
  status:               "" => "<computed>"
  vcpus:                "" => "<computed>"
  volume_ids.#:         "" => "1"
Error applying plan:

3 error(s) occurred:

* digitalocean_droplet.managers.2: unexpected EOF
* digitalocean_droplet.managers.1: unexpected EOF
* digitalocean_droplet.managers.0: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
panic: interface conversion: interface is nil, not string
2017/01/23 09:45:10 [DEBUG] plugin: terraform:
2017/01/23 09:45:10 [DEBUG] plugin: terraform: goroutine 129 [running]:
2017/01/23 09:45:10 [DEBUG] plugin: terraform: panic(0x2ddf660, 0x4265ba100)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4/libexec/src/runtime/panic.go:500 +0x1a1
2017/01/23 09:45:10 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/digitalocean.resourceDigitalOceanDropletCreate(0x426454840, 0x2e45b80, 0x4263e2280, 0x4263d04b0, 0x16444)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /private/tmp/terraform-20161214-2441-3cw6bz/terraform-0.8.0/src/github.com/hashicorp/terraform/builtin/providers/digitalocean/resource_digitalocean_droplet.go:179 +0xe56
2017/01/23 09:45:10 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0x4262aa7e0, 0x42641e0a0, 0x4265ae200, 0x2e45b80, 0x4263e2280, 0x1, 0x4261da000, 0x18)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /private/tmp/terraform-20161214-2441-3cw6bz/terraform-0.8.0/src/github.com/hashicorp/terraform/helper/schema/resource.go:162 +0x30e
2017/01/23 09:45:10 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0x4262aaea0, 0x42641e050, 0x42641e0a0, 0x4265ae200, 0x0, 0x4263d4cf8, 0x18c9b)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /private/tmp/terraform-20161214-2441-3cw6bz/terraform-0.8.0/src/github.com/hashicorp/terraform/helper/schema/provider.go:212 +0x9b
2017/01/23 09:45:10 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0x4265a54c0, 0x4265ae120, 0x4264602d0, 0x0, 0x0)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /private/tmp/terraform-20161214-2441-3cw6bz/terraform-0.8.0/src/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x57
2017/01/23 09:45:10 [DEBUG] plugin: terraform: reflect.Value.call(0x4262aa6c0, 0x425fe1158, 0x13, 0x3445850, 0x4, 0x4266cdee0, 0x3, 0x3, 0x2, 0x4263d4b30, ...)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4/libexec/src/reflect/value.go:434 +0x5c8
2017/01/23 09:45:10 [DEBUG] plugin: terraform: reflect.Value.Call(0x4262aa6c0, 0x425fe1158, 0x13, 0x4266cdee0, 0x3, 0x3, 0x0, 0x425fdb780, 0xb4b670)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4/libexec/src/reflect/value.go:302 +0xa4
2017/01/23 09:45:10 [DEBUG] plugin: terraform: net/rpc.(*service).call(0x42644efc0, 0x42644ef80, 0x4262d5f60, 0x426632880, 0x4265a5660, 0x29aa980, 0x4265ae120, 0x16, 0x29aa9c0, 0x4264602d0, ...)
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4/libexec/src/net/rpc/server.go:383 +0x148
2017/01/23 09:45:10 [DEBUG] plugin: terraform: created by net/rpc.(*Server).ServeCodec
2017/01/23 09:45:10 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4/libexec/src/net/rpc/server.go:477 +0x421
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.2: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.managers.2: unexpected EOF
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[2]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.1: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.managers.1: unexpected EOF
2017/01/23 09:45:10 [DEBUG] plugin: /usr/local/Cellar/terraform/0.8.0/bin/terraform: plugin process exited
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[1]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.0: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred

* digitalocean_droplet.managers.0: unexpected EOF
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[0]
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[0]"
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[2]"
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[1]"
2017/01/23 09:45:10 [INFO] Starting shadow graph walk: walkApply
2017/01/23 09:45:10 [DEBUG] Waiting for shadow graph to complete...
2017/01/23 09:45:10 [DEBUG] vertex 'root.var.digitalocean_token': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.var.workers_size': walking
2017/01/23 09:45:10 [DEBUG] vertex "provider.digitalocean", got dep: "var.digitalocean_token"
2017/01/23 09:45:10 [DEBUG] vertex 'root.var.digitalocean_ssh_key': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.provider.digitalocean': walking
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "var.workers_size"
2017/01/23 09:45:10 [DEBUG] vertex 'root.var.managers_size': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.var.ssh_fingerprint': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.provider.digitalocean': evaluating
2017/01/23 09:45:10 [TRACE] [walkApply] Entering eval tree: provider.digitalocean
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInitProvider
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[1]", got dep: "var.managers_size"
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalOpFilter
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[1]", got dep: "var.ssh_fingerprint"
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[2]", got dep: "var.managers_size"
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalBuildProviderConfig
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSetProviderConfig
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalOpFilter
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalConfigProvider
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: provider.digitalocean
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_volume.myvol-01", got dep: "provider.digitalocean"
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_volume.myvol-01': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_volume.myvol-01': evaluating
2017/01/23 09:45:10 [TRACE] [walkApply] Entering eval tree: digitalocean_volume.myvol-01
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInstanceInfo
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalValidateResource
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalCompareDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApply
2017/01/23 09:45:10 [DEBUG] apply: digitalocean_volume.myvol-01: executing Apply
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalUpdateStateHook
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_volume.myvol-01
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[0]", got dep: "digitalocean_volume.myvol-01"
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[0]", got dep: "var.managers_size"
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[2]", got dep: "digitalocean_volume.myvol-01"
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[1]", got dep: "digitalocean_volume.myvol-01"
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[2]", got dep: "var.ssh_fingerprint"
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[1]': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[2]': walking
2017/01/23 09:45:10 [DEBUG] vertex "digitalocean_droplet.managers[0]", got dep: "var.ssh_fingerprint"
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[0]': walking
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[1]': evaluating
2017/01/23 09:45:10 [TRACE] [walkApply] Entering eval tree: digitalocean_droplet.managers[1]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInstanceInfo
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[2]': evaluating
2017/01/23 09:45:10 [TRACE] [walkApply] Entering eval tree: digitalocean_droplet.managers[2]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInstanceInfo
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalValidateResource
2017/01/23 09:45:10 [DEBUG] vertex 'root.digitalocean_droplet.managers[0]': evaluating
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalDiff
2017/01/23 09:45:10 [TRACE] [walkApply] Entering eval tree: digitalocean_droplet.managers[0]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalSequence
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInstanceInfo
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: terraform.EvalNoop
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalCompareDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalValidateResource
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalCompareDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalValidateResource
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApply
2017/01/23 09:45:10 [DEBUG] apply: digitalocean_droplet.managers.1: executing Apply
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApply
2017/01/23 09:45:10 [DEBUG] apply: digitalocean_droplet.managers.2: executing Apply
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalCompareDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.1: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.managers.1: unexpected EOF
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[1]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.2: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.managers.2: unexpected EOF
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[2]
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalReadState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApply
2017/01/23 09:45:10 [DEBUG] apply: digitalocean_droplet.managers.0: executing Apply
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalIf
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteState
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/01/23 09:45:10 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.managers.0: unexpected EOF
2017/01/23 09:45:10 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.managers.0: unexpected EOF
2017/01/23 09:45:10 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.managers[0]
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[0]"
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[2]"
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "digitalocean_droplet.managers[1]"
2017/01/23 09:45:10 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "var.digitalocean_ssh_key"
2017/01/23 09:45:10 [ERROR] Shadow graph error: 3 error(s) occurred:

Terraform fails with Golang JSON parsing error if tag name is invalid

terraform v0.11.1
digitalocean provider v0.1.3

Affected Resource(s)

  • digitalocean_tag

Terraform Configuration Files

provider "digitalocean" {
  version = "~> 0.1.3"
}

resource "digitalocean_tag" "bad_tag" {
  name = "bad.tag.name"
}

Debug Output

digitalocean_tag.bad_tag: Creating...
  name: "" => "bad.tag.name"

Error: Error applying plan:

1 error(s) occurred:

* digitalocean_tag.bad_tag: 1 error(s) occurred:

* digitalocean_tag.bad_tag: Error creating tag: invalid character 'S' looking for beginning of value

Expected Behavior

If a tag name with unsupported characters is specified for a digitalocean_tag in Terraform, validation should report the cause of the issue with a actionable error message (eg dot is not a support character).

Actual Behavior

Provider propagated an unhelpful Golang JSON parser error message as a result of an unexpected API response.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Using resources from the "terraform_remote_state" forces to recreate "digitalocean_droplet"

External persistant volumes terraform project:

# main.tf
resource "digitalocean_volume" "example" {
  name = "example"
  region = "ams3"
  size = 10
}

# outputs.tf
output "volume-example" {
  value = "${digitalocean_volume.example.id}"
}

Main project uses persistant volumes:

data "terraform_remote_state" "persistent" {
  backend = "local"
  config {
    path = "${path.cwd}/persistent/terraform.tfstate"
  }
}

resource "digitalocean_droplet" "example" {
  count = 1
  name = "example-droplet"
  region = "ams3"
  size = "s-1vcpu-1gb"
  image = "ubuntu"

  do_volume_ids = ["${data.terraform_remote_state.persistent.volume-example}"]
}

Terraform plan:

-/+ digitalocean_droplet.example (tainted) (new resource required)
      id:                   "93652482" => <computed> (forces new resource)
      # === not changed === 
      volume_ids.#:         "1" => "1"
      volume_ids.0:         "60f2dc7a-5777-11e8-a769-0242ac113505" => "60f2dc7a-5777-11e8-a769-0242ac113505"

Despite the fact that id not changed, terraform forces droplet to reprovision.

Changing the size of a volume tries to delete it instead of resize

Terraform Version

$ terraform -v
Terraform v0.11.5
+ provider.digitalocean v0.1.3

Terraform Configuration Files

resource "digitalocean_volume" "pg_vol" {
  name        = "pgdata"
  region      = "lon1"
  size        = 20 
  description = "postgres data volume"
}

resource "digitalocean_droplet" "postgres" {
  image              = "ubuntu-16-04-x64"
  name               = "postgres"
  region             = "lon1"
  size               = "1gb"
  volume_ids         = ["${digitalocean_volume.pg_vol.id}"]
}

Expected Behavior

The volume should be resized.

Actual Behavior

The volume tries to get deleted.

  ~ digitalocean_droplet.postgres
      volume_ids.#:                      "1" => <computed>

-/+ digitalocean_volume.pg_vol (new resource required)
      id:                                "resource_uuid_goes_here" => <computed> (forces new resource)
      description:                       "postgres data volume" => "postgres data volume"
      droplet_ids.#:                     "1" => <computed>
      name:                              "pgdata" => "pgdata"
      region:                            "lon1" => "lon1"
      size:                              "20" => "30" (forces new resource)

Going through with this plan will lead to a 409 error: Volume needs to be detached first.

Steps to Reproduce

  1. terraform apply
  2. Change the size on the digitalocean_volume (pg_vol in this case)
  3. terraform apply

Tags for digital ocean droplets keep changing order

This issue was originally opened by @simaofreitas as hashicorp/terraform#9099. It was migrated here as part of the provider split. The original body of the issue is below.


Hi,

I'm using terraform for managing a set of droplets in digital ocean.
Yesterday I introduced tags (using digitalocean_tag) and everything is working correctly.
The problem is that every time I run terraform plan (or apply) I get changes because the tags keep changing their order inside the tfstate file.

Terraform version: 0.7.3

Example of tags definition:

resource "digitalocean_tag" "staging" {
    name = "staging"
}

resource "digitalocean_tag" "web" {
    name = "web"
}

Example of droplet definition

resource "digitalocean_droplet" "machine01" {
  image              = "ubuntu-14-04-x64"
  name               = "machine01"
  region             = "fra1"
  size               = "16gb"
  private_networking = true
  backups            = true
  tags               = ["${digitalocean_tag.staging.id}", "${digitalocean_tag.web.id}"]

  ssh_keys = [
     ...
  ]
}

When running terraform plan (after I already ran terraform apply) I get this:

~ digitalocean_droplet.machine01
    tags.0: "staging" => "web"
    tags.1: "web" => "staging"

If I apply, the next time I run plan I would get the reverse output. But it always changes.

Couldn't find any open issues about this.

Any ideas?

Thanks a lot

Updating existing DNS record names fails with error about data field needing to end with a .

When updating existing DNS records on DigitalOcean, changing the name of the record results in this error:

Error: Error applying plan:

1 error(s) occurred:

* module.digitalocean_records_<domain>.digitalocean_record.msoid: 1 error(s) occurred:

* digitalocean_record.msoid: Failed to update record: PUT https://api.digitalocean.com/v2/domains/<domain>/records/<record_id>: 422 Data needs to end with a dot (.)

In looking over the API reference, it appears the data field needs to be populated. This is the value field in the resource. Even though value hasn't changed, it needs to be supplied to the API as data. Since no data field is supplied, there is no . at the end of it. I tested this with curl to verify that not supplying it caused the same error and just adding that one extra field with the existing value fixed it.

API reference

data is a required field for updating these records:

A, AAAA, CAA, CNAME, MX, TXT, SRV, NS

Terraform Version

Terraform v0.11.0

  • provider.digitalocean v0.1.2

Affected Resource(s)

  • digitalocean_record

Terraform Configuration Files

Starting resource:

resource "digitalocean_record" "msoid" {
  domain  = "${var.domain_name}"
  name    = "msoid"
  type    = "CNAME"
  ttl     = "300"
  value   = "clientconfig.microsoftonline-p.net."
}

Example change to cause error:

resource "digitalocean_record" "msoid" {
  domain  = "${var.domain_name}"
  name    = "msoid.test"
  type    = "CNAME"
  ttl     = "300"
  value   = "clientconfig.microsoftonline-p.net."
}

Expected Behavior

The record name should have been changed to msoid.test.

Actual Behavior

* digitalocean_record.msoid: Failed to update record: PUT https://api.digitalocean.com/v2/domains/<domain>/records/<record_id>: 422 Data needs to end with a dot (.)

Steps to Reproduce

  1. terraform apply
  2. Change record name
  3. terraform apply

priority is required when domain record type is MX or SRV

This issue was originally opened by @tvaughan as hashicorp/terraform#2561. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform's DigitialOcean domain_record documentation says that priority is optional. DigitalOcean's API documentation says that priority is required if the domain record type is MX or SRV. When priority is not provided in a terraform plan and it is required by the DigitalOcean API, this is the error:

* Failed to create record: Error creating record: API Error: unprocessable_entity: Priority is not a number and Priority Priority must be an integer between 0 and 65535

Tested on:

$ terraform --version
Terraform v0.5.3
$ lsb_release -a
No LSB modules are available.  
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:        15.04
Codename:       vivid
$ uname -m
x86_64

To reproduce:

resource "digitalocean_domain" "example" {
  ip_address = "127.0.0.1"
  name = "example.com"
}

resource "digitalocean_droplet" "mail" {
  image = "ubuntu-15-04-x64"
  name = "mail.${digitalocean_domain.example.name}"
  region = "nyc1"
  size = "512mb"
  ssh_keys = ["8675309"]
}

resource "digitalocean_record" "mail" {
  domain = "${digitalocean_domain.example.name}"
  name = "mail"
  type = "A"
  value = "${digitalocean_droplet.mail.ipv4_address}"
}

resource "digitalocean_record" "mx" {
  domain = "${digitalocean_domain.example.name}"
  type = "MX"
  value = "${digitalocean_record.mail.name}"
}

I'd like to submit a pull-request to resolve this. Should the DigitalOcean provider require priority, or provide a default value, like 10, when type is MX or SRV? FWIW - I assumed terraform would provide a default.

Terraform restarts node when applying default `resize_disk` value `true`

This issue was originally opened by @nikoren as hashicorp/terraform#14687. It was migrated here as part of the provider split. The original body of the issue is below.


Hi, I'm trying to upgrade terraform from 0.7 to 0.9.3 ,
Once I switch to new version terraform identifies that there is no resize_disk value in my current state:

~ digitalocean_droplet.stage-share-xxxx.1
    resize_disk: "" => "true"
  • according to [documentation (https://www.terraform.io/docs/providers/do/r/droplet.html#resize_disk) - this setting controls wether to allow or not disk increase, I couldn't see any possible impact by applying this change.

  • When I try to apply the change , the node is restarted, and in digital_ocean console I can see the following history:

Event	Initiated	Execution	Time
Power On	1 hour ago	6 seconds
Resize	2 hours ago	17 minutes 19 seconds
Power Off	2 hours ago	11 seconds
Create	1 month ago	20 seconds
  • I think terraform tries to go and resize the disk to same size which involves node restart even though no changes were done in configuration.

  • I believe terraform should not restart node and only update state in scenario when actual disk wasn't changed or maybe documentation should be more clear about the fact that node gets restarted when no changes were made to disk configuration.

Terraform constantly tries to swap tags on droplets

Hi, when I have droplets with two tags, terraform constantly tries to reorder the tags:

  ~ digitalocean_droplet.consul1
      tags.0: "consul_bootstrap" => "consul_instances"
      tags.1: "consul_instances" => "consul_bootstrap"

Terraform Version

Terraform v0.11.5

  • provider.digitalocean v0.1.3

Terraform Configuration Files

resource "digitalocean_tag" "consul_instances" {
    name = "consul_instances"
} 
resource "digitalocean_tag" "consul_bootstrap" {
    name = "consul_bootstrap"
}

resource "digitalocean_droplet" "consul1" {
    image = "ubuntu-16-04-x64"
    name = "consul1"
    region = "fra1"
    size = "s-1vcpu-1gb"
    ssh_keys = ["${var.ssh_fingerprint}"]
    user_data = "${file("minimal.conf")}"
    tags   = ["${digitalocean_tag.consul_instances.id}", "${digitalocean_tag.consul_bootstrap.id}"]
}

Expected Behavior

Tags order should not affect anything.

Steps to Reproduce

  1. terraform apply
  2. terraform plan, terraform apply and terraform plan again. Terraform will never show you an empty execution plan.

digitalocean_record MX generates invalid state

This issue was originally opened by @danielsreichenbach as hashicorp/terraform#10333. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.7.12

Affected Resource(s)

  • digitalocean_record

Terraform Configuration Files

resource "digitalocean_domain" "acme" {
   name        = "acme.com"
   ...
}

resource "digitalocean_record" "mx-acme-mx" {
  domain    = "${digitalocean_domain.acme.name}"
  type      = "MX"
  priority  = 1
  value     = "mx.acme.com."
}

Expected Behavior

This should generated a domain named acme.com with a MX record pointing to mx.acme.com, and store the state correctly.

Actual Behavior

Generates domain and MX record properly but terraform.tfstate is broken afterwards, it will contain

                        "attributes": {
                            "domain": "acme",
                            "fqdn": "@.acme.com",
                            "id": "19638502",
                            "name": "@",
                            "port": "0",
                            "priority": "1",
                            "type": "MX",
                            "value": "mx.acme.com.acme.com.",
                            "weight": "0"
                        }

Changing the resource configuration to this

resource "digitalocean_record" "mx-acme-mx" {
  domain    = "${digitalocean_domain.acme.name}"
  type      = "MX"
  priority  = 1
  value     = "mx."
}

will properly generate a state of

                         "attributes": {
                             "domain": "acme.com",
                             "fqdn": "@.acme.com",
                            "id": "19638637",
                             "name": "@",
                             "port": "0",
                             "priority": "1",
                             "type": "MX",
                            "value": "mx.acme.com.",
                             "weight": "0"
                         },

Executing terraform plan before and afterwards will however always result in this plan:

-/+ digitalocean_record.mx-acme-mx
    domain:   "acme.com" => "acme.com"
    fqdn:     "@.acme.com" => "<computed>"
    name:     "@" => ""
    port:     "0" => "<computed>"
    priority: "1" => "1"
    type:     "MX" => "MX"
    value:    "mx.acme.com.acme.com." => "mx." (forces new resource)
    weight:   "0" => "<computed>"

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Add Support for Spaces

DO just got support for spaces. Spaces are essentially S3 buckets but provided by digital ocean.

Error digitalocean_droplet.node.1: diffs didn't match during apply.

This issue was originally opened by @onorua as hashicorp/terraform#15195. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.9.8

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_droplet

Error during apply

Terraform Version: 0.9.8
    Resource ID: digitalocean_droplet.node.1
    Mismatch reason: extra attributes: size, resize_disk, private_networking, image
    Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"locked":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ssh_keys.0":*terraform.ResourceAttrDiff{Old:"", New:"95:c9:42:d5:a2:4a:ad:80:5b:f9:80:c5:4f:92:e2:59", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"molochko-sfo2-dev1-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv4_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv4_address_private":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "price_monthly":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "status":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv6_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "region":*terraform.ResourceAttrDiff{Old:"", New:"sfo2", NewComputed:false, NewRemoved:false, NewExtra:"sfo2", RequiresNew:true, Sensitive:false, Type:0x0}, "vcpus":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "disk":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ssh_keys.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv6_address_private":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "price_hourly":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:true, DestroyTainted:false, Meta:map[string]interface {}(nil)}
    Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"ssh_keys.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "size":*terraform.ResourceAttrDiff{Old:"", New:"4gb", NewComputed:false, NewRemoved:false, NewExtra:"4Gb", RequiresNew:false, Sensitive:false, Type:0x0}, "resize_disk":*terraform.ResourceAttrDiff{Old:"", New:"true", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vcpus":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "image":*terraform.ResourceAttrDiff{Old:"", New:"25448024", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "ssh_keys.0":*terraform.ResourceAttrDiff{Old:"", New:"95:c9:42:d5:a2:4a:ad:80:5b:f9:80:c5:4f:92:e2:59", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "private_networking":*terraform.ResourceAttrDiff{Old:"", New:"true", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv6_address_private":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "disk":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv4_address_private":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "region":*terraform.ResourceAttrDiff{Old:"", New:"sfo2", NewComputed:false, NewRemoved:false, NewExtra:"sfo2", RequiresNew:true, Sensitive:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"molochko-sfo2-dev1-1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "price_hourly":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "status":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "locked":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "price_monthly":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv6_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ipv4_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}

Also include as much context as you can about your config, state, and the steps you performed to trigger this error.

Resource config

resource "digitalocean_droplet" "node" {
  name   = "${var.name_prefix}-${count.index}"
  image  = "${coalesce("${var.image}","ubuntu-16-04-x64")}"
  region = "${element(split(",", coalesce(var.location,"nyc3")), count.index)}"
  size   = "${coalesce("${var.size}","512mb")}"
  count  = "${lookup(map("do", "${var.nodes}"), "${var.provider}" , "0")}"
  private_networking = "true"
  ssh_keys = [ "${module.creds.do_ssh_fingerprint}" ]

 # lifecycle {
 #   create_before_destroy = true
 #   ignore_changes = ["image","private_networking","resize_disk","size"]
 # }

  connection {
    user = "${coalesce("${var.user}","root")}"
    type = "ssh"
    private_key = "${module.creds.do_priv_key}"
    timeout = "2m"
    port = "${var.ssh_port}"
  }
  provisioner "remote-exec" {
    inline = [
      "mkdir -p /tmp/hooks"
    ]
  }
}

I believe this is due to:

  lifecycle {
    create_before_destroy = true
    ignore_changes = ["image","private_networking","resize_disk","size"]
  }

as the error reflect ignore_changes part.

DigitalOcean provider should allow specifying SSH key by name

This issue was originally opened by @carmstrong as hashicorp/terraform#3058. It was migrated here as part of the provider split. The original body of the issue is below.


Currently, we must specify the SSH key by its ID or fingerprint, which is only available by querying the DO API. This is a less than ideal user experience.

With the DO API, we can enumerate all keys on an account. We should allow SSH keys to be specified by name as well as by ID.

provider/digitalocean: Add monitoring attribute

This issue was originally opened by @skovorodkin as hashicorp/terraform#13376. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

v0.9.2

Affected Resource(s)

  • digitalocean_droplet

Terraform Configuration Files

provider "digitalocean" {
  token = "TOKEN"
}
resource "digitalocean_droplet" "droplet-1" {
  image = "ubuntu-16-04-x64"
  name = "droplet-01"
  region = "nyc3"
  size = "512mb"
  monitoring = true
}

Expected Behavior

A new droplet should be created with Monitoring enabled.

Actual Behavior

1 error(s) occurred:

* digitalocean_droplet.droplet-1: : invalid or unknown key: monitoring

Steps to Reproduce

  1. terraform plan

DigitalOcean API allows to enable Monitoring while creating a new droplet.

Godo already has the necessary field.

fqdn for the record doesn't match DO

When generating record with the following file:

resource "digitalocean_record" "mars" {
  domain     = "cyber.fund"
  type       = "A"
  name       = "mars.cyber.fund"
  value      = "93.125.26.210"
}

terraform show then outputs mars.cyber.fund as fqdn:

digitalocean_record.mars:
  id = 29299392
  domain = cyber.fund
  fqdn = mars.cyber.fund
  name = mars.cyber.fund
...

But DigitalOcean records it is mars.cyber.fund.cyber.fund.

Terraform Version

v.10.7

Affected Resource(s)

  • digitalocean_record

Droplet Import doesn't set everything

Terraform Version

Terraform v0.11.3

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_droplet

Command Run

$ terraform import digitalocean_droplet.db-ref-nyc3-04 83792719
digitalocean_droplet.db-ref-nyc3-04: Importing from ID "83792719"...
digitalocean_droplet.db-ref-nyc3-04: Import complete!
  Imported digitalocean_droplet (ID: 83792719)
digitalocean_droplet.db-ref-nyc3-04: Refreshing state... (ID: 83792719)

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Expected Behavior

I should be able to run terraform apply -target digitalocean_droplet.db-ref-nyc3-04 and not get any changes

Actual Behavior

-/+ digitalocean_droplet.db-ref-nyc3-04 (new resource required)
      id:                   "83792719" => <computed> (forces new resource)
      image:                "" => "ubuntu-16-04-x64" (forces new resource)
      resize_disk:          "" => "true"
      ssh_keys.#:           "" => "1"
      ssh_keys.0:           "" => "895316"

We are missing

  • image
  • resize_disk
  • ssh_keys

Deleting volume ERROR

Hi,

Terraform Version

Terraform v0.9.11

with this simple recipe:

provider "digitalocean" {
  token = "${var.digitalocean_token}"
}

resource "digitalocean_volume" "docker_bootstrap" {
  region      = "${var.region}"
  name        = "docker"
  size        = 2
  description = "docker volume"
}

resource "digitalocean_droplet" "dcos_bootstrap" {
  name = "${format("${var.dcos_cluster_name}-bootstrap-%02d", count.index)}"

  image = 25718515
  size = "${var.boot_size}"
  depends_on = ["digitalocean_volume.docker_bootstrap"]
  volume_ids = ["${digitalocean_volume.docker_bootstrap.id}"]
  ssh_keys = ["${var.ssh_key_fingerprint}"]
  private_networking = true
  connection {
    user = "root"
    private_key = "${file(var.dcos_ssh_key_path)}"
  }
  user_data     = "#cloud-config\n\nssh_authorized_keys:\n  - \"${file("${var.dcos_ssh_public_key_path}")}\"\n"
  region      = "${var.region}"
}

After successful run of terraform apply and a consequent run of terraforom destroyย I get the following error:

Error applying plan:

1 error(s) occurred:

* digitalocean_volume.docker_bootstrap (destroy): 1 error(s) occurred:

* digitalocean_volume.docker_bootstrap: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/ed9d6674-7389-11e7-9bdc-0242ac110704: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

There is probably a timing issue because the order of destroying seems to be legit.

digitalocean_volume.docker_bootstrap: Refreshing state... (ID: ed9d6674-7389-11e7-9bdc-0242ac110704)
digitalocean_droplet.dcos_bootstrap: Refreshing state... (ID: 56571893)
digitalocean_droplet.dcos_bootstrap: Destroying... (ID: 56571893)
digitalocean_droplet.dcos_bootstrap: Still destroying... (ID: 56571893, 10s elapsed)
digitalocean_droplet.dcos_bootstrap: Destruction complete
digitalocean_volume.docker_bootstrap: Destroying... (ID: ed9d6674-7389-11e7-9bdc-0242ac110704)

Allow Assign Existing Float IP to New Droplet

This issue was originally opened by @miry as hashicorp/terraform#9353. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.7.4

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_floating_ip
  • digitalocean_droplet

There are no example describes how to assign existing Float Ip resource to new droplet. https://www.terraform.io/docs/providers/do/r/floating_ip.html

It would great to have similar solution as for aws_eip: https://www.terraform.io/docs/providers/aws/r/eip_association.html

Example:

resource "digitalocean_floating_ip_association" "ip_assoc" {
  instance_id = "${digitalocean_droplet.web.id}"
  allocation_id = "${digitalocean_floating_ip.example.id}"
}

or provide ip in digitalocean_droplet resource:

resource "digitalocean_droplet" "web" {
  ...
  float_ips = ["${digitalocean_floating_ip.example.id}"]
  ...
}

it's possible use without terraform app?

Hi there,

sorry for asking here, and please, let me know if there is a better place to ask.

It's possible to call this plugin without the terraform cli?

I'm trying to use this plugin in a custom app in golang that launches some machines on Digital Ocean. It's possible to use it without the terraform?

Any advise here?

thanks

DigitalOcean volume - prevent deletion (detach only) on destroy

Is it possible somehow to prevent DO volume deletion on terraform destroy (or any other action that may force to delete the volume - resize, etc..)?

It will be awesome to have DO volume attribute detach_only = true/false to be sure that persistent volume with sensitive data can't be deleted with other infrastructure.

resource "digitalocean_volume" "foobar" {
  region      = "nyc1"
  name        = "baz"
  size        = 100
  description = "an example volume"
  detach_only = true
}

I think this behavior would be useful for other cloud providers as well (aws, google, etc)

There is parameter lifecycle.prevent_destroy, but it's just bloks the operation and not really useful for that kind of workflows.

Tags crashing

Hi there,

Terraform Version

Terraform v0.10.6

Terraform Configuration Files

https://gist.github.com/matt40k/9086a7e0de6d38a4b7e970b5fdadba81#file-do-basicdroplet-tf

https://gist.github.com/matt40k/9086a7e0de6d38a4b7e970b5fdadba81#file-do-dropletwithfirewall-tf

Debug Output

First config returns:
'''
Error applying plan:

1 error(s) occurred:

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
'''

Second config returns

Error applying plan:

2 error(s) occurred:

* digitalocean_firewall.web: 1 error(s) occurred:

* digitalocean_firewall.web: unexpected EOF
* digitalocean_droplet.web: 1 error(s) occurred:

* digitalocean_droplet.web: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resour

panic: interface conversion: interface {} is nil, not string
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: goroutine 61 [running]:
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.expandFirewallInboundRules(0xc042032000, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:313 +0xcb7
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.firewallRequest(0xc042032000, 0xc042194c00, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:296 +0x485
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/digitalocean.resourceDigitalOceanFirewallCreate(0xc042032000, 0xa881e0, 0xc042194c00, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/digitalocean/resource_digitalocean_firewall.go:156 +0x6c
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0423f0360, 0xc0420dc3c0, 0xc0420026a0, 0xa881e0, 0xc042194c00, 0x1, 0x28, 0xc04245f5f0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/helper/schema/resource.go:186 +0x494
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/helper/schema.(*Pro
vider).Apply(0xc042382850, 0xc0420dc280, 0xc0420dc3c0, 0xc0420026a0, 0x220db0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/helper/schema/provider.go:242 +0xa2
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: github.com/terraform-providers/terraform-provider-digitalocean/vendor/github.com/hashicorp/terraform/plugin.(*ResourcePr
oviderServer).Apply(0xc0423cfd20, 0xc042002320, 0xc04200d490, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-digitalocean/vendor
/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x5e
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: reflect.Value.call(0xc04223e0c0, 0xc0420e36f0, 0x13, 0xb293e4, 0x4, 0xc0422abf20, 0x3, 0x3, 0x0, 0x0, ...)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /usr/local/go/src/reflect/value.go:434 +0x926
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: reflect.Value.Call(0xc04223e0c0, 0xc0420e36f0, 0x13, 0xc0422abf20, 0x3, 0x3, 0x0, 0x0, 0x0)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /usr/local/go/src/reflect/value.go:302 +0xab
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: net/rpc.(*service).call(0xc0423ddfc0, 0xc0423ddf80, 0xc0423ec5b8, 0xc0420e8d00, 0xc04233b2e0, 0xa116a0, 0xc042002320, 0x
16, 0xa116e0, 0xc04200d490, ...)
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /usr/local/go/src/net/rpc/server.go:387 +0x14b
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe: created by net/rpc.(*Server).ServeCodec
2017-09-29T14:38:12.414+0100 [DEBUG] plugin.terraform-provider-digitalocean_v0.1.2_x4.exe:      /usr/local/go/src/net/rpc/server.go:481 +0x40b
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalIf
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteDiff
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyPost
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_firewall.web: unexpected EOF
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_firewall.web: unexpected EOF
2017/09/29 14:38:12 [TRACE] [walkApply] Exiting eval tree: digitalocean_firewall.web
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalIf
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteState
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalWriteDiff
2017/09/29 14:38:12 [TRACE] root: eval: *terraform.EvalApplyPost
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* digitalocean_droplet.web: unexpected EOF
2017/09/29 14:38:12 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* digitalocean_droplet.web: unexpected EOF
2017/09/29 14:38:12 [TRACE] [walkApply] Exiting eval tree: digitalocean_droplet.web
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "provider.digitalocean (close)"
2017/09/29 14:38:12 [TRACE] dag/walk: upstream errored, not walking "root"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017-09-29T14:38:12.424+0100 [DEBUG] plugin: plugin process exited: path=C:\git\terraform\.terraform\plugins\windows_amd64\terraform-provider-digitalocean_v0.1.2_x4.exe
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [TRACE] Preserving existing state lineage "1be62308-8623-4224-b15d-9c662ba2697b"
2017/09/29 14:38:12 [DEBUG] plugin: waiting for all plugin processes to complete...
2017-09-29T14:38:12.527+0100 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
2017-09-29T14:38:12.549+0100 [DEBUG] plugin: plugin process exited: path=C:\git\terraform\.terraform\plugins\windows_amd64\terraform-provider-http_v1.0.0_x4.exe

ces that successfully compl

e!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
ted. Please address the error
above and apply again to incrementally change your infrastructure.

Terraform detects change between record and local state file

Terraform Version

Versions:
Terraform: v0.11.1
Digitalocean provider: v0.1.3

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_record

Terraform Configuration Files

Two small files to reproduce:

main.tf

provider "digitalocean" {
  token = "${var.digitalocean_token}"
}

resource "digitalocean_domain" "domain" {
  name       = "${var.domain}"
  ip_address = "${var.ip_address}"
}

resource "digitalocean_record" "www" {
  domain = "${digitalocean_domain.domain.name}"
  type   = "CNAME"
  name   = "www"
  value  = "@"
  ttl    = "43200"
}

vars.tf

variable "digitalocean_token" {
  description = "The token used to authenticate against the Digital Ocean environment"
  default = "COPYPASTE"
}

variable "domain" {
  description = "The domain to add to digital ocean"
  default = "COPYPASTE"
}

variable "ip_address" {
  description = "The ip address to direct traffic too"
  default = "COPYPASTE"
}

Expected Behavior

After the initial creation of the resource with terraform apply, any subsequent terraform apply or terraform plan should show up with no changes required.

Actual Behavior

After the initial creation whenever I do terraform plan or terraform apply changes are found which cause the resource to be destroyed and recreated. This should not be the case. Ignoring the fact the resource is destroyed and recreated, terraform should not detect any changes between terraform.tfstate & Digital Ocean.

The output from the simple files above is:

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

digitalocean_domain.domain: Refreshing state... (ID: example.domain)
digitalocean_record.www: Refreshing state... (ID: ######)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ digitalocean_record.www (new resource required)
      id:       "######" => <computed> (forces new resource)
      domain:   "example.domain" => "example.domain"
      fqdn:     "www.example.domain" => <computed>
      name:     "www" => "www"
      port:     "0" => <computed>
      priority: "0" => <computed>
      ttl:      "43200" => "43200"
      type:     "CNAME" => "CNAME"
      value:    "example.domain." => "@" (forces new resource)
      weight:   "0" => <computed>


Plan: 1 to add, 0 to change, 1 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

Steps to Reproduce

Using main.tf & vars.tf above

  1. terraform apply (Initial Create)
  2. terraform plan

Deleting DigitalOcean droplets fails for terraform destroy

This issue was originally opened by @aknuds1 as hashicorp/terraform#14329. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.9.4

Affected Resource(s)

  • digitalocean_droplet

Terraform Configuration Files

Tectonic Installer Terraform config for DigitalOcean

Debug Output

Debug log gist

Expected Behavior

I am trying to delete my DigitalOcean droplets created with Terraform, via terraform destroy.

Actual Behavior

Terraform bails with an error per droplet it's trying to delete: digitalocean_droplet.etcd_node.0: Error deleting droplet: invalid character 'S' looking for beginning of value.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Clone the Tectonic Installer repository into $GOPATH/src/github.com/coreos/tectonic-installer
  2. Install Yarn
  3. Create DigitalOcean droplets: PLATFORM=digitalocean make apply
  4. Delete DigitalOcean droplets: PLATFORM=digitalocean make destroy

DigitalOcean new image type

Issue:
When specifying size, it is not possible (or not documented well enough), how to use new size-slugs.
From what I know about terraform, it seems that it is then not possible to instantiate "optimised droplets".
Unfortunately, it seems that these instances are required to deploy coreos on digitalocean.
Consequently, script that used to work to deploy cluster (kubernetes, dc/os,...) , can't be fixed to start with the right droplet.
Suggested fix: Allow "size" to be a "size_slug", or clarify how it can work.

More precisely if I pass the size_slug as "size" in the provising, digitalocean API complains that a size_slug has been passed where only size was expected, if we try to pass a size_slug in provisioning then terraform complains about size_slug being an unknown key.

digitalocean_volume refuses to delete attached volume in destroy action

Terraform Version and OS version

$ terraform -v
Terraform v0.9.9

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.11.6
BuildVersion:	15G1217

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_volume
  • digitalocean_droplet

Terraform Configuration Files

variable "digitalocean_token" {
  description = "This is the Digitalocean API-token which is used to setup the machines."
}
variable "digitalocean_region" {
  description = "For example: nyc1, nyc2, ams2, ams3, fra2"
  default = "fra1"
}
variable "digitalocean_dokku_size" {
  description = "Instance size: 512mb, 1gb, 2gb, 4gb ..."
  default = "2gb"
}
variable "digitalocean_volume_size" {
  description = "We will attach permanent volume for persistent data. You can provide size of that volume here"
  default = "100"
}

variable "digitalocean_dokku_domain_tld" {
  description = <<EOF
Main TLD for this dokku installation like: example.com
Subdomain of that domain are used for dokku and apps.
NOTE: THIS DOMAIN NEEDS TO BE SETUPPED IN DIGITALOCEAN DOMAINS!
EOF
}

variable "digitalocean_dokku_subdomain" {
  description = <<EOF
Write any subdomain of the domain you provided for: var.digitalocean_dokku_domain
This will be used for this dokku installation and subdomains of that domain will be used to apps running in dokku.
For example writing: 'dokku-test.something' would result in dokku server => 'dokku-test.something.example.com'
EOF
}

variable "initial_ssh_key" {
  description = "Public SSH Key which is installed into the server during initial setup"
}

# Configure the DigitalOcean Provider
provider "digitalocean" {
  token = "${var.digitalocean_token}"
}

resource "digitalocean_ssh_key" "pihvi" {
  name  = "Pihvi.io Deployment key"
  public_key = "${var.initial_ssh_key}"
}

# Add volume for persistent data
resource "digitalocean_volume" "dokku_persistent_data" {
  region      = "${var.digitalocean_region}"
  name        = "persistent-${replace("${var.digitalocean_dokku_subdomain}.${var.digitalocean_dokku_domain_tld}",".","-")}"
  size        = "${var.digitalocean_volume_size}"
  description = "Persistent data for ${var.digitalocean_dokku_subdomain}.${var.digitalocean_dokku_domain_tld}"
}

# Create a new Dokku Droplet
resource "digitalocean_droplet" "dokku" {
  # Ubuntu is the prefered installation for dokku
  image     = "ubuntu-16-04-x64"

  # This is also the hostname and FQDN of the machine
  name      = "${var.digitalocean_dokku_subdomain}.${var.digitalocean_dokku_domain_tld}"
  region    = "${var.digitalocean_region}"
  size      = "${var.digitalocean_dokku_size}"
  ssh_keys  = [ "${digitalocean_ssh_key.pihvi.id}" ]
  ipv6      = true

  # Attach persistent volume
  volume_ids = ["${digitalocean_volume.dokku_persistent_data.id}"]

  user_data = <<EOF
#cloud-config
manage-resolv-conf: true
resolv_conf:
  nameservers:
    - '8.8.8.8'
    - '8.8.4.4'
EOF
}

# Add floating ip for safe system updates
resource "digitalocean_floating_ip" "dokku" {
  droplet_id = "${digitalocean_droplet.dokku.id}"
  region     = "${digitalocean_droplet.dokku.region}"
}

# Enable IPv4 (with floating ip-address)
resource "digitalocean_record" "dokku_ipv4" {
  domain = "${var.digitalocean_dokku_domain_tld}"
  type   = "A"
  name   = "${var.digitalocean_dokku_subdomain}"
  value  = "${digitalocean_floating_ip.dokku.ip_address}"
}

# Enable IPv6 (non floating ip-address)
# To enable flaoting IPv6, Please vote for: https://digitalocean.uservoice.com/forums/136585-digitalocean/suggestions/10513887-floating-ip-ipv6
resource "digitalocean_record" "dokku_ipv6" {
  domain = "${var.digitalocean_dokku_domain_tld}"
  type   = "AAAA"
  name   = "${var.digitalocean_dokku_subdomain}"
  value  = "${digitalocean_droplet.dokku.ipv6_address}"
}

# Enable CNAME for all subdomains
resource "digitalocean_record" "dokku_subdomains" {
  domain = "${var.digitalocean_dokku_domain_tld}"
  type   = "CNAME"
  name   = "*.${var.digitalocean_dokku_subdomain}"
  value  = "${var.digitalocean_dokku_subdomain}.${var.digitalocean_dokku_domain_tld}."
}

Debug Output

$ terraform destroy -var-file=dokku.tfvars .
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

digitalocean_ssh_key.pihvi: Refreshing state... (ID: 10391475)
digitalocean_record.dokku_subdomains: Refreshing state... (ID: 25666030)
digitalocean_volume.dokku_persistent_data: Refreshing state... (ID: 121bfff2-5c0a-11e7-ab87-0242ac116705)
digitalocean_droplet.dokku: Refreshing state... (ID: 53302108)
digitalocean_droplet.dokku: Destroying... (ID: 53302108)
digitalocean_record.dokku_subdomains: Destroying... (ID: 25666030)
digitalocean_record.dokku_subdomains: Destruction complete
digitalocean_droplet.dokku: Still destroying... (ID: 53302108, 10s elapsed)
digitalocean_droplet.dokku: Destruction complete
digitalocean_volume.dokku_persistent_data: Destroying... (ID: 121bfff2-5c0a-11e7-ab87-0242ac116705)
digitalocean_ssh_key.pihvi: Destroying... (ID: 10391475)
digitalocean_ssh_key.pihvi: Destruction complete
Error applying plan:

1 error(s) occurred:

* digitalocean_volume.dokku_persistent_data (destroy): 1 error(s) occurred:

* digitalocean_volume.dokku_persistent_data: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/121bfff2-5c0a-11e7-ab87-0242ac116705: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

I wanted to delete the attached digitalocean volume after testing.

Actual Behavior

Destroy action failed to remove the attached volume.

New firewall resource always thinks changes need to be made.

Hi,

I've noticed a problem with the outbound rule in the new firewall resource. terraform apply wants to modify this outbound rule every time where instead it should say no changes need to be made.

Terraform Version

$ terraform -version
Terraform v0.10.0

Affected Resource(s)

  • digitalocean_firewall

Terraform Configuration Files

See also: https://gitlab.com/tvaughan/terraform-digitalocean-starterkit/blob/master/firewalls.tf

# -*- coding: utf-8; mode: terraform -*-

resource "digitalocean_firewall" "starterkit_firewall" {
  name = "allow-outbound-ssh-http-https"

  droplet_ids = [
    "${digitalocean_droplet.starterkit_droplet.id}",
  ]

  inbound_rule = [
    {
      protocol   = "tcp"
      port_range = "22"

      source_addresses = [
        "0.0.0.0/0",
        "::/0",
      ]
    },
    {
      protocol   = "tcp"
      port_range = "80"

      source_addresses = [
        "0.0.0.0/0",
        "::/0",
      ]
    },
    {
      protocol   = "tcp"
      port_range = "443"

      source_addresses = [
        "0.0.0.0/0",
        "::/0",
      ]
    },
  ]

  outbound_rule = [
    {
      protocol   = "tcp"
      port_range = "all"

      destination_addresses = [
        "0.0.0.0/0",
        "::/0",
      ]
    },
    {
      protocol   = "udp"
      port_range = "53"  # DNS

      destination_addresses = [
        "0.0.0.0/0",
        "::/0",
      ]
    },
  ]
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

Terraform should say that no changes need to be made if this plan is run more than once.

Actual Behavior

Terraform repeatedly tries to update the outbound rule:

~ digitalocean_firewall.starterkit_firewall
    outbound_rule.0.port_range: "53" => "all"
    outbound_rule.0.protocol:   "udp" => "tcp"
    outbound_rule.1.port_range: "0" => "53"
    outbound_rule.1.protocol:   "tcp" => "udp"

If I look at the firewall in my DigitalOcean dashboard I see that everything has already been created correctly.

Steps to Reproduce

terraform apply

Important Factoids

None that I can think of.

References

Not that I was able to find. I looked for dupes.

Digital Ocean Provider Seems to Choke on Captcha

Terraform Version

Terraform v0.10.8

Affected Resource(s)

Digital Ocean

Terraform Configuration Files

N/A

Debug Output

https://gist.github.com/elricsfate/20e0f30aa2bf4acc0ac12de044554499

Expected Behavior

After a successful plan, an apply should apply the requested changes

Actual Behavior

An error occurs as seen in the gist.

This seems to occur due to a captcha request.

Steps to Reproduce

Initiate a plan.
Plan succeeds.
Apply the plan.
Failture.

References

This may be somehow related to

digitalocean/godo#142

Load Balancers are not importable

Terraform Version

  • provider.digitalocean v0.1.3

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_loadbalancer

Expected Behavior

Load balancers should be importable.

Actual Behavior

What actually happened?

Error: digitalocean_loadbalancer.public (import id: 86ac71f2-2234-4add-8d87-4dd3430bb7f5): import digitalocean_loadbalancer.public (id: 86ac71f2-2234-4add-8d87-4dd3430bb7f5): resource digitalocean_loadbalancer doesn't support import

Just opening this for tracking purposes.

Resource 'digitalocean_droplet.droplet' does not have attribute 'ipv4_address_private'

Hi,

I try use droplet module from github:
https://github.com/antarctica/terraform-module-digital-ocean-droplet

And always get an error about unset attribute.
I know that I can use my own custom module and just comment/remove following lines:

output "ip_v4_address_private" {
    value = "${digitalocean_droplet.droplet.ipv4_address_private}"
}

But I think it will be great to fix it on provider level because it will be useful for dynamic resource's configurations for using with modules even if private_networking is false.
Also may be you know some other nice workaround to solve this problem while this will be fixed on provider level ?

Terraform Version

Terraform v0.11.7

  • provider.digitalocean v0.1.3

Affected Resource(s)

  • digitalocean_droplet

Terraform Configuration Files

terraform {
  required_version = ">= 0.11.7"
}

provider "digitalocean" {
    version = "~> 0.1.3"
    token   = "${var.digitalocean_token}"
}

variable "digitalocean_token" {
  type = "string"
  default = ""
  description = "DigitalOcean API Token"
}

variable "ssh_fingerprints" {
    default = [
        "blah"
    ]
}

module "vm01" {
    source = "github.com/antarctica/terraform-module-digital-ocean-droplet?ref=v1.2.0"
#    source = "./droplet"
    hostname = "vm01"
    image = "centos-7-x64"
    region = "lon1"
    size = "1gb"
    private_networking = "false"
    ssh_fingerprints = "${var.ssh_fingerprints}"
}

Error Output

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

digitalocean_droplet.droplet: Refreshing state... (ID: 12345678)

------------------------------------------------------------------------

Error: Error running plan: 1 error(s) occurred:

* module.pgsql01.output.ip_v4_address_private: Resource 'digitalocean_droplet.droplet' does not have attribute 'ipv4_address_private' for variable 'digitalocean_droplet.droplet.ipv4_address_private'

Expected Behavior

ipv4_address_private should be set and should be a null even if private_networking is false.

Actual Behavior

always get an error:

does not have attribute 'ipv4_address_private' for variable 'digitalocean_droplet.droplet.ipv4_address_private'

Steps to Reproduce

terraform plan
terraform apply

and then again run:
terraform plan

"volume_ids" with counted volumes

Hi,

I stumbled upon an issue with specifying volume ids for volumes created with count. I tried various ways e.g.:

volume_ids = ["${"${format("digitalocean_volume.docker_master.%d.id", count.index)}"}"]

Which doesn't work because of a nested interpolation or:

volume_ids = ["${digitalocean_volume.docker_master.*.id}"]

Which neither works since digitalocean doesn't support attaching one volume to more than one droplet.
Is there any way how I can achieve this?

422 error when creating a firewall with only tags.

Hi,
I'm seeing odd behaviour with the new firewall resource with my use case. I'm trying to create a firewall with only tags as its destination or source, however it is consistently failing with a 422 http status code from the API with the message 'invalid address'.

Terraform Version

0.10.0

Affected Resource(s)

digitalocean_firewall

Terraform Configuration Files

Working config:

resource "digitalocean_firewall" "gluster_firewall" {
  name = "gluster"

  outbound_rule = [
    { protocol = "udp", port_range = "53",  destination_addresses = [ "0.0.0.0/0", "::/0" ] },
    { protocol = "tcp", port_range = "80",  destination_addresses = [ "0.0.0.0/0", "::/0" ] },
    { protocol = "tcp", port_range = "443", destination_addresses = [ "0.0.0.0/0", "::/0" ] },
  ]
}

Config which gives an error:

resource "digitalocean_firewall" "gluster_firewall" {
  name = "gluster"

  outbound_rule = [
    { protocol = "udp", port_range = "53",  destination_addresses = [ "0.0.0.0/0", "::/0" ] },
    { protocol = "tcp", port_range = "80",  destination_addresses = [ "0.0.0.0/0", "::/0" ] },
    { protocol = "tcp", port_range = "443", destination_addresses = [ "0.0.0.0/0", "::/0" ] },

    { protocol = "udp", port_range = "111",         destination_tags = [ "${ var.tag_id_server }" ] },
    { protocol = "tcp", port_range = "111",         destination_tags = [ "${ var.tag_id_server }" ] },
    { protocol = "tcp", port_range = "24007-24008", destination_tags = [ "${ var.tag_id_server }", "${ var.tag_id_client }" ] },
    { protocol = "tcp", port_range = "49152-49172", destination_tags = [ "${ var.tag_id_server }", "${ var.tag_id_client }" ] },
  ]
}

It seems to fail regardless of the order of the destination_tags only lines or where they appear in the outbound_rule. I also tried with only one tag only rule and this also fails.

Expected Behavior

Resource should have been created with a success. Firewall should have protocol, port range and tags only.

Actual Behavior

422 invalid address given from DO API.

Steps to Reproduce

terraform apply

Extra info

From using the API directly with postman I was able to create a firewall with only a tag. The payload sent was:

{
  "name": "firewall",
  "inbound_rules": [],
  "outbound_rules": [
    {
      "protocol": "tcp",
      "ports": "80",
      "destinations": {
        "tags": [
          "some-tag-name"
        ]
      }
    }
  ]
}

The only way I could get the API to throw a 422 was by actually giving a malformed address:

{
  "name": "firewall",
  "inbound_rules": [],
  "outbound_rules": [
    {
      "protocol": "tcp",
      "ports": "80",
      "destinations": {
        "tags": [
          "some-tag-name"
        ],
        "addresses": [
          "not-an-address"
        ]
      }
    }
  ]
}

Edit: Tidy up bug report with headings a formatting.

DigitalOcean droplet image not found

This issue was originally opened by @eakraly as hashicorp/terraform#17497. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.11.3

Terraform Configuration Files

...

Debug Output

Crash Output

Expected Behavior

Using DigitalOcean provider, trying to create droplet, terraform fails with following error:

Error: Error refreshing state: 1 error(s) occurred:

  • data.digitalocean_image.XXX: 1 error(s) occurred:
  • data.digitalocean_image.XXX: data.digitalocean_image.XXX: no user image found with name YYY

After some debugging I found out that DigitalOcean paginates its https://api.digitalocean.com/v2/images API and returns 1 page by default. Which means if image YYY is not on the first page - it is not "seen" by terraform and it fails.
If I keep number of images <=10 then it all works fine.

I'm not sure this is strictly terraform bug - it looks more like DigitalOcean API issue.

Actual Behavior

There should be no limit on number of images on DO, no matter how many images are there - any one can be used to deploy a droplet.

Steps to Reproduce

  1. Have 11 images on DO
  2. Create a single droplet with last created image (11th)
  3. Observer terraform failing with error "no user image found with name"

Additional Context

References

Invalid size for Droplet creation.

Terraform Version

Terraform v0.11.1

  • provider.digitalocean v0.1.3
  • provider.null v1.0.0
  • provider.scaleway v1.0.0
  • provider.template v1.0.0

Affected Resource(s)

  • digitalocean_droplet

Terraform Configuration Files

https://github.com/discentem/terraform-chef-server

Relevant variable: https://github.com/discentem/terraform-chef-server/blob/digital_ocean/variable_values.tfvars#L8

Panic Output

$  terraform apply -var-file=variable_values.tfvars -var-file=secrets.tfvars -auto-approve
var.chef_password
  Enter a value: <redacted>

data.template_file.chef_server_config: Refreshing state...
data.template_file.knife_config: Refreshing state...
data.template_file.gd-config: Refreshing state...
data.template_file.cron_gd: Refreshing state...
data.template_file.chef_bootstrap: Refreshing state...
data.template_file.id_rsa: Refreshing state...
digitalocean_ssh_key.default: Creating...
  fingerprint: "" => "<computed>"
  name:        "" => "id_rsa"
  public_key:  "" => "ssh-rsa <redacted>"
digitalocean_droplet.chef_server: Creating...
  disk:                 "" => "<computed>"
  image:                "" => "ubuntu-16-04-x64"
  ipv4_address:         "" => "<computed>"
  ipv4_address_private: "" => "<computed>"
  ipv6_address:         "" => "<computed>"
  ipv6_address_private: "" => "<computed>"
  locked:               "" => "<computed>"
  name:                 "" => "crepitus"
  price_hourly:         "" => "<computed>"
  price_monthly:        "" => "<computed>"
  region:               "" => "nyc3"
  resize_disk:          "" => "true"
  size:                 "" => "3gb"
  status:               "" => "<computed>"
  vcpus:                "" => "<computed>"
digitalocean_ssh_key.default: Creation complete after 1s (ID: 17017812)

Error: Error applying plan:

1 error(s) occurred:

* digitalocean_droplet.chef_server: 1 error(s) occurred:

* digitalocean_droplet.chef_server: Error creating droplet: POST https://api.digitalocean.com/v2/droplets: 422 You specified an invalid size for Droplet creation.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.


Expected Behavior

What should have happened?

A droplet with 3gb of ram should be created.

Actual Behavior

What actually happened?

API complained I provided an incorrect value for size.

Steps to Reproduce

Create a digitalocean_droplet and try to specific 3gb size.

Or:

Clone repo at https://github.com/discentem/terraform-chef-server.git

Run terraform apply -var-file=variable_values.tfvars -auto-approve and provide values for the variables.

Important Factoids

n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.