AWS Cloudformation 未能确认 AutoScalingGroup

AWS Cloudformation failing to acknowledge AutoScalingGroup

在使用 CloudFormation 创建 EC2 实例和自动缩放组时,我遇到了错误: The following resource(s) failed to create: [WebsInstanceServerGroup].

image of CloudFormation Group output

创建 Auto Scaling 组时失败,但是当我检查 Auto Scaling 组控制台时,它说创建是 'successful.'('in-progress' 删除发生在 15 分钟后从 CloudFormation 输出值)。

image of AutoScaling output

CloudFormation 未确认已成功创建 AutoScale 组的原因可能是什么?

该错误还说明了一些关于 WebInstanceServerGroup 的信息,因此我为此检查了我的模板,但没有发现任何可疑之处。

"WebsInstanceServerGroup": {
  "Type": "AWS::AutoScaling::AutoScalingGroup",
  "Properties": {
    "AvailabilityZones": {
      "Fn::GetAZs": "AWS::Region"
    },
    "VPCZoneIdentifier": {
      "Ref": "WebsELBSubnetId"
    },
    "LoadBalancerNames": [
      {
        "Ref": "WebsELB"
      }
    ],
    "LaunchConfigurationName": {
      "Ref": "WebsEC2Instance"
    },
    "Cooldown": 300,
    "HealthCheckGracePeriod": 600,
    "HealthCheckType": "EC2",
    "Tags": [
      {
        "Key": "Name",
        "Value": {
          "Ref": "WebsInstanceName"
        },
        "PropagateAtLaunch": "true"
      },
      {
        "Key": "Service",
        "Value": {
          "Ref": "ServiceTag"
        },
        "PropagateAtLaunch": "true"
      }
    ],
    "MinSize": {
      "Ref": "ASGMin"
    },
    "DesiredCapacity": {
      "Ref": "ASGDesired"
    },
    "MaxSize": {
      "Ref": "ASGMax"
    }
  },
  "CreationPolicy": {
    "ResourceSignal": {
      "Count": {
        "Ref": "ASGMin"
      },
      "Timeout": "PT15M"
    }
  }
}

如果需要更多信息,请告诉我,在此先感谢。

您的自动缩放组中的 EC2 实例似乎没有发送 the required success signals

CloudFormation 将等待您发送 ASGMin 信号,然后才认为您的 WebsInstanceServerGroup 已成功创建。因此,如果 ASGMin 设置为 3,则您的 3 个 EC2 实例中的每一个都应该发送一个信号。

要发送信号,您可以使用 cfn-signal helper, or with the AWS CLI:

aws cloudformation signal-resource \ 
  --stack-name {your stack name here} \
  --status SUCCESS \ 
  --logical-resource-id WebsInstanceServerGroup \ 
  --unique-id {the instance ID for the EC2 instance that is sending the signal}

当您认为您的 EC2 实例已完全配置并准备就绪时,请在您的 User Data 脚本末尾使用此命令。