Use the following command to get the list of only running instances with describe tags:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters Name=instance-state-name,Values=running --output text
Learn more about AWS by going through AWS course and master this trending technology.