Skip to content

Instantly share code, notes, and snippets.

@bugb
Last active November 25, 2022 06:39
Show Gist options
  • Save bugb/91e811a783190d88f183c61cc8ad9ff3 to your computer and use it in GitHub Desktop.
Save bugb/91e811a783190d88f183c61cc8ad9ff3 to your computer and use it in GitHub Desktop.
Allocate ECS agent to another ECS cluster
sudo -s
service ecs stop
docker stop ecs-agent
docker rm ecs-agent
mv /var/lib/ecs/data/agent.db{,.bak}
sed -i 's/Prod-BC-ECS-ElasticSearch-Standard-C1/Prod-BC-ECS-ElasticSearch-Premium-C1/g' /etc/ecs/ecs.config
echo -e 'ECS_DATADIR=/data\nECS_ENABLE_TASK_IAM_ROLE=true\nECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST=true\nECS_LOGFILE=/log/ecs-agent.log\nECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]\nECS_LOGLEVEL=info' >> /etc/ecs/ecs.config
echo "ecs config is: "
cat /etc/ecs/ecs.config
docker pull public.ecr.aws/ecs/amazon-ecs-agent:latest
docker run --name ecs-agent \
--detach=true \
--restart=on-failure:10 \
--volume=/var/run:/var/run \
--volume=/var/log/ecs/:/log \
--volume=/var/lib/ecs/data:/data \
--volume=/etc/ecs:/etc/ecs \
--volume=/etc/ecs:/etc/ecs/pki \
--net=host \
--env-file=/etc/ecs/ecs.config \
amazon/amazon-ecs-agent:latest
# docker logs -f ecs-agent
service ecs start
service ecs status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment