I want to retrieve the IP addresses of EC2 instances hosting the Apache Solr application getting created through my CFT along with the port number it is running on. I need to pass this information to another stack. Is there any way I can do this?
Asked
Active
Viewed 146 times
1 Answers
0
Generally this is done through CloudFormation Outputs: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
The syntax is shown below:
"Outputs" : {
"Logical ID" : {
"Description" : "Information about the value",
"Value" : "Value to return",
"Export" : {
"Name" : "Value to export"
}
}
}
Or for an example: Here we define a simple EC2 Instance
"Server" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
}
}
And in this statement we are exposing the public ip attribute for the instance.
"Outputs" : {
"PublicIp" : {
"Value" : { "Fn::GetAtt" : [ "Server", "PublicIp" ]},
"Description" : "Server's PublicIp Address"
}
}
(examples gotten from this issue: AWS CloudFormation: How to output a machine's PublicIP? Credit should go to: Matt Houser)
By default Solr runs on port: 8983 so unless this is not the case, this can probably be used.
In that case your Outputs might look like this:
"Outputs" : {
"PublicIp" : {
"Value" : { "Fn::GetAtt" : [ "Server", "PublicIp" ]},
"Description" : "Server's PublicIp Address"
},
"SolrPort" : {
"Value" : "8983",
"Description" : "Port that Solr is running on."
}
}

J. Meijers
- 949
- 8
- 14