{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/5979","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/5979/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/5979/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/5979/events","html_url":"https://github.com/hashicorp/terraform/issues/5979","id":145225566,"number":5979,"title":"aws_iam_policy_attachment error when attaching amazon \"managed\" policies","user":{"login":"dansteen","id":64940,"avatar_url":"https://avatars.githubusercontent.com/u/64940?v=3","gravatar_id":"","url":"https://api.github.com/users/dansteen","html_url":"https://github.com/dansteen","followers_url":"https://api.github.com/users/dansteen/followers","following_url":"https://api.github.com/users/dansteen/following{/other_user}","gists_url":"https://api.github.com/users/dansteen/gists{/gist_id}","starred_url":"https://api.github.com/users/dansteen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dansteen/subscriptions","organizations_url":"https://api.github.com/users/dansteen/orgs","repos_url":"https://api.github.com/users/dansteen/repos","events_url":"https://api.github.com/users/dansteen/events{/privacy}","received_events_url":"https://api.github.com/users/dansteen/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":6,"created_at":"2016-04-01T16:34:35Z","updated_at":"2016-04-11T14:45:39Z","closed_at":null,"body":"For the following config:  \r\n```\r\nresource \"aws_iam_role\" \"emr\" {\r\n    name = \"matching-spark-emr-${var.env}\"\r\n    assume_role_policy = \"${file(\"${path.module}/iam-policy-emr-trust-relationship.tpl\")}\"\r\n}\r\n\r\n# the generic role provided by amazon\r\nresource \"aws_iam_policy_attachment\" \"AmazonElasticMapReduceRole\" {\r\n  name = \"AmazonElasticMapReduceRole\"\r\n  roles = [ \"${aws_iam_role.emr.name}\" ]\r\n  policy_arn = \"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole\"\r\n}\r\n```\r\n\r\nI Occasionally, get the following error:\r\n```\r\n* aws_iam_policy_attachment.AmazonElasticMapReduceRole: [WARN] Error updating user, role, or group list from IAM Policy Attachment AmazonElasticMapReduceRole:\r\n– NoSuchEntity: Policy arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole was not found.\r\n        status code: 404, request id: be6c2f10-f824-11e5-9241-eb1509222747\r\n```\r\n\r\nNote that I only seem to get this when attaching amazon \"managed\" policies to a role.   A second run results in success.   Also, as a note, the above code is in a module, and I call that module multiple times (despite the warning in the documentation about only using \"aws_iam_policy_attachment\" once per policy."},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/208381080","html_url":"https://github.com/hashicorp/terraform/issues/5979#issuecomment-208381080","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/5979","id":208381080,"user":{"login":"dansteen","id":64940,"avatar_url":"https://avatars.githubusercontent.com/u/64940?v=3","gravatar_id":"","url":"https://api.github.com/users/dansteen","html_url":"https://github.com/dansteen","followers_url":"https://api.github.com/users/dansteen/followers","following_url":"https://api.github.com/users/dansteen/following{/other_user}","gists_url":"https://api.github.com/users/dansteen/gists{/gist_id}","starred_url":"https://api.github.com/users/dansteen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dansteen/subscriptions","organizations_url":"https://api.github.com/users/dansteen/orgs","repos_url":"https://api.github.com/users/dansteen/repos","events_url":"https://api.github.com/users/dansteen/events{/privacy}","received_events_url":"https://api.github.com/users/dansteen/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T14:45:39Z","updated_at":"2016-04-11T14:45:39Z","body":"@jeekajoo do you instantiate  your module more than once?"}}