したがって、3つの異なるインスタンス「タイプ」(サーバー、エージェント、リレー)を持つAWSCloudFormationテンプレートがあります
AutoScalingを使用して、あるタイプのインスタンスをX個動的に起動しています。
私の問題は、テンプレートの出力から、できればセクションにソートされた、これらのサーバーのすべてのIPが必要なことです。
すなわち
サーバー:xxxx yyyy
リレー:zzzz
エージェント:aaaa
出力からインスタンスIDだけを取得するにはどうすればよいですか?(IDからIPを取得できます)
添付テンプレート:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "uDeploy Agent-Relay-Server",
"Parameters" : {
"keyName" : {
"Description" : "SSH key to enable access on the servers",
"Type" : "String",
"Default" : "nick-portal"
},
"ServerInstanceCount" : {
"Description" : "Number of Servers to start",
"Type" : "Number",
"Default" : "1"
},
"RelayInstanceCount" : {
"Description" : "Number of Agent Relays to start",
"Type" : "Number",
"Default" : "2"
},
"AgentInstanceCount" : {
"Description" : "Number of Agents to start",
"Type" : "Number",
"Default" : "4"
},
"ServerAMI" : {
"Description" : "",
"Type" : "String",
"Default" : "ami-7539b41c"
},
"RelayAMI" : {
"Description" : "",
"Type" : "String",
"Default" : "ami-7539b41c"
},
"AgentAMI" : {
"Description" : "",
"Type" : "String",
"Default" : "ami-7539b41c"
},
"ServerUserData" : {
"Description" : "",
"Type" : "String",
"Default" : "#!/bin/bash"
},
"RelayUserData" : {
"Description" : "",
"Type" : "String",
"Default" : "#!/bin/bash"
},
"AgentUserData" : {
"Description" : "",
"Type" : "String",
"Default" : "#!/bin/bash"
},
"Zone" : {
"Description" : "",
"Type" : "String",
"Default" : "us-east-1d"
}
},
"Resources" : {
"ServerLaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"KeyName" : { "Ref" : "keyName" },
"ImageId" : { "Ref" : "ServerAMI" },
"UserData" : { "Fn::Base64" : { "Ref" : "ServerUserData" } },
"SecurityGroups" : [ { "Ref" : "ServerSecurityGroup" }, { "Ref" : "SshSecurityGroup" } ],
"InstanceType" : "t1.micro"
}
},
"RelayLaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"KeyName" : { "Ref" : "keyName" },
"ImageId" : { "Ref" : "RelayAMI" },
"UserData" : { "Fn::Base64" : { "Ref" : "RelayUserData" } },
"SecurityGroups" : [ { "Ref" : "RelaySecurityGroup" }, { "Ref" : "SshSecurityGroup" } ],
"InstanceType" : "t1.micro"
}
},
"AgentLaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"KeyName" : { "Ref" : "keyName" },
"ImageId" : { "Ref" : "AgentAMI" },
"UserData" : { "Fn::Base64" : { "Ref" : "AgentUserData" } },
"SecurityGroups" : [ { "Ref" : "AgentSecurityGroup" }, { "Ref" : "SshSecurityGroup" } ],
"InstanceType" : "t1.micro"
}
},
"ServerAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [ { "Ref" : "Zone" } ],
"LaunchConfigurationName" : { "Ref" : "ServerLaunchConfig" },
"MinSize" : { "Ref" : "ServerInstanceCount" },
"MaxSize" : { "Ref" : "ServerInstanceCount" }
}
},
"RelayAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [ { "Ref" : "Zone" } ],
"LaunchConfigurationName" : { "Ref" : "RelayLaunchConfig" },
"MinSize" : { "Ref" : "RelayInstanceCount" },
"MaxSize" : { "Ref" : "RelayInstanceCount" }
}
},
"AgentAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [ { "Ref" : "Zone" } ],
"LaunchConfigurationName" : { "Ref" : "AgentLaunchConfig" },
"MinSize" : { "Ref" : "AgentInstanceCount" },
"MaxSize" : { "Ref" : "AgentInstanceCount" }
}
},
"RelaySecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable inbound 20080 and 7916 from Agents",
"SecurityGroupIngress" :
[
{
"IpProtocol" : "tcp",
"FromPort" : "20080",
"ToPort" : "20080",
"SourceSecurityGroupName" : { "Ref" : "AgentSecurityGroup" }
},
{
"IpProtocol" : "tcp",
"FromPort" : "7916",
"ToPort" : "7916",
"SourceSecurityGroupName" : { "Ref" : "AgentSecurityGroup" }
}
]
}
},
"ServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable inbound 8080 all and 7918 from Relays",
"SecurityGroupIngress" : [
{
"IpProtocol" : "tcp",
"FromPort" : "7918",
"ToPort" : "7918",
"SourceSecurityGroupName" : { "Ref" : "RelaySecurityGroup" }
},
{
"IpProtocol" : "tcp",
"FromPort" : "8080",
"ToPort" : "8080",
"CidrIp" : "0.0.0.0/0"
}
]
}
},
"AgentSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable no inbound",
"SecurityGroupIngress" : []
}
},
"SshSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH from all",
"SecurityGroupIngress" : [
{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
}
]
}
}
},
"Outputs" : {
"Ip"
}
}