Set AWS CentOS7 Hostname

Set AWS CentOS7 Hostname

How to change CentOS7 hostname EC2 at AWS

First thing, connect in your instance and…

set the hostname

hostnamectl set-hostname --static hostname.domain.tld

After, you should edit cloud.cfg

vi /etc/cloud/cloud.cfg

and add preserve_hostname: true

cloud_dir: /var/lib/cloud
templates_dir: /etc/cloud/templates
ssh_svcname: sshd

preserve_hostname: true

# vim:syntax=yaml

Other thing very important when you use EC2 instances is to setup the timezone.

ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime