terraform/builtin/providers
Paul Stack 6649b938da provider/aws: Provide the option to skip_destroy on aws_volume_attachment (#9792)
* provider/aws: Provide the option to skip_destroy on
aws_volume_attachment

When you want to attach and detach pre-existing EBS volumes to an
instance, we would do that as follows:

```
resource "aws_instance" "web" {
	ami = "ami-21f78e11"
  availability_zone = "us-west-2a"
	instance_type = "t1.micro"
	tags {
		Name = "HelloWorld"
	}
}

data "aws_ebs_volume" "ebs_volume" {
  filter {
  	name = "size"
  	values = ["${aws_ebs_volume.example.size}"]
  }
  filter {
  	name = "availability-zone"
  	values = ["${aws_ebs_volume.example.availability_zone}"]
  }
  filter {
  	name = "tag:Name"
  	values = ["TestVolume"]
  }
}

resource "aws_volume_attachment" "ebs_att" {
  device_name = "/dev/sdh"
	volume_id = "${data.aws_ebs_volume.ebs_volume.id}"
	instance_id = "${aws_instance.web.id}"
	skip_destroy = true
}
```

The issue here is that when we run a terraform destroy command, the volume tries to get detached from a running instance and goes into a non-responsive state. We would have to force_destroy the volume at that point and risk losing any data on it.

This PR introduces the idea of `skip_destroy` on a volume attachment. tl;dr:

We want the volume to be detached from the instane when the instance itself has been destroyed. This way the normal shut procedures will happen and protect the disk for attachment to another instance

Volume Attachment Tests:

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSVolumeAttachment_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/11/02 00:47:27 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSVolumeAttachment_ -timeout 120m
=== RUN   TestAccAWSVolumeAttachment_basic
--- PASS: TestAccAWSVolumeAttachment_basic (133.49s)
=== RUN   TestAccAWSVolumeAttachment_skipDestroy
--- PASS: TestAccAWSVolumeAttachment_skipDestroy (119.64s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	253.158s
```

EBS Volume Tests:

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSEBSVolume_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/11/02 01:00:18 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSEBSVolume_ -timeout 120m
=== RUN   TestAccAWSEBSVolume_importBasic
--- PASS: TestAccAWSEBSVolume_importBasic (26.38s)
=== RUN   TestAccAWSEBSVolume_basic
--- PASS: TestAccAWSEBSVolume_basic (26.86s)
=== RUN   TestAccAWSEBSVolume_NoIops
--- PASS: TestAccAWSEBSVolume_NoIops (27.89s)
=== RUN   TestAccAWSEBSVolume_withTags
--- PASS: TestAccAWSEBSVolume_withTags (26.88s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	108.032s
```

* Update volume_attachment.html.markdown
2016-11-02 15:29:37 +00:00
..
archive provider/archive: Converting to datasource. (#8492) 2016-10-25 15:59:06 +01:00
atlas
aws provider/aws: Provide the option to skip_destroy on aws_volume_attachment (#9792) 2016-11-02 15:29:37 +00:00
azure
azurerm provider/azurerm: update Azure SDK to 6.0 Beta (#9700) 2016-11-01 19:25:20 +00:00
bitbucket
chef
clc
cloudflare
cloudstack Adding private gateway and static route resource to cloudstack provider (#9637) 2016-10-27 21:06:39 +02:00
cobbler
consul Fixes for consul_service resource (#9366) 2016-10-26 13:07:00 +01:00
datadog provider/datadog: Reduce diff on thresholds 2016-10-20 10:22:24 -05:00
digitalocean provider/digitalocean: Ingore resize_disk on the import DO droplet tests 2016-10-25 11:40:56 +01:00
dme
dnsimple
docker provider/docker: Fixes for docker_container host object and documentation (#9367) 2016-10-27 10:54:05 +01:00
dyn
fastly
github provider/github: github_repository resource 2016-10-13 08:04:17 -07:00
google Search configured project image families (#9243) 2016-11-01 21:00:12 +00:00
grafana
heroku
influxdb
librato
logentries
mailgun
mysql
null
openstack provider/openstack: Openstack Provider Updates (#9725) 2016-11-01 13:16:39 +00:00
packet
pagerduty Remove the unnecessary use of &schema.Schema 2016-10-24 16:43:53 +02:00
postgresql
powerdns
rabbitmq Fix vet issues 2016-10-18 11:11:12 -04:00
random
rundeck
scaleway provider/scaleway server volume property (#9695) 2016-10-29 12:07:35 +01:00
softlayer
statuscake
template
terraform
test
tls Restore tls_cert_request to being a managed resource 2016-09-24 12:22:07 -07:00
triton
ultradns
vcd
vsphere Adding 'detach_unknown_disks_on_delete' flag for VM resource 2016-09-26 18:16:02 -07:00