aws-cloudformation - 用于使用现有目标组配置新 EC2 实例的 AWS CF 模板

标签 aws-cloudformation aws-ec2-instance-connect

我正在尝试配置一个新的 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/

相关文章:

c# - 如何使用 CloudFormation Template 连接到现有 EC2 实例并执行 shell 文件

amazon-web-services - AWS IAM 策略通过 ec2-instance-connect 限制对特定 ec2 实例的访问

aws-cloudformation - 启动 EC2 实例时 CloudFormation 抛出 "Value () for parameter groupId is invalid. The value cannot be empty"

amazon-web-services - 如何将可用区列表从 Terraform 传递到 CloudFormation 模板?

aws-api-gateway - 在 API 网关路径中引用授权者定义

amazon-web-services - Cloudwatch 触发 Aws lambda

amazon-web-services - 属性 IamInstanceProfile 的值必须为 String 类型

amazon-web-services - 用于 SSH 的 Amazon EC2 实例连接 - 安全组?