我正在尝试配置一个新的 EC2 实例并将其附加到我之前创建的现有 targetGroup。我确实有 targetGroupArn 和新实例的详细信息。在所有文档中,我可以看到创建新实例和新目标组并将实例 ID 引用到创建目标组的示例模板。
是否有任何选项可以仅创建新实例并将其附加到现有目标组?
这样我就可以提及新实例将附加到的targetGroupArn。 下面我提到了我正在寻找的示例模板。
{
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"TargetGroupArn": "arn:aws:elasticloadbalancing:ap-south-1:4444444444:targetgroup/MyTG/56abcccccccc56",
"Targets": [
{
"Id": {
"Ref": "ec2Instance1"
}
}
]
}
}
最佳答案
Is there any option to create only new instance and attaching it to the existing target group?
是的,您可以通过 custom resources 来做到这一点以 lambda 函数的形式。该函数将使用 AWS SDK(例如 boto3
)将实例附加到现有目标组。
关于aws-cloudformation - 用于使用现有目标组配置新 EC2 实例的 AWS CF 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71589467/