Amazon ECS MissingAuthenticationTokenException

amazon-web-services

I follow this instruction http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_GetStarted.html
and here's what I got:

$ aws ecs list-clusters

{
    "clusterArns": [
        "arn:aws:ecs:us-east-1:xxx:cluster/MyCluster", 
        "arn:aws:ecs:us-east-1:xxx:cluster/default"
    ]
}

and on the EC2 instance:

$ cat /var/log/ecs/ecs-agent.log

t=2015-02-02T18:31:45+0000 lvl=info msg="Starting Agent" module=main stack=    [agent/agent.go:32]
t=2015-02-02T18:31:45+0000 lvl=info msg="Loading configuration" module=main stack=[agent/agent.go:34]
t=2015-02-02T18:31:45+0000 lvl=info msg="Connecting to docker daemon" module=main stack=[agent/agent.go:41]
t=2015-02-02T18:31:45+0000 lvl=info msg="Connected to docker daemon" module=main stack=[agent/agent.go:43]
t=2015-02-02T18:31:45+0000 lvl=info msg="Registering Instance with ECS" module=main stack=[agent/agent.go:50]
t=2015-02-02T18:31:45+0000 lvl=crit msg="Could not register" module="api client" err="{\"__type\":\"MissingAuthenticationTokenException\",\"message\":\"Missing Authentication Token\"}" stack="[github.com/aws/amazon-ecs-agent/agent/api/api_client.go:175 agent/agent.go:51]"
t=2015-02-02T18:31:45+0000 lvl=eror msg="Error registering" module=main err="{\"__type\":\"MissingAuthenticationTokenException\",\"message\":\"Missing Authentication Token\"}" stack=[agent/agent.go:53]


cat /var/log/ecs/ecs-init.log

ecs-init [Mon Feb  2 18:31:43 UTC 2015]: pre-start
ecs-init [Mon Feb  2 18:31:43 UTC 2015]: Loading Amazon EC2 Container Service Agent from file /var/cache/ecs/ecs-agent.tar
ecs-init [Mon Feb  2 18:31:44 UTC 2015]: start
ecs-init [Mon Feb  2 18:31:44 UTC 2015]: Starting Amazon EC2 Container Service Agent
ecs-init [Mon Feb  2 18:31:45 UTC 2015]: Exited 1

So where Authentication Token should be set ?

Best Answer

Authentication tokens should be set by the IAM role that you use to launch your container instance.

Did you set up an IAM role for Amazon ECS with this procedure: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/get-set-up-for-amazon-ecs.html#create-an-iam-role

Also, you need to launch your container instance with that IAM role.

Hope this helps.