Unable to bootstrap EC2 server with user data

0

I am creating an AWS EC2 t2.micro and using the below user data. I added the condition to check for the presence of the "BootstrapCompleted " file and run updates AFTER that.


    #!/bin/bash
    while  [  ! -f /tmp/BootstrapCompleted ]
    do
      sleep 300
    done
    echo "file found" >> /tmp/ameya.log
    echo -e "Ameya is going mad" >> /tmp/ameya.log
    sleep 120
    yum update -y >> /tmp/ameya.log
    echo -e "\n My Sanity is restored" >> /tmp/ameya.log

However, when I do SSH to the VM and run

yum update -y

It runs the updates meaning they are not installed with User Data.

checked the log file

cat /var/log/cloud-init-output.log

I see some issue here. Last few lines output as below.

Cloud-init v. 22.1-5.el8 running 'modules:config' at Thu, 23 Feb 2023 01:59:01 +0000. Up 101.14 seconds.
Errors during downloading metadata for repository 'epel':
  - Curl error (6): Couldn't resolve host name for https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/repodata/repomd.xml [Could not resolve host: dl.fedoraproject.org]
Error: Failed to download metadata for repo 'epel': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Cloud-init v. 22.1-5.el8 running 'modules:final' at Thu, 23 Feb 2023 02:00:10 +0000. Up 170.00 seconds.
Cloud-init v. 22.1-5.el8 finished at Thu, 23 Feb 2023 02:02:12 +0000. Datasource DataSourceEc2Local.  Up 291.76 seconds

I note that ameya.log is created as per below.

[root@ANL62600251 ~]# cat /tmp/ameya.log 
file found
Ameya is going mad
Extra Packages for Enterprise Linux 8 - x86_64  0.0  B/s |   0  B     00:00    

 My Sanity is restored

I now run

yum update

Interesting observation is

yum update
Extra Packages for Enterprise Linux 8 - x86_64                                                          6.5 kB/s | 4.7 kB     00:00    

This tells me that, when yum update was running it had no internet connection?

질문됨 일 년 전251회 조회
1개 답변
0

Hello, Greetings of the day!! Thank you for contacting AWS.

I understand you are getting the following error while installing updates on your EC2 instance via user-data script a stack

"Error: Failed to download metadata for repo 'epel': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried",

However, the updates are getting installed successfully while connecting to the instance via SSH. You believe that this could be an issue with internet connectivity during the execution of user-data script.

As per the details mentioned in your query, it seems that this could occur due to either DNS resolution issue or lack of internet connectivity. However, to better address the issue, we require details that are non-public information. Thus, I request you to kindly open a support case with AWS using the following link https://console.aws.amazon.com/support/home#/case/create

Thank you and have a nice day!!

AWS
지원 엔지니어
Aditi_B
답변함 일 년 전

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

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

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

관련 콘텐츠