Amazon web services 有没有办法确定EC2实例是否与自动缩放组关联
是否有办法确定EC2实例是否与自动缩放组关联?您可以使用该功能检查实例连接到哪个自动缩放组 因此,例如,对于实例idAmazon web services 有没有办法确定EC2实例是否与自动缩放组关联,amazon-web-services,amazon-ec2,Amazon Web Services,Amazon Ec2,是否有办法确定EC2实例是否与自动缩放组关联?您可以使用该功能检查实例连接到哪个自动缩放组 因此,例如,对于实例idi-4ba0837f,您可以运行以下命令 aws autoscaling describe-auto-scaling-instances --instance-ids i-4ba0837f 下面是附加到自动缩放组的响应示例 { "AutoScalingInstances": [ { "Protected
i-4ba0837f
,您可以运行以下命令
aws autoscaling describe-auto-scaling-instances --instance-ids i-4ba0837f
下面是附加到自动缩放组的响应示例
{
"AutoScalingInstances": [
{
"ProtectedFromScaleIn": false,
"AvailabilityZone": "us-west-2c",
"InstanceId": "i-4ba0837f",
"AutoScalingGroupName": "my-auto-scaling-group",
"HealthStatus": "HEALTHY",
"LifecycleState": "InService",
"LaunchConfigurationName": "my-launch-config"
}
]
}
但是,如果未附加到任何列表,则该列表将为空
{
"AutoScalingInstances": []
}
如果此操作未返回任何结果,则该实例不属于自动缩放组
这也将在SDK中提供:
{
"AutoScalingInstances": [
{
"InstanceId": "some-instance-id",
"InstanceType": "m4.large",
"AutoScalingGroupName": "awseb-some-name",
"AvailabilityZone": "eu-west-1c",
"LifecycleState": "InService",
"HealthStatus": "HEALTHY",
"LaunchTemplate": {
"LaunchTemplateId": "lt-04a2fffdesa",
"LaunchTemplateName": "AWSEBEC2LaunchTemplate_foobar",
"Version": "2"
},
"ProtectedFromScaleIn": false
}
]
}
如果不是
{
"AutoScalingInstances": []
}
您可以使用以下aws cli命令:
aws autoscaling describe-auto-scaling-instances --instance-ids i-exampleid
如果实例是自动缩放组的一部分,结果将为您提供详细信息
您还可以查看实例标记以确定它是否属于ASG。ASG中的EC2将始终具有
aws:autoscaling:groupName
标记
aws autoscaling describe-auto-scaling-instances --instance-ids i-exampleid