gpt4 book ai didi

amazon-web-services - CloudFormation AutoscalingGroup "LoadBalancer attachments did not stabilize"

转载 作者:行者123 更新时间:2023-12-02 20:51:29 28 4
gpt4 key购买 nike

所以我正在使用 ECS(通过 ecs-cli 创建)和 CloudFormation,并且在创建自动缩放组时遇到问题: Attachments did not stabilize

它始终失败,提示“LoadBalancer 附件不稳定”。有谁知道这可能是什么原因造成的?

我有两个 CloudFormation 堆栈,一个主要堆栈用于设置我的大部分基础设施,第二个堆栈(出现故障)用于第二个 ECS 集群。我正在从第一个/主堆栈的输出传递输入参数。

我认为这可能是子网大小问题(它们在第一个堆栈中创建并传递到第二个堆栈,10.0.0.0/24 和 10.0.1.0/24),所以我尝试在第二个cloudformation模板并使用它们,但它导致了同样的错误。

在两个模板文件之间创建相同的自动缩放组和 ELB...

第一堆:

"InternetGateway": {
"Condition": "CreateVpcResources",
"Type": "AWS::EC2::InternetGateway"
},
"AttachGateway": {
"Condition": "CreateVpcResources",
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"InternetGatewayId": {
"Ref": "InternetGateway"
}
}
},
"RouteViaIgw": {
"Condition": "CreateVpcResources",
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "Vpc"
}
}
},
"PublicRouteViaIgw": {
"Condition": "CreateVpcResources",
"DependsOn": "AttachGateway",
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "RouteViaIgw"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "InternetGateway"
}
}
},
"PubSubnet1RouteTableAssociation": {
"Condition": "CreateVpcResources",
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "PubSubnetAz1"
},
"RouteTableId": {
"Ref": "RouteViaIgw"
}
}
},
"PubSubnet2RouteTableAssociation": {
"Condition": "CreateVpcResources",
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "PubSubnetAz2"
},
"RouteTableId": {
"Ref": "RouteViaIgw"
}
}
},
"Outputs": {
"VpcId": {
"Value": { "Ref": "Vpc" }
},
"KeyName": {
"Value": { "Ref": "KeyName" }
},
"SourceCidr": {
"Value": { "Ref": "SourceCidr"}
},
"EcsInstancePolicy": {
"Value": { "Ref": "EcsInstancePolicy" }
},
"SubnetIds": {
"Value": {
"Fn::Join": [
",", [{
"Ref": "PubSubnetAz1"
},
{
"Ref": "PubSubnetAz2"
}
]
]
}
},
"CloudSecurityGroup": {
"Value": { "Ref": "EcsSecurityGroup" }
},
"GatewayRouteTable": {
"Value": { "Ref": "PublicRouteViaIgw" }
}
}

第二堆:

"Parameters": {
"EcsAmiId": {
"Type": "String",
"Description": "ECS EC2 AMI id",
"Default": ""
},
"EcsInstanceType": {
"Type": "String",
"Description": "ECS EC2 instance type",
"ConstraintDescription": "must be a valid EC2 instance type."
},
"KeyName": {
"Type": "AWS::EC2::KeyPair::KeyName",
"Description": "Required - Name of an existing EC2 KeyPair to enable SSH access to the ECS instances"
},
"VpcId": {
"Type": "String",
"Description": "Required - VPC Id of existing VPC of Central stack.",
"AllowedPattern": "^(?:vpc-[0-9a-f]{8}|)$",
"ConstraintDescription": "VPC Id must begin with 'vpc-'"
},
"SubnetIds": {
"Type": "String",
"Description": "Required - Comma separated list of two (2) existing VPC Subnet Ids where ECS instances will run."
},
"AsgMaxSize": {
"Type": "Number",
"Description": "Maximum size and initial Desired Capacity of ECS Auto Scaling Group",
"Default": "1"
},
"SourceCidr": {
"Type": "String",
"Description": "Required - Input CIDR/IP range to open up for ECS and Aurora"
},
"EcsInstancePolicy": {
"Type": "String",
"Description": "Required - IAM Policy for the ECS instances to use"
},
"EcsCluster": {
"Type": "String",
"Description": "ECS Cluster Name",
"Default": "default"
},
"CloudSecurityGroup": {
"Type": "String",
"Description": "Name of the security group used by the ECS instances in the Cloud cluster"
},
},
"Resources": {
"EcsSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "ECS Allowed Ports",
"VpcId": { "Ref": "VpcId" },
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": 22,
"ToPort": 22,
"SourceSecurityGroupId": { "Ref": "CloudSecurityGroup" }
},
{
"IpProtocol": "tcp",
"FromPort": 11000,
"ToPort": 11001,
"SourceSecurityGroupId": { "Ref": "CloudSecurityGroup" }
},
{
"IpProtocol": "tcp",
"FromPort": 22,
"ToPort": 22,
"CidrIp": { "Ref": "SourceCidr" }
},
{
"IpProtocol": "tcp",
"FromPort": 11000,
"ToPort": 11001,
"CidrIp": { "Ref": "SourceCidr" }
}
]
}
},
"EcsSecurityGroupIngressSelf": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "EcsSecurityGroup" },
"SourceSecurityGroupId": { "Ref": "EcsSecurityGroup" },
"IpProtocol": "tcp",
"FromPort": 22,
"ToPort": 9999
}
},
"ElasticLoadBalancer": {
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties": {
"Subnets": {
"Fn::Split": [
",",
{ "Ref": "SubnetIds" }
]
},
"CrossZone": "true",
"SecurityGroups": [{
"Ref": "EcsSecurityGroup"
}],
"Listeners": [{
"LoadBalancerPort": "22",
"InstancePort": "22",
"Protocol": "TCP"
},
{
"LoadBalancerPort": "11000",
"InstancePort": "11000",
"Protocol": "TCP"
},
{
"LoadBalancerPort": "11001",
"InstancePort": "11001",
"Protocol": "TCP"
}
],
"HealthCheck": {
"HealthyThreshold": "2",
"Interval": "30",
"Target": "TCP:22",
"Timeout": "5",
"UnhealthyThreshold": "5"
}
}
},
"EcsInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [{
"Ref": "EcsInstancePolicy"
}]
}
},
"EcsInstanceLc": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "EcsAmiId"
},
"InstanceType": {
"Ref": "EcsInstanceType"
},
"AssociatePublicIpAddress": true,
"IamInstanceProfile": {
"Ref": "EcsInstanceProfile"
},
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroups": [{
"Ref": "EcsSecurityGroup"
}],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"", [
"#!/bin/bash\n",
"echo ECS_CLUSTER=",
{
"Ref": "EcsCluster"
},
" >> /etc/ecs/ecs.config\n"
]
]
}
}
}
},
"EcsInstanceAsg": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"VPCZoneIdentifier": [{ "Ref": "SubnetIds" }],
"LaunchConfigurationName": {
"Ref": "EcsInstanceLc"
},
"MinSize": "1",
"MaxSize": {
"Ref": "AsgMaxSize"
},
"DesiredCapacity": {
"Ref": "AsgMaxSize"
},
"LoadBalancerNames": [{ "Ref": "ElasticLoadBalancer" }],
"Tags": [{
"Key": "Name",
"Value": {
"Fn::Join": [
"", [
"ECS Instance - ",
{
"Ref": "AWS::StackName"
}
]
]
},
"PropagateAtLaunch": "true"
}]
}
},

如果有任何额外信息有帮助,请告诉我

最佳答案

从您的屏幕截图来看,CloudFormation 堆栈以及 EcsInstanceAsg Auto Scaling 组似乎是之前创建的,并且您正在尝试更新 Auto Scaling 组以引用新创建的负载均衡器.

CloudFormation 资源在更新时无法稳定的最常见问题是由于引用的资源在 CloudFormation 堆栈外部被修改和/或删除。这会导致 CloudFormation 修改它无法再找到的资源,这可能会导致随机错误或超时,并且根据 AWS CloudFormation Best Practices 不鼓励这样做。 。如果是这种情况,最好的方法是尽可能使用全新的堆栈重新开始。

如果您的情况并非如此,则 LoadBalancerNames 的就地更新可能存在未知限制或问题。 AWS::AutoScaling::AutoScalingGroup 中的属性(仅支持 just added on Jan 17 2017 ,因此可能仍然存在问题)。尝试重新创建您的 Auto Scaling 组(更改模板中的 EcsInstanceAsg 资源的名称将导致重新创建它)并查看是否可以解决问题。

关于amazon-web-services - CloudFormation AutoscalingGroup "LoadBalancer attachments did not stabilize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42099898/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com