{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/6569","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/6569/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/6569/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/6569/events","html_url":"https://github.com/hashicorp/terraform/issues/6569","id":153890389,"number":6569,"title":"security_groups forces new resource in non default VPC in aws_instance","user":{"login":"mschurenko","id":4079843,"avatar_url":"https://avatars.githubusercontent.com/u/4079843?v=3","gravatar_id":"","url":"https://api.github.com/users/mschurenko","html_url":"https://github.com/mschurenko","followers_url":"https://api.github.com/users/mschurenko/followers","following_url":"https://api.github.com/users/mschurenko/following{/other_user}","gists_url":"https://api.github.com/users/mschurenko/gists{/gist_id}","starred_url":"https://api.github.com/users/mschurenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschurenko/subscriptions","organizations_url":"https://api.github.com/users/mschurenko/orgs","repos_url":"https://api.github.com/users/mschurenko/repos","events_url":"https://api.github.com/users/mschurenko/events{/privacy}","received_events_url":"https://api.github.com/users/mschurenko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-09T23:11:55Z","updated_at":"2016-05-09T23:11:55Z","closed_at":null,"body":"In the terraform.tfstate file it looks like security_groups.#: is set to 0 and vpc_security_group_ids.# is set to 1. Here is the relevant snippet:\r\n\r\n```json\r\n \"aws_instance.pritunl\": {\r\n                    \"type\": \"aws_instance\",\r\n                    \"depends_on\": [\r\n                        \"aws_iam_instance_profile.pritunl_profile\",\r\n                        \"aws_key_pair.infra\",\r\n                        \"aws_security_group.pritunl\",\r\n                        \"aws_subnet.public_us-west-2a\"\r\n                    ],\r\n                    \"primary\": {\r\n                        \"id\": \"i-e611f320\",\r\n                        \"attributes\": {\r\n                            \"ami\": \"ami-f0091d91\",\r\n                            \"associate_public_ip_address\": \"true\",\r\n                            \"availability_zone\": \"us-west-2a\",\r\n                            \"disable_api_termination\": \"false\",\r\n                            \"ebs_block_device.#\": \"0\",\r\n                            \"ebs_optimized\": \"false\",\r\n                            \"ephemeral_block_device.#\": \"0\",\r\n                            \"iam_instance_profile\": \"pritunl_profile\",\r\n                            \"id\": \"i-e611f320\",\r\n                            \"instance_state\": \"running\",\r\n                            \"instance_type\": \"m3.medium\",\r\n                            \"key_name\": \"infra\",\r\n                            \"monitoring\": \"false\",\r\n                            \"private_dns\": \"ip-10-62-240-144.us-west-2.compute.internal\",\r\n                            \"private_ip\": \"10.62.240.144\",\r\n                            \"public_dns\": \"\",\r\n                            \"public_ip\": \"52.39.6.119\",\r\n                            \"root_block_device.#\": \"1\",\r\n                            \"root_block_device.0.delete_on_termination\": \"true\",\r\n                            \"root_block_device.0.iops\": \"0\",\r\n                            \"root_block_device.0.volume_size\": \"40\",\r\n                            \"root_block_device.0.volume_type\": \"standard\",\r\n                            \"security_groups.#\": \"0\",\r\n                            \"source_dest_check\": \"true\",\r\n                            \"subnet_id\": \"subnet-7ac53e1e\",\r\n                            \"tags.#\": \"3\",\r\n                            \"tags.Name\": \"pritunl\",\r\n                            \"tags.team\": \"opsauto\",\r\n                            \"tags.tf_stack\": \"vpc\",\r\n                            \"tenancy\": \"default\",\r\n                            \"user_data\": \"dc329b0e9a5e2da2e4960547d9fe9199ed46e8a6\",\r\n                            \"vpc_security_group_ids.#\": \"1\",\r\n                            \"vpc_security_group_ids.4023412840\": \"sg-e47bf983\"\r\n                        },\r\n                        \"meta\": {\r\n                            \"schema_version\": \"1\"\r\n                        }\r\n                    }\r\n                },\r\n```\r\n\r\nFor some reason when I run \"terraform plan\" I get this output:\r\n\r\n```sh\r\n-/+ aws_instance.pritunl\r\n    ami:                                       \"ami-f0091d91\" => \"ami-f0091d91\"\r\n    associate_public_ip_address:               \"true\" => \"1\"\r\n    availability_zone:                         \"us-west-2a\" => \"<computed>\"\r\n    ebs_block_device.#:                        \"0\" => \"<computed>\"\r\n    ephemeral_block_device.#:                  \"0\" => \"<computed>\"\r\n    iam_instance_profile:                      \"pritunl_profile\" => \"pritunl_profile\"\r\n    instance_state:                            \"running\" => \"<computed>\"\r\n    instance_type:                             \"m3.medium\" => \"m3.medium\"\r\n    key_name:                                  \"infra\" => \"infra\"\r\n    placement_group:                           \"\" => \"<computed>\"\r\n    private_dns:                               \"ip-10-62-240-144.us-west-2.compute.internal\" => \"<computed>\"\r\n    private_ip:                                \"10.62.240.144\" => \"<computed>\"\r\n    public_dns:                                \"\" => \"<computed>\"\r\n    public_ip:                                 \"52.39.6.119\" => \"<computed>\"\r\n    root_block_device.#:                       \"1\" => \"1\"\r\n    root_block_device.0.delete_on_termination: \"true\" => \"1\"\r\n    root_block_device.0.iops:                  \"0\" => \"<computed>\"\r\n    root_block_device.0.volume_size:           \"40\" => \"40\"\r\n    root_block_device.0.volume_type:           \"standard\" => \"<computed>\"\r\n    security_groups.#:                         \"0\" => \"1\" (forces new resource)\r\n    security_groups.4023412840:                \"\" => \"sg-e47bf983\" (forces new resource)\r\n    source_dest_check:                         \"true\" => \"1\"\r\n    subnet_id:                                 \"subnet-7ac53e1e\" => \"subnet-7ac53e1e\"\r\n    tags.#:                                    \"3\" => \"3\"\r\n    tags.Name:                                 \"pritunl\" => \"pritunl\"\r\n    tags.team:                                 \"opsauto\" => \"opsauto\"\r\n    tags.tf_stack:                             \"vpc\" => \"vpc\"\r\n    tenancy:                                   \"default\" => \"<computed>\"\r\n    user_data:                                 \"dc329b0e9a5e2da2e4960547d9fe9199ed46e8a6\" => \"dc329b0e9a5e2da2e4960547d9fe9199ed46e8a6\"\r\n    vpc_security_group_ids.#:                  \"1\" => \"<computed>\"\r\n```\r\n\r\nWhy is terraform now setting security_groups when it wasn't before? I am not using a default VPC so, according to the documentation, it should be just using vpc_security_group_ids. Now it's trying to set both security_groups and vpc_security_group_ids and wanting to force a new ec2 instance.\r\n\r\n### Terraform Version\r\nTerraform v0.6.15\r\n\r\n### Affected Resource(s)\r\n- aws_instance\r\n"}}