Let’s create a way to change CentOS7 hostname on 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
...
paths:
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