ECS agent not available on Amazon ECS optimised AMI

0

AMI ID: amzn2-ami-ecs-hvm-2.0.20200115-x86_64-ebs (ami-03f05a4c7314d92be)
Symptom: from console, see attached file. When click on 'update agent' button, it came back with 'There is no update available for your container agent.'

SSH onto the EC2 Instance

$ sudo yum update -y ecs-init
Loaded plugins: priorities, update-motd, upgrade-helper
amzn2-core                                                                                                                                                                                                                                               | 2.4 kB  00:00:00     
No packages marked for update
[ec2-user@ip-10-215-20-34 ~]$ service docker restart && sudo start ecs
Redirecting to /bin/systemctl restart docker.service
Failed to restart docker.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status docker.service' for details.
[ec2-user@ip-10-215-20-34 ~]$ which ecs-init
/usr/bin/which: no ecs-init in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin)
[ec2-user@ip-10-215-20-34 ~]$ sudo docker -v
Docker version 18.09.9-ce, build 039a7df

So ecs-init is missing from this AMI
Ref: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/agent-update-ecs-ami.html
Ref: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.htmlw

Edited by: Nemoisme on Feb 12, 2020 5:15 AM
Edit for clarity and add references

asked 4 years ago648 views
1 Answer
0

AMI ID: amzn2-ami-ecs-hvm-2.0.20200115-x86_64-ebs (ami-03f05a4c7314d92be)
1.
I add this role 'AmazonEC2ContainerServiceforEC2Role' to the ECS Task Executioner (Cloud Formation ECS service stack). Delete and rerun create-stack

  TaskExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      Path: /
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: ecs-tasks.amazonaws.com
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
        - arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role

(ssh onto the instance, then)
2 install ecs and starts it
$ sudo amazon-linux-extras install -y ecs
$ sudo yum update -y ecs-init
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update
Note:
The way in https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html to start ecs doesn't work for me.

$ service docker restart && sudo start ecs
sudo: start: command not found

3 Test launching tasks
From AWS ECS Console, I then manually launched new task like the one created & stopped by CF stack.

  1. The tasks stopped again.
    Task failed to start
    Nginx, webapp tasks does have any Cloud Watch Log. But mysql task does ping down to some settings problem, so I fixed it there.
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions