Skip to content

Commit

Permalink
Merge pull request #11 from base2Services/feature/custom-hostname
Browse files Browse the repository at this point in the history
Use instance_name config when setting hostname
  • Loading branch information
Guslington authored Oct 2, 2019
2 parents 7a8b028 + 50dfa55 commit cc5913f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bastion.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
bastion_userdata = [
"#!/bin/bash\n",
"aws --region ", Ref("AWS::Region"), " ec2 associate-address --allocation-id ", FnGetAtt('BastionIPAddress','AllocationId') ," --instance-id $(curl http://169.254.169.254/2014-11-05/meta-data/instance-id -s)\n",
"hostname ", Ref('EnvironmentName') ,"-" ,"bastion-`/opt/aws/bin/ec2-metadata --instance-id|/usr/bin/awk '{print $2}'`\n",
"sed '/HOSTNAME/d' /etc/sysconfig/network > /tmp/network && mv -f /tmp/network /etc/sysconfig/network && echo \"HOSTNAME=", Ref('EnvironmentName') ,"-" ,"bastion-`/opt/aws/bin/ec2-metadata --instance-id|/usr/bin/awk '{print $2}'`\" >>/etc/sysconfig/network && /etc/init.d/network restart\n",
"hostname ", Ref('EnvironmentName') ,"-" ,"#{instance_name}-`/opt/aws/bin/ec2-metadata --instance-id|/usr/bin/awk '{print $2}'`\n",
"sed '/HOSTNAME/d' /etc/sysconfig/network > /tmp/network && mv -f /tmp/network /etc/sysconfig/network && echo \"HOSTNAME=", Ref('EnvironmentName') ,"-" ,"#{instance_name}-`/opt/aws/bin/ec2-metadata --instance-id|/usr/bin/awk '{print $2}'`\" >>/etc/sysconfig/network && /etc/init.d/network restart\n",
]

bastion_userdata.push(*userdata.split("\n")) if defined? userdata
Expand Down

0 comments on commit cc5913f

Please sign in to comment.