mardi 30 décembre 2014

can I reference instance data in AWS::AutoScaling::LaunchConfiguration

We are spinning up Elasticsearch in docker containers as part of an auto scaling group and using the launchconfiguration to create the configuration file.


Ideally I would like to use the config.files to create the configuration, but I need to also set the instances IP address as the publish_host for ES.


Right now I have this in my config.files:



"/data/elasticsearch.yml" : {
"content" : { "Fn::Join" : ["", [
"path.plugins: /elasticsearch/plugins\n\n",
"network.publish_host: INSTANCE_IP\n",
"node.name: INSTANCE_NAME\n",
"cluster.name: ", { "Ref" : "AWS::StackName" }, "\n\n",
"cloud.aws.region:\n",
" ", { "Ref" : "AWS::Region" }, "\n",
"discovery:\n",
" type: ec2\n",
"\n",
"discovery.ec2.tag.Jarfish: ElasticSearch\n",
"discovery.ec2.tag.Stack: ", { "Ref" : "AWS::StackId" }, "\n",
"\n",
"cloud.node.auto_attributes: true\n",
"discovery.zen.minimum_master_nodes: 2\n"
]]}


and I later use sed do replace the INSTANCE_IP and INSTANCE_NAME as part of a script in the UserData block. It works, but has me creating the config in 2 places.


Is there a way to reference the current instance and its IP via Fn::GetAtt or Ref as part of the files like I can for the StackId and StackName?


It seems that it's possible to get the IP address of an Instance type, but since this is a LaunchConfiguration, I don't see a way to get the InstanceID that could then be used to get the IP ...





Aucun commentaire:

Enregistrer un commentaire