是否可以通过 CF 模板在 elbv2 目标组中注册 ec2 节点?
Is it possible to register ec2 node in elbv2 target group via CF template?
我将 AWS::ELBv2 与一组规则一起使用,这些规则将请求重定向到我的 EC2 实例上多个 tcp 端口上的不同服务 运行。我的应用程序不支持缩放,所以我不能使用自动缩放组,我只需要将 ELBv2 附加到我的 ec2 实例。我们正在使用 CloudFormation 进行部署自动化。
通过自动缩放,我可以使用 AutoscalingCluster 的 TargetGroupARNs 属性:
"AutoScalingCluster": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"TargetGroupARNs": [
{
"Ref": "FirstappTargetGroup"
},
{
"Ref": "SecondappTargetGroup"
}
],
...
}
但是 AWS::EC2::Instance 没有这样的 属性(根据 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html)并且也没有与目标组相关的属性。
创建堆栈后可以在目标组中注册节点,但这是额外的步骤,可能不方便。
您可以将 ec2 节点指定为目标:在 AWS::ElasticLoadBalancingV2::TargetGroup
"MyTargetGroup": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Port": 80,
"Protocol": "HTTP",
"VpcId": {
"Ref": "VpcId"
},
"Targets": [
{
"Id": {
"Ref": "MyEC2Node"
}
}
]
}
}
所以它不是 EC2 节点 属性,在这种情况下它是 TargetGroup 属性。
aws api 也没有通过 aws elbv2 describe-target-groups
显示 属性
我将 AWS::ELBv2 与一组规则一起使用,这些规则将请求重定向到我的 EC2 实例上多个 tcp 端口上的不同服务 运行。我的应用程序不支持缩放,所以我不能使用自动缩放组,我只需要将 ELBv2 附加到我的 ec2 实例。我们正在使用 CloudFormation 进行部署自动化。
通过自动缩放,我可以使用 AutoscalingCluster 的 TargetGroupARNs 属性:
"AutoScalingCluster": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"TargetGroupARNs": [
{
"Ref": "FirstappTargetGroup"
},
{
"Ref": "SecondappTargetGroup"
}
],
...
}
但是 AWS::EC2::Instance 没有这样的 属性(根据 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html)并且也没有与目标组相关的属性。
创建堆栈后可以在目标组中注册节点,但这是额外的步骤,可能不方便。
您可以将 ec2 节点指定为目标:在 AWS::ElasticLoadBalancingV2::TargetGroup
"MyTargetGroup": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Port": 80,
"Protocol": "HTTP",
"VpcId": {
"Ref": "VpcId"
},
"Targets": [
{
"Id": {
"Ref": "MyEC2Node"
}
}
]
}
}
所以它不是 EC2 节点 属性,在这种情况下它是 TargetGroup 属性。
aws api 也没有通过 aws elbv2 describe-target-groups