This problem can be solved by adding the host name to /etc/hosts or overriding the hostname when the DHCP client gets a lease.

On AWS if you're autoscaling neither solution is palatable.

Instead you can specify a script like the following as User Data (under "Advanced" if you're using the AWS console to launch your instance) to append the AWS generated hostname to the /etc/hosts file. The /etc/hosts file remains intact between reboots but the hostname can change which means this doesn't solve long lived instances, but it works with autoscaling where reboots shouldn't typically occur.


if ! grep $HOSTNAME $ETC_HOSTS > /dev/null ; then  
    if grep "" $ETC_HOSTS > /dev/null ; then
        sed -i "s/127\.0\.0\.1.*$/& $HOSTNAME/" $ETC_HOSTS
        echo " localhost $HOSTNAME" >> $ETC_HOSTS

For a longer term solution you can drop the script's contents into /etc/rc.local so it runs on startup.