{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/8426","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/8426/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/8426/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/8426/events","html_url":"https://github.com/hashicorp/terraform/issues/8426","id":172794926,"number":8426,"title":"spot instance request fails with Invalid IAM Instance Profile name","user":{"login":"richardbowden","id":311487,"avatar_url":"https://avatars.githubusercontent.com/u/311487?v=3","gravatar_id":"","url":"https://api.github.com/users/richardbowden","html_url":"https://github.com/richardbowden","followers_url":"https://api.github.com/users/richardbowden/followers","following_url":"https://api.github.com/users/richardbowden/following{/other_user}","gists_url":"https://api.github.com/users/richardbowden/gists{/gist_id}","starred_url":"https://api.github.com/users/richardbowden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardbowden/subscriptions","organizations_url":"https://api.github.com/users/richardbowden/orgs","repos_url":"https://api.github.com/users/richardbowden/repos","events_url":"https://api.github.com/users/richardbowden/events{/privacy}","received_events_url":"https://api.github.com/users/richardbowden/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":1,"created_at":"2016-08-23T20:13:08Z","updated_at":"2016-08-25T08:23:51Z","closed_at":null,"body":"Hi there,\r\n\r\nThank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.\r\n\r\n### Terraform Version\r\n0.7.1\r\n\r\n### Affected Resource(s)\r\nmay effect one of these\r\n- aws_spot_instance_request\r\n- aws_instance\r\n- aws_iam_role\r\n- aws_iam_instance_profile\r\n\r\nIf this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.\r\n\r\n### Terraform Configuration Files\r\n```hcl\r\nprovider \"aws\" {\r\n  region = \"${var.aws_region}\"\r\n}\r\n\r\nvariable \"aws_region\" {\r\n    default = \"eu-central-1\"\r\n}\r\n\r\nvariable \"keypair\" {\r\n    default = \"terratest\"\r\n}\r\n\r\nvariable \"vpc_id\" {\r\n    default = \"vpc-4005ea29\"\r\n}\r\n\r\ndata \"aws_ami\" \"ubuntu\" {\r\n  most_recent = true\r\n  filter {\r\n    name   = \"name\"\r\n    values = [\"ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*\"]\r\n  }\r\n  filter {\r\n    name   = \"virtualization-type\"\r\n    values = [\"hvm\"]\r\n  }\r\n  owners = [\"099720109477\"] # Canonical\r\n}\r\n\r\nresource \"aws_spot_instance_request\" \"consul_cluster\" {\r\n  ami                    = \"${data.aws_ami.ubuntu.id}\"\r\n  count                  = 1\r\n  spot_price             = \"0.04\"\r\n  instance_type          = \"m4.xlarge\"\r\n\r\n  iam_instance_profile   = \"${aws_iam_instance_profile.consul_instance_profile.name}\"\r\n\r\n  vpc_security_group_ids = [\"${aws_security_group.access.id}\"]\r\n  key_name               = \"${var.keypair}\"\r\n  wait_for_fulfillment   = true\r\n\r\n  tags {\r\n    Name = \"consul_srv_${count.index}\"\r\n  }\r\n}\r\n\r\nresource \"aws_security_group\" \"access\" {\r\n  name = \"consul_access\"\r\n\r\n  ingress {\r\n    from_port   = 22\r\n    to_port     = 22\r\n    protocol    = \"tcp\"\r\n    cidr_blocks = [\"0.0.0.0/0\"] //only for this example\r\n  }\r\n\r\n  egress {\r\n    from_port   = 0\r\n    to_port     = 0\r\n    protocol    = \"tcp\"\r\n    cidr_blocks = [\"0.0.0.0/0\"]\r\n  }\r\n\r\n  vpc_id = \"${var.vpc_id}\"\r\n}\r\n\r\nresource \"aws_iam_instance_profile\" \"consul_instance_profile\" {\r\n  name  = \"consul_instance_profile\"\r\n  roles = [\"${aws_iam_role.consul_iam_role.name}\"]\r\n}\r\n\r\n// IAM Stuff\r\nresource \"aws_iam_role\" \"consul_iam_role\" {\r\n  name = \"consul_iam_role\"\r\n\r\n  assume_role_policy = <<EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Action\": \"sts:AssumeRole\",\r\n      \"Principal\": {\r\n        \"Service\": \"ec2.amazonaws.com\"\r\n      },\r\n      \"Effect\": \"Allow\",\r\n      \"Sid\": \"\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\n```\r\n\r\n### Debug Output\r\nfirst run : https://gist.github.com/richardbowden/9221914de9d541f314addc9d2f1a5496\r\nsecond run: https://gist.github.com/richardbowden/d5b7d22eff89ed375314d7d54dcb0325\r\n\r\n### Panic Output\r\nn/a\r\n\r\n### Expected Behaviour\r\nthe spot request should finish without error \"Invalid IAM Instance Profile name\"\r\n\r\n### Actual Behaviour\r\non the first run (see debug output called first run), everything gets created, including iam_role and instance_profile, when the spot instance is requested, an error is produced as follows:\r\n\r\n```\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* aws_spot_instance_request.consul_cluster: Error requesting spot instances: InvalidParameterValue: Value (consul_instance_profile) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name\r\n       \tstatus code: 400, request id: ce73435e-5018-4798-8942-6b47ec013d19\r\n\r\nTerraform does not automatically rollback in the face of errors.\r\nInstead, your Terraform state file has been partially updated with\r\nany resources that successfully completed. Please address the error\r\nabove and apply again to incrementally change your infrastructure.\r\n```\r\n\r\nHowever, this is not the case, when checking the iam_role and instance_profile using the aws cli tools, both are present and correct.\r\n\r\nOn running `terraform apply` a second time, the spot request is created with no errors, the iam_role and instance_profile are used from the previous run\r\n\r\n### Steps to Reproduce\r\nPlease list the steps required to reproduce the issue, for example:\r\n1. change vars `vpc_id` and `keypair` in the config above\r\n2. `terraform apply` we get a failure (debug run 1)\r\n3. `terraform apply` the second time it works (debug run 2)\r\n\r\n### Important Factoids\r\nn/a\r\n\r\n### References\r\nN/A\r\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/242314544","html_url":"https://github.com/hashicorp/terraform/issues/8426#issuecomment-242314544","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/8426","id":242314544,"user":{"login":"kbarek","id":94371,"avatar_url":"https://avatars.githubusercontent.com/u/94371?v=3","gravatar_id":"","url":"https://api.github.com/users/kbarek","html_url":"https://github.com/kbarek","followers_url":"https://api.github.com/users/kbarek/followers","following_url":"https://api.github.com/users/kbarek/following{/other_user}","gists_url":"https://api.github.com/users/kbarek/gists{/gist_id}","starred_url":"https://api.github.com/users/kbarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbarek/subscriptions","organizations_url":"https://api.github.com/users/kbarek/orgs","repos_url":"https://api.github.com/users/kbarek/repos","events_url":"https://api.github.com/users/kbarek/events{/privacy}","received_events_url":"https://api.github.com/users/kbarek/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T08:23:51Z","updated_at":"2016-08-25T08:23:51Z","body":"Ran into this bug with terraform 0.7.0 and 0.7.1. It doesn't happen on every apply, but when it does a second apply always succeeds."}}
{"actor":{"display_login":"kbarek"}}