If you need to set the hostname on a linux server, and you are using Terraform, then you can do the following:

Include the provisioner block and set it to remote-exec:

1
2
3
provisioner "remote-exec" {
  inline = ["sudo hostnamectl set-hostname friendly.example.com"]
}