{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/873","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/873/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/873/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/873/events","html_url":"https://github.com/hashicorp/terraform/issues/873","id":55704055,"number":873,"title":"Terraform fails to retrieve schema.Set resource attribute value containing references to other resources.","user":{"login":"ggiamarchi","id":1434745,"avatar_url":"https://avatars.githubusercontent.com/u/1434745?v=3","gravatar_id":"","url":"https://api.github.com/users/ggiamarchi","html_url":"https://github.com/ggiamarchi","followers_url":"https://api.github.com/users/ggiamarchi/followers","following_url":"https://api.github.com/users/ggiamarchi/following{/other_user}","gists_url":"https://api.github.com/users/ggiamarchi/gists{/gist_id}","starred_url":"https://api.github.com/users/ggiamarchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggiamarchi/subscriptions","organizations_url":"https://api.github.com/users/ggiamarchi/orgs","repos_url":"https://api.github.com/users/ggiamarchi/repos","events_url":"https://api.github.com/users/ggiamarchi/events{/privacy}","received_events_url":"https://api.github.com/users/ggiamarchi/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/core","name":"core","color":"cccccc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-28T02:04:52Z","updated_at":"2015-01-31T13:46:50Z","closed_at":null,"body":"For instance, using the sample provider [provider.go](https://gist.github.com/ggiamarchi/cc6f200842794c0b05eb#file-provider-go) and the corresponding terraform configuration :\r\n\r\n```\r\nprovider \"test\" {\r\n}\r\n\r\nresource \"test_container\" \"ctn001\" {\r\n    elements = [\r\n        \"${test_element.elt001.id}\",\r\n        \"${test_element.elt002.id}\",\r\n        \"${test_element.elt003.id}\"\r\n    ]\r\n}\r\n\r\nresource \"test_element\" \"elt001\" {\r\n}\r\n\r\nresource \"test_element\" \"elt002\" {\r\n}\r\n\r\nresource \"test_element\" \"elt003\" {\r\n}\r\n```\r\nTerraform creates the 3 `test_element` resources but then, when it tries to create the `test_container` resource it doesn't give the right IDs when getting it with [`d.Get(\"elements\").(*schema.Set)`](https://gist.github.com/ggiamarchi/cc6f200842794c0b05eb#file-provider-go-L35)\r\n\r\nIn the log, we can see the `elements` set is wrong\r\n\r\n```\r\n2015/01/28 02:51:13 terraform-provider-test: 2015/01/28 02:51:13 [DEBUG] Create element with id XVlBzgbaiCMRAjWwhTHctcuAxhxKQF\r\n2015/01/28 02:51:13 terraform-provider-test: 2015/01/28 02:51:13 [DEBUG] Create element with id DaFpLSjFbcXoEFfRsWxPLDnJObCsNV\r\n2015/01/28 02:51:13 terraform-provider-test: 2015/01/28 02:51:13 [DEBUG] Create element with id lgTeMaPEZQleQYhYzRyWJjPjzpfRFE\r\n...\r\n2015/01/28 02:51:13 terraform-provider-test: 2015/01/28 02:51:13 [DEBUG] Create container with id gmotaFetHsbZRjxAwnwekrBEmfdzdc and elements *Set(map[int]interface {}{616279343:\"XVlBzgbaiCMRAjWwhTHctcuAxhxKQF\", 0:\"\", 471749553:\"DaFpLSjFbcXoEFfRsWxPLDnJObCsNV\"})\r\ntest_element.elt003: Creation complete\r\n...\r\ntest_element.elt002: Creation complete\r\ntest_element.elt001: Creation complete\r\ntest_container.ctn001: Creating...\r\n  elements.#:           \"0\" => \"3\"\r\n  elements.471749553:   \"\" => \"DaFpLSjFbcXoEFfRsWxPLDnJObCsNV\"\r\n  elements.616279343:   \"\" => \"XVlBzgbaiCMRAjWwhTHctcuAxhxKQF\"\r\n  elements.~1468225307: \"\" => \"\"\r\ntest_container.ctn001: Creation complete\r\n```\r\n\r\nThis is a regression introduced by https://github.com/hashicorp/terraform/commit/b4bf8131516c80a0b3b980924afde5d510458935. When testing with the commit just before https://github.com/hashicorp/terraform/commit/aa82c10e3927eb33d5ecbc5844e93619a088d638 it works great as shown in the following log\r\n\r\n```\r\n2015/01/28 02:57:45 terraform-provider-test: 2015/01/28 02:57:45 [DEBUG] Create element with id XVlBzgbaiCMRAjWwhTHctcuAxhxKQF\r\n2015/01/28 02:57:45 terraform-provider-test: 2015/01/28 02:57:45 [DEBUG] Create element with id DaFpLSjFbcXoEFfRsWxPLDnJObCsNV\r\n2015/01/28 02:57:45 terraform-provider-test: 2015/01/28 02:57:45 [DEBUG] Create element with id lgTeMaPEZQleQYhYzRyWJjPjzpfRFE\r\n...\r\ntest_element.elt003: Creation complete\r\ntest_element.elt002: Creation complete\r\ntest_element.elt001: Creation complete\r\ntest_container.ctn001: Creating...\r\n  elements.#:           \"0\" => \"3\"\r\n  elements.471749553:   \"\" => \"DaFpLSjFbcXoEFfRsWxPLDnJObCsNV\"\r\n  elements.616279343:   \"\" => \"XVlBzgbaiCMRAjWwhTHctcuAxhxKQF\"\r\n  elements.~1468225307: \"\" => \"lgTeMaPEZQleQYhYzRyWJjPjzpfRFE\"\r\ntest_container.ctn001: Creation complete\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/72318289","html_url":"https://github.com/hashicorp/terraform/issues/873#issuecomment-72318289","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/873","id":72318289,"user":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"created_at":"2015-01-31T13:46:50Z","updated_at":"2015-01-31T13:46:50Z","body":"I haven't been able to repro this so far, but watched it repro on someone else's. I thought maybe race condition and made this script, but nothing so far:\r\n\r\n```\r\necho Starting...\r\ncount=1\r\nwhile [ $? -eq 0 ]; do\r\n    rm -f terraform.tfstate\r\n    output=$(terraform apply)\r\n    if [[ $output == *\"~\"* ]]; then\r\n        echo \"Reproduced on count ${count}!\"\r\n        echo $output\r\n        exit 1\r\n    fi\r\n\r\n    ((count++))\r\n    if [ $count -gt 100 ]; then\r\n        echo No bug encountered.\r\n        exit 0\r\n    fi\r\ndone\r\n```"}}