{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/3449","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/3449/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/3449/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/3449/events","html_url":"https://github.com/hashicorp/terraform/issues/3449","id":110429474,"number":3449,"title":"aws_volume_attachment recreates attachments unnecessarily","user":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provider/aws","name":"provider/aws","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-08T11:35:39Z","updated_at":"2015-10-13T07:20:54Z","closed_at":null,"body":"I'm trying to setup a multi-node cluster with attached ebs volumes.  An example below:\r\n\r\n```\r\nresource \"aws_instance\" \"nodes\" {\r\n\tinstance_type = \"${var.model}\"\r\n\tkey_name = \"${var.ec2_keypair}\"\r\n\tami = \"${lookup(var.zk_amis, var.region)}\"\r\n\tcount = \"${var.node_count}\"\r\n\tvpc_security_group_ids = [\"${aws_security_group.default.id}\"]\r\n\tsubnet_id = \"${lookup(var.subnet_ids, element(keys(var.subnet_ids), count.index))}\"\r\n\tassociate_public_ip_address = true\r\n\tuser_data = \"${file(\"cloud_init\")}\"\r\n\ttags {\r\n\t\tName = \"${var.cluster_name}-${count.index}\"\r\n\t}\r\n}\r\n\r\nresource \"aws_ebs_volume\" \"node-ebs\" {\r\n\tcount = \"${var.node-count}\"\r\n\tavailability_zone = \"${element(keys(var.subnet_ids), count.index)}\"\r\n\tsize = 100\r\n\ttags {\r\n\t\tName = \"${var.cluster_name}-ebs-${count.index}\"\r\n\t}\r\n}\r\n\r\nresource \"aws_volume_attachment\" \"node-attach\" {\r\n\tcount = \"${var.node_count}\"\r\n\tdevice_name = \"/dev/xvdh\"\r\n\tvolume_id = \"${element(aws_ebs_volume.node-ebs.*.id, count.index)}\"\r\n\tinstance_id = \"${element(aws_instance.nodes.*.id, count.index)}\"\r\n}\r\n```\r\n\r\nIf a change happens to a single node (for instance if a single ec2 instance is terminated) ALL of the aws_volume_attachments are recreated.  \r\n\r\nClearly we would not want volume attachments to be removed in a production environment.  Worse than that, in conjunction with #2957 you first must unmount these attachments before they can be recreated.  This has the effect of making volume attachments only viable on brand new clusters."},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/147627552","html_url":"https://github.com/hashicorp/terraform/issues/3449#issuecomment-147627552","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/3449","id":147627552,"user":{"login":"danabr","id":207266,"avatar_url":"https://avatars.githubusercontent.com/u/207266?v=3","gravatar_id":"","url":"https://api.github.com/users/danabr","html_url":"https://github.com/danabr","followers_url":"https://api.github.com/users/danabr/followers","following_url":"https://api.github.com/users/danabr/following{/other_user}","gists_url":"https://api.github.com/users/danabr/gists{/gist_id}","starred_url":"https://api.github.com/users/danabr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danabr/subscriptions","organizations_url":"https://api.github.com/users/danabr/orgs","repos_url":"https://api.github.com/users/danabr/repos","events_url":"https://api.github.com/users/danabr/events{/privacy}","received_events_url":"https://api.github.com/users/danabr/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T07:20:54Z","updated_at":"2015-10-13T07:20:54Z","body":"Our current workaround is to duplicate the \"aws_volume_attachment\" resources, rather than using the element function."}}