# Get EC2 Instance Id from within the EC2 requires two commands for the Metadata Service:
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`and
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-id
# View the Console of a Running EC2 instance
aws ec2 get-console-output --instance-id i-0598c7950e195e
# Get a Screenshot of a Running EC2 instance as JPG
aws ec2 get-console-screenshot --instance-id i-0598c7950e195e > i-0598c7940550e195e.jpg
# Start EC2 instances using their ids
aws ec2 start-instances --instance-ids i-0598c7950e195e
# Reboot EC2 instances using their ids
aws ec2 reboot-instances --instance-ids i-0598c7950e195e
# Stop EC2 instances using their ids
aws ec2 stop-instances --instance-ids i-0598c7950e195e
# Force Stop EC2 instances using their ids
aws ec2 stop-instances --instance-ids i-0598c7950e195e --force
Recent Comments