Lab 3‐2: AWS EC2 with AWS CLI - seabar24/SYS-360 GitHub Wiki

EC2 Describe-Instance Querying

Windows Server 2022 AMI ID: ami-00d990e7e5ece7974

Ubuntu Server 22.04 LTS AMI ID: ami-0c7217cdde317cfec

Useful source for querying in AWS CLI: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html

Command for only showing running instances:

aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId}" --filters "Name=instance-state-code,Values=16" --output text

Output:

image

Command for instance ids of public IP Addresses of running instances:

aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId, PublicIP:PublicIpAddress}" --filters "Name=instance-state-code,Values=16" --output text

Output:

image

This one is just for fun and found on accident Command for only printing out Public IP Addresses of running instances:

aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId}" --query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress}" --filters "Name=instance-state-code,Values=16" --output text

Command that only shows instance ids and public ip addresses of windows instances:

aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId, PublicIP:PublicIpAddress}" --filters "Name=instance-state-code,Values=16" "Name=platform,Values=windows" --output text

Output:

image

RDP to Windows

Source used: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html

Make sure when copying the password, it’s the same length as the actual password. Seems like it was copying the password multiple times.

image