Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New digitalocean_volume_attachment resource for proper updates of droplet volumes #130

Merged

Conversation

TFaga
Copy link
Contributor

@TFaga TFaga commented Aug 30, 2018

This PR adds an additional virtual resource named digitalocean_volume_attachment, which represents a volume attachment to a droplet. Replaces the current way of attaching volumes by passing in their ids to the droplet definition.

Using the attachment resource allows terraform to correctly traverse the dependency graph of our resources and enables the provider to gracefully update any attached volumes. It does so by first detaching the volumes from the droplet, deleting old ones, creating new ones and finally reattaching the new volumes to the initial droplet.

Backward compatibility is preserved. You can continue using the current way of attaching volumes to droplets without issue. Just keep in mind that the methods are mutually exclusive. You must not use both of them at the same time. The documentation is also updated accordingly. Fixes #87

Example of the attachment resource:

resource "digitalocean_volume" "foo" {
  region = "lon1"
  name = "foo"
  size = 5
}

resource "digitalocean_droplet" "foo" {
  name = "foo"
  region = "lon1"
  size = "s-1vcpu-1gb"
  image = "ubuntu-18-04-x64"
}

resource "digitalocean_volume_attachment" "foo" {
  droplet_id = "${digitalocean_droplet.foo.id}"
  volume_id = "${digitalocean_volume.foo.id}"
}

@ghost ghost added the size/L label Aug 30, 2018
@ghost ghost added size/XL and removed size/L labels Aug 31, 2018
@andrewsomething
Copy link
Member

:shipit: Great stuff!

@andrewsomething andrewsomething merged commit e3f0ebf into digitalocean:master Sep 4, 2018
@TFaga TFaga deleted the iss87-volume-attachement branch September 5, 2018 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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