EC2 instance is not registered in ECS cluster

0

I created an ECS cluster for EC2 Linux + Networking, spot instance from web UI wizard. However, the instances never appear on the UI. I double-checked roles and policies, and I believe every permission is granted.

In the instances, I found an error in the cloud-init log file /var/log/cloud-init-output.log saying:

/var/lib/cloud/instance/scripts/part-001: line 7: /etc/init/spot-instance-termination-notice-handler.conf: No such file or directory

The auto-generated user data is:

#!/bin/bash
echo ECS_CLUSTER=my-cluster >> /etc/ecs/ecs.config;echo ECS_BACKEND_HOST= >> /etc/ecs/ecs.config;
export PATH=/usr/local/bin:$PATH
yum -y install jq
yum install -y awscli
aws configure set default.region ap-northeast-1
cat <<EOF > /etc/init/spot-instance-termination-notice-handler.conf
... 

I didn't modify the script and apparently, there is no such directory /etc/init in the latest AMI (amzn2-ami-ecs-gpu-hvm-2.0.20220831-x86_64-ebs)

질문됨 2년 전298회 조회
1개 답변
0

the error is happening because the /etc/init directory does not exist in ec2. add a mkdir /etc/init before the cat <<EOF > in your userdata.

#!/bin/bash
echo ECS_CLUSTER=my-cluster >> /etc/ecs/ecs.config;echo ECS_BACKEND_HOST= >> /etc/ecs/ecs.config;
export PATH=/usr/local/bin:$PATH
yum -y install jq
yum install -y awscli
aws configure set default.region ap-northeast-1
**mkdir /etc/init**
cat <<EOF > /etc/init/spot-instance-termination-notice-handler.conf
답변함 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠