New EC2 instance within default public subnet doesn't get public IP address

2

Hi everyone!

Since I've set up an AWS infrastructure for a web project using ECS cluster more than a year ago everything was fine. Until yesterday when I've decided to update AMI to the freshest official Amazon ECS-optimized image. I've updated launch configuration, terminated an instance, and started waiting until it will be recreated by auto-scaling group. The new instance was created but I've noticed that it didn't get public IP address. It was attached to the same default public subnet with an attribute "Auto-assign public IPv4 address" equals to "Yes". Also, I've noticed that the instances system log contains some errors related to internet connectivity. Here is a piece of it:

<13>Oct 17 17:06:17 user-data: + for i in '{1..5}'
<13>Oct 17 17:06:17 user-data: + yum install -y bind-utils htop less postgresql traceroute aws-cli awslogs jq screen
<13>Oct 17 17:06:17 user-data: Loaded plugins: priorities, update-motd, upgrade-helper
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:  One of the configured repositories failed (Unknown),
<13>Oct 17 17:06:36 user-data:  and yum doesn't have enough cached data to continue. At this point the only
<13>Oct 17 17:06:36 user-data:  safe thing yum can do is fail. There are a few ways to work "fix" this:
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:      1. Contact the upstream for the repository and get them to fix the problem.
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:      2. Reconfigure the baseurl/etc. for the repository, to point to a working
<13>Oct 17 17:06:36 user-data:         upstream. This is most often useful if you are using a newer
<13>Oct 17 17:06:36 user-data:         distribution release than is supported by the repository (and the
<13>Oct 17 17:06:36 user-data:         packages for the previous distribution release still work).
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:      3. Run the command with the repository temporarily disabled
<13>Oct 17 17:06:36 user-data:             yum --disablerepo=<repoid> ...
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:      4. Disable the repository permanently, so yum won't use it by default. Yum
<13>Oct 17 17:06:36 user-data:         will then just ignore the repository until you permanently enable it
<13>Oct 17 17:06:36 user-data:         again or use --enablerepo for temporary usage:
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:             yum-config-manager --disable <repoid>
<13>Oct 17 17:06:36 user-data:         or
<13>Oct 17 17:06:36 user-data:             subscription-manager repos --disable=<repoid>
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:      5. Configure the failing repository to be skipped, if it is unavailable.
<13>Oct 17 17:06:36 user-data:         Note that yum will try to contact the repo. when it runs most commands,
<13>Oct 17 17:06:36 user-data:         so will have to try and fail each time (and thus. yum will be be much
<13>Oct 17 17:06:36 user-data:         slower). If it is a very temporary problem though, this is often a nice
<13>Oct 17 17:06:36 user-data:         compromise:
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data:             yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
<13>Oct 17 17:06:36 user-data: 
<13>Oct 17 17:06:36 user-data: Cannot find a valid baseurl for repo: amzn2-core/2/x86_64
<13>Oct 17 17:06:36 user-data: Could not retrieve mirrorlist https://amazonlinux-2-repos-us-east-1.s3.dualstack.us-east-1.amazonaws.com/2/core/latest/x86_64/mirror.list  error was
<13>Oct 17 17:06:36 user-data: 12: Timeout on https://amazonlinux-2-repos-us-east-1.s3.dualstack.us-east-1.amazonaws.com/2/core/latest/x86_64/mirror.list : (28, 'Failed to connect to amazonlinux-2-repos-us-east-1.s3.dualstack.us-east-1.amazonaws.com  port 443 after 2702 ms: Connection timed out')
<13>Oct 17 17:06:36 user-data: + sleep 60

And it's not clear what was the reason and what was the effect. Either instance didn't get public IP address due to errors in the instance setup process, or the instance setup process has failed due to network issues.

  • Have you tried terminating and spinning up another new instance?

asked 2 years ago251 views
1 Answer
0

The error is connection timed out and if the EC2 instance does have a public IP assigned, the issue can be with other networking configurations such as a change in the route table, security group, etc. I recommend taking a look at the following article to troubleshoot.

AWS
Taka_M
answered 2 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