Commit d5e0a59
committed
Remove nameserver from resolv.conf at the end of AMI build
The conditional statement avoids cleaning if the `/etc/resolv.conf` is a symbolic link. It is a symbolic link when it is managed by other systems.
Cleaning the `/etc/resolv.conf` speeds up instance launch because it wouldn't try to use name server from the AMI creation environment. The delay was shown in `/var/log/cloud-init.log`:
```
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 40.099 seconds
2025-03-19 16:00:07,721 - util.py[DEBUG]: Resolving URL: http://[fd00:ec2::254] took 0.000 seconds
2025-03-19 16:00:17,731 - util.py[DEBUG]: Resolving URL: http://instance-data.:8773 took 10.010 seconds
```
Example content of `/etc/resolv.conf`:
```
cat /etc/resolv.conf
# Generated by NetworkManager
search ec2.internal
nameserver 192.168.0.2
```
Signed-off-by: Hanwen <[email protected]>1 parent cd24ecb commit d5e0a59
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments