Reputation: 11496
When navigating to the Auto Scaling Groups section of the EC2 Management Console, we can see information about the EC2 instances for each Auto Scaling Groups.
If you take a look at the image below:
How can I get the value of the field highlighted in green (Lifecycle
) using the Instance ID
via the AWS CLI?
I already tried the following command:
aws ec2 describe-instance-status --instance-ids <some instance ID>
But that does not provide me with the value in that field.
Upvotes: 1
Views: 706
Reputation: 8152
Try to use aws autoscaling describe-auto-scaling-instances
Usage:
aws autoscaling describe-auto-scaling-instances --instance-ids i-4ba0837f
Output:
{
"AutoScalingInstances": [
{
"ProtectedFromScaleIn": false,
"AvailabilityZone": "us-west-2c",
"InstanceId": "i-4ba0837f",
"AutoScalingGroupName": "my-auto-scaling-group",
"HealthStatus": "HEALTHY",
"LifecycleState": "InService",
"LaunchConfigurationName": "my-launch-config"
}
]
}
Bonus:
If you wanna get the LifecycleState value as a string, use the following command :
aws autoscaling describe-auto-scaling-instances --instance-ids INSTANCE_ID --query "AutoScalingInstances[].LifecycleState" --output text
Upvotes: 2