{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/5660","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/5660/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/5660/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/5660/events","html_url":"https://github.com/hashicorp/terraform/issues/5660","id":141303553,"number":5660,"title":"EC2 Instances for ECS do not register with clusters","user":{"login":"ajcrites","id":1308273,"avatar_url":"https://avatars.githubusercontent.com/u/1308273?v=3","gravatar_id":"","url":"https://api.github.com/users/ajcrites","html_url":"https://github.com/ajcrites","followers_url":"https://api.github.com/users/ajcrites/followers","following_url":"https://api.github.com/users/ajcrites/following{/other_user}","gists_url":"https://api.github.com/users/ajcrites/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcrites/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcrites/subscriptions","organizations_url":"https://api.github.com/users/ajcrites/orgs","repos_url":"https://api.github.com/users/ajcrites/repos","events_url":"https://api.github.com/users/ajcrites/events{/privacy}","received_events_url":"https://api.github.com/users/ajcrites/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provider/aws","name":"provider/aws","color":"bfdadc"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-16T15:09:16Z","updated_at":"2016-03-16T16:09:12Z","closed_at":null,"body":"I am effectively following [these instructions to launch an ECS Container Instance](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html). I am creating an ECS-optimized EC2 instance with the config set to the ECS cluster I want to use and the ECS IAM role:\r\n\r\n```\r\nresource \"aws_ecs_cluster\" \"ingest\" {\r\n  name = \"ingest\"\r\n}\r\n\r\nresource \"aws_iam_role\" \"ecs_ingest\" {\r\n  name = \"ecs_ingest\"\r\n  assume_role_policy = <<EOF\r\n{\r\n\"Version\": \"2012-10-17\",\r\n\"Statement\": [\r\n  {\r\n    \"Effect\": \"Allow\",\r\n    \"Principal\": {\r\n      \"Service\": \"ecs.amazonaws.com\"\r\n    },\r\n    \"Action\": \"sts:AssumeRole\"\r\n  }\r\n]\r\n}\r\nEOF\r\n}\r\n\r\nresource \"aws_iam_role_policy\" \"ecs_ingest\" { \r\n  name = \"ecs_instance_role\"\r\n  role = \"${aws_iam_role.ecs_ingest.id}\"\r\n  policy = <<EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"ecs:CreateCluster\",\r\n        \"ecs:DeregisterContainerInstance\",\r\n        \"ecs:DiscoverPollEndpoint\",\r\n        \"ecs:Poll\",\r\n        \"ecs:RegisterContainerInstance\",\r\n        \"ecs:StartTelemetrySession\",\r\n        \"ecs:Submit*\",\r\n        \"ecr:GetAuthorizationToken\",\r\n        \"ecr:BatchCheckLayerAvailability\",\r\n        \"ecr:GetDownloadUrlForLayer\",\r\n        \"ecr:BatchGetImage\",\r\n        \"ecs:StartTask\"\r\n      ],\r\n      \"Resource\": \"*\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\n\r\nresource \"aws_iam_instance_profile\" \"ingest\" {\r\n  name = \"ingest_profile\"\r\n  roles = [\"${aws_iam_role.ecs_ingest.name}\"]\r\n}\r\n\r\nresource \"aws_instance\" \"ingest\" {\r\n  # ECS-optimized AMI for us-east-1\r\n  ami = \"ami-33b48a59\"\r\n  instance_type = \"t2.micro\"\r\n  user_data = <<EOF\r\n#!/bin/bash\r\necho ECS_CLUSTER=${aws_ecs_cluster.ingest.name} >> /etc/ecs/ecs.config\r\nEOF\r\n  iam_instance_profile = \"${aws_iam_instance_profile.ingest.name}\"\r\n}\r\n```\r\n\r\nThis creates the role, the cluster, and the EC2 instance and it assigns the correct role to the EC2 instance as well, but when I view my clusters in the console there are no registered container instances. When I select the cluster and the \"ECS Instances\" tab it tells me to add additional ECS instances using Auto Scaling or EC2, but the EC2 instance I have created did not register."},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/197401640","html_url":"https://github.com/hashicorp/terraform/issues/5660#issuecomment-197401640","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/5660","id":197401640,"user":{"login":"yissachar","id":2190867,"avatar_url":"https://avatars.githubusercontent.com/u/2190867?v=3","gravatar_id":"","url":"https://api.github.com/users/yissachar","html_url":"https://github.com/yissachar","followers_url":"https://api.github.com/users/yissachar/followers","following_url":"https://api.github.com/users/yissachar/following{/other_user}","gists_url":"https://api.github.com/users/yissachar/gists{/gist_id}","starred_url":"https://api.github.com/users/yissachar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yissachar/subscriptions","organizations_url":"https://api.github.com/users/yissachar/orgs","repos_url":"https://api.github.com/users/yissachar/repos","events_url":"https://api.github.com/users/yissachar/events{/privacy}","received_events_url":"https://api.github.com/users/yissachar/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T16:09:12Z","updated_at":"2016-03-16T16:09:12Z","body":"@ajcrites If I'm not mistaken your `aws_iam_role. ecs_ingest` has the wrong service specified. You have it set as `ecs.amazonaws.com` when it should be `ec2.amazonaws.com`."}}