Sam Hammamy
Sam Hammamy

Reputation: 11017

Setting AWS EC2 instance hostname using CloudFormation template

I know that I can set the name key/tag pair in a launch config in cloudformation template like below

"SaltMasterGroup": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "DesiredCapacity": "1",
        "LaunchConfigurationName": { "Ref": "SaltMasterLaunchConfig" },
        "Tags" : [ {
         "Key" : "Name",
         "Value" : "saltmaster.lab.example.com",
         "PropagateAtLaunch" : "true"}
       ]
      }
    }

However can I set the private hostname using a CFN template? As you can see I am using salt so I am prepared to set the names using salt, but I was hoping for a CFN solution.

Upvotes: 5

Views: 6381

Answers (1)

NHol
NHol

Reputation: 2125

You can use userdata to set the host name with

sudo hostname myhost
echo myhost > /etc/hostname

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

Upvotes: 3

Related Questions