{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/4306","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/4306/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/4306/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/4306/events","html_url":"https://github.com/hashicorp/terraform/issues/4306","id":122061489,"number":4306,"title":"aws_instance creation failed due to missed IAM role","user":{"login":"partamonov","id":12701926,"avatar_url":"https://avatars.githubusercontent.com/u/12701926?v=3","gravatar_id":"","url":"https://api.github.com/users/partamonov","html_url":"https://github.com/partamonov","followers_url":"https://api.github.com/users/partamonov/followers","following_url":"https://api.github.com/users/partamonov/following{/other_user}","gists_url":"https://api.github.com/users/partamonov/gists{/gist_id}","starred_url":"https://api.github.com/users/partamonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/partamonov/subscriptions","organizations_url":"https://api.github.com/users/partamonov/orgs","repos_url":"https://api.github.com/users/partamonov/repos","events_url":"https://api.github.com/users/partamonov/events{/privacy}","received_events_url":"https://api.github.com/users/partamonov/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":1,"created_at":"2015-12-14T15:10:13Z","updated_at":"2015-12-14T18:18:35Z","closed_at":null,"body":"Rather often I'm getting aws_instance creation error, due to it is pointing to profile with empty roles.\r\nVersion is 0.6.8 and this I saw before\r\nError message:\r\n```\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* aws_instance.vm: Error launching source instance: InvalidParameterValue: IAM Instance Profile \"arn:aws:iam::xxxxx:instance-profile/development\" has no associated IAM Roles\r\n        status code: 400, request id:\r\n```\r\n\r\nWhat I have.\r\nIAM module with following inside:\r\n```\r\nresource \"aws_iam_instance_profile\" \"development\" {\r\n...\r\n  roles = [\"${aws_iam_role.development.name}\"]\r\n}\r\n\r\nsome \r\nresource \"aws_iam_role_policy\" \"sns\" {\r\n    name = \"default_sns\"\r\n    role = \"${aws_iam_role.development.id}\"\r\n...\r\n}\r\n\r\nresource \"aws_iam_role\" \"development\" {\r\n...\r\n}\r\n\r\noutput \"profile\" {\r\n  value = \"${aws_iam_instance_profile.development.name}\"\r\n}\r\n```\r\n\r\nAnd aws instance is created in module\r\n```\r\nmodule \"cis\" {\r\n  source = \"../modules/cis_instance\"\r\n  ...\r\n  iam_profile = \"${module.aws_iam.profile}\"\r\n}\r\n```\r\n\r\n```\r\nresource \"aws_instance\" \"vm\" {\r\n  ami = \"${var.ami_id}\"\r\n  ...\r\n  iam_instance_profile = \"${var.iam_profile}\"\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/164515730","html_url":"https://github.com/hashicorp/terraform/issues/4306#issuecomment-164515730","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/4306","id":164515730,"user":{"login":"jen20","id":548524,"avatar_url":"https://avatars.githubusercontent.com/u/548524?v=3","gravatar_id":"","url":"https://api.github.com/users/jen20","html_url":"https://github.com/jen20","followers_url":"https://api.github.com/users/jen20/followers","following_url":"https://api.github.com/users/jen20/following{/other_user}","gists_url":"https://api.github.com/users/jen20/gists{/gist_id}","starred_url":"https://api.github.com/users/jen20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jen20/subscriptions","organizations_url":"https://api.github.com/users/jen20/orgs","repos_url":"https://api.github.com/users/jen20/repos","events_url":"https://api.github.com/users/jen20/events{/privacy}","received_events_url":"https://api.github.com/users/jen20/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T18:18:35Z","updated_at":"2015-12-14T18:18:35Z","body":"This seems like it may be related to #4235 and the eventual consistency of IAM. The discussion there suggests we wait for the instance profile to exist as part of instance creation, so it might be that we need additional logic there to check for roles having not been added yet."}}