Set a static hostname in a Linux EC2 instance

Configure a static hostname in your AWS EC2 Linux instance

Add the following line into /etc/cloud/cloud.cfg

preserve_hostname: true