I am using shell script to get instance id and instance state on the basis of instance name. And for that I am using below query in shell script:
INSTANCE_NAME = "ABCDED00WEB"
INSTANCE_DETAIL=$(aws ec2 describe-instances \
--filters "Name=tag:Name,Values=$INSTANCE_NAME" "Name=instance-state-name,Values=running" \
--query "Reservations[*].Instances[*].[Tags[?Key=='Name'].Value[],InstanceId,State.Name]" \
--output text)
Can someone confirm is the above query correct to get instance id and state? Also, how I can check the variable "INSTANCE_DETAIL" null or not and if not null, then how to retrieve Instance Id and state separately from the output variable - INSTANCE_DETAIL