{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/8395","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/8395/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/8395/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/8395/events","html_url":"https://github.com/hashicorp/terraform/issues/8395","id":172545180,"number":8395,"title":"Adding additional instances that have volume attachments","user":{"login":"micahlmartin","id":171773,"avatar_url":"https://avatars.githubusercontent.com/u/171773?v=3","gravatar_id":"","url":"https://api.github.com/users/micahlmartin","html_url":"https://github.com/micahlmartin","followers_url":"https://api.github.com/users/micahlmartin/followers","following_url":"https://api.github.com/users/micahlmartin/following{/other_user}","gists_url":"https://api.github.com/users/micahlmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/micahlmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micahlmartin/subscriptions","organizations_url":"https://api.github.com/users/micahlmartin/orgs","repos_url":"https://api.github.com/users/micahlmartin/repos","events_url":"https://api.github.com/users/micahlmartin/events{/privacy}","received_events_url":"https://api.github.com/users/micahlmartin/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,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-22T20:21:16Z","updated_at":"2016-10-03T05:42:31Z","closed_at":null,"body":"I have a module that creates an instance or mysql and attaches an ebs volume. I'm trying to increase the number of instances from 1 to 3. Here is the configuration:\r\n\r\n```\r\nresource \"aws_instance\" \"mysql_galera\" {\r\n  count = \"${var.instances}\"\r\n  ami = \"${var.ami_id}\"\r\n  instance_type = \"${var.instance_type}\"\r\n  vpc_security_group_ids = [\"${var.security_groups}\"]\r\n  subnet_id = \"${element(var.subnets, count.index)}\"\r\n  user_data = \"${data.template_cloudinit_config.config.rendered}\"\r\n  iam_instance_profile = \"${var.iam_instance_profile}\"\r\n  ebs_optimized = true\r\n  ....\r\n}\r\n\r\nresource \"aws_ebs_volume\" \"mysql_galera_ebs_volume\" {\r\n  depends_on = [\"aws_instance.mysql_galera\"]\r\n  count = \"${var.instances}\"\r\n  availability_zone = \"${element(aws_instance.mysql_galera.*.availability_zone, count.index)}\"\r\n  encrypted = \"${var.ebs_encrypted}\"\r\n  size = \"${var.ebs_size}\"\r\n  type = \"${var.ebs_type}\"\r\n}\r\n\r\nresource \"aws_volume_attachment\" \"mysql_galera_ebs_attachment\" {\r\n  count = \"${var.instances}\"\r\n  device_name = \"/dev/sdh\"\r\n  volume_id = \"${element(aws_ebs_volume.mysql_galera_ebs_volume.*.id, count.index)}\"\r\n  instance_id = \"${element(aws_instance.mysql_galera.*.id, count.index)}\"\r\n}\r\n```\r\n\r\nHere's the relevant part of the `plan`:\r\n\r\n```\r\n-/+ module.base.mysql_galera.aws_volume_attachment.mysql_galera_ebs_attachment.0\r\n    device_name:  \"/dev/sdh\" => \"/dev/sdh\"\r\n    force_detach: \"\" => \"<computed>\"\r\n    instance_id:  \"i-xxx\" => \"${element(aws_instance.mysql_galera.*.id, count.index)}\" (forces new resource)\r\n    volume_id:    \"vol-xxx\" => \"${element(aws_ebs_volume.mysql_galera_ebs_volume.*.id, count.index)}\" (forces new resource)\r\n```\r\n\r\nIf I've already created the first resource and then increase the count to 3 this is what I get. Any ideas on how to handle this?"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/251030634","html_url":"https://github.com/hashicorp/terraform/issues/8395#issuecomment-251030634","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/8395","id":251030634,"user":{"login":"ybogdanov","id":292569,"avatar_url":"https://avatars.githubusercontent.com/u/292569?v=3","gravatar_id":"","url":"https://api.github.com/users/ybogdanov","html_url":"https://github.com/ybogdanov","followers_url":"https://api.github.com/users/ybogdanov/followers","following_url":"https://api.github.com/users/ybogdanov/following{/other_user}","gists_url":"https://api.github.com/users/ybogdanov/gists{/gist_id}","starred_url":"https://api.github.com/users/ybogdanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybogdanov/subscriptions","organizations_url":"https://api.github.com/users/ybogdanov/orgs","repos_url":"https://api.github.com/users/ybogdanov/repos","events_url":"https://api.github.com/users/ybogdanov/events{/privacy}","received_events_url":"https://api.github.com/users/ybogdanov/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T05:42:31Z","updated_at":"2016-10-03T05:42:31Z","body":"Thanks, @PaulCapestany. Will try!"}}
{"actor":{"display_login":"ybogdanov"}}