connect instance to ECS cluster by user data script in launch template is not functioning properly

122 views Asked by At

I have specific user data script which connect my instance to ecs cluster, weirdly it doesn't work unless I connect to the instance and manually stop and then start ecs service on it once again. After that it works completely fine.

user data script:

#!/bin/bash

sudo amazon-linux-extras disable docker
sudo amazon-linux-extras install -y ecs
echo ECS_CLUSTER=ClusterName | sudo tee -a /etc/ecs/ecs.config
echo ECS_ENABLE_GPU_SUPPORT=true | sudo tee -a /etc/ecs/ecs.config
sudo systemctl enable --now ecs

adding

sudo systemctl stop ecs
sudo systemctl start ecs

at the end didn't help, but when I do it manually after logging in to the instance it does help.

1

There are 1 answers

0
Danyil Poprotskyi On

https://github.com/aws/amazon-ecs-agent/issues/1707

adding --no-block helped:

systemctl enable --now --no-block ecs.service