The title nearly says it all. I have a VM in EC2 running CentOS 7. It uses DHCP, which seems to be a EC2 requirement. DHCP keeps overwriting the hostname on reboot, no matter what I try. I won't enumerate it, but I've tried pretty much every suggestion here: Override DHCP hostname on RHEL5/CentOS/Amazon Linux as well as those found on several other sites that google searches turned up. I don't understand if it's the particular OS version or AWS/EC2 environment, but I can't change the hostname and make it stick across reboots. Even brute forcing it via /etc/rc.d/rc.local (adding "/bin/hostnamectl set-hotname foo.bar.baz" did not work. I can't believe other AWS/EC2 users haven't figured this out. Please help.
Update: This also does not work: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html I.e., adding a DNS A record for the box in AWS's Route53 (and verifying it works), and setting HOSTNAME=foo.bar.baz in /etc/sysconfig/network (checking after a reboot) is also futile.
Update 2: A similar question was answered for Fedora 20. The accepted solution there also involved reconfiguring cloud-init, though in a different manner. Also, it wasn't clear that that question/solution applies to other distros. Thus, I feel my question should probably remain for others running CentOS and searching for it that way (yes, I know Fedora and CentOS are siblings, but not everyone googles for all synonyms when searching for solutions).