Lab 3‐2 ‐ AWS EC2 with CLI ‐ Part 02 - Isaiah-River/SYS-360 GitHub Wiki

Navigation

Overview

In this lab, I got more experience working with AWS CLI, this lab focusing on filtering for specific information from the describe-instances command. I also worked to set up a remote desktop connection into my Windows VM.

Objectives

  • Filtering and querying with the describe-instances command
  • Setting up a remote desktop connection into an EC2 instance

Completing the lab

Part 01 - Launch Instances from CLI

To start this lab I first had to ensure I had my session token updated as noted in last lab. With this done I went into the web console to get the AMI ID for both Windows (ami-04f77c9cd94746b09) and Linux (ami-0c614dee691cbbf37) instances. I then ran the following commands to launch these two instances

# Launch a Windows instance
aws ec2 run-instances --image-id ami-04f77c9cd94746b09 --count 1 --instance-type t3.micro --key-name iriver-cc --security-groups IRiver-DefaultCC --region us-east-1

# Launch a Linux instance
aws ec2 run-instances --image-id ami-0c614dee691cbbf37 --count 1 --instance-type t2.micro --key-name iriver-cc --security-groups IRiver-DefaultCC --region us-east-1


# Show running instances information
aws ec2 describe-instances

Part 02 - Query specific information on Instances from CLI

In this next part we worked with some options for the aws ec2 describe-instances command to start to familiarize ourselves with parsing for various information. To do this I ran the following commands:

# Pull only the instance ID of running instances
aws ec2 describe-instances --query 'instance-id' --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].InstanceId'

# Only pull the Public IP address of running instances
aws ec2 describe-instances --query 'instance-id' --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].PublicIpAddress'

# Only pull the public IP address of instances running Windows.
aws ec2 describe-instances --query 'instance-id' --filters "Name=instance-state-name,Values=running" "Name=platform,Values=windows" --query 'Reservations[*].Instances[*].PublicIpAddress'

I took a screenshot of these for my first three deliverables:

{F298401F-9780-43C3-8B56-127C6D7619EA}

Part 03 - Use RDP to Connect to your Windows Instance

Next up I went to use remote desktop protocol to remotely access my Windows instance. To do this I opened the Amazon EC2 console, then in the navigation pane, choose I chose "Instances". I selected my Windows instance, and then "Connect". Underneath the RDP tab, I ensured I was using the default Administrator account, and then I selected "Get Password". Here I uploaded my private key I downloaded from last lab:

{B8BDB341-2D9F-4DDC-BB7B-DB95A352701C}

I then chose "Decrypt password" which then provided a password for my account which I copied and saved, and I then downloaded the remote desktop profile. I then launched Remote Desktop Connection, and selected more options, and chose "Open" navigating to my RDP profile I just downloaded. This gave me an issue at first saying that it was not able to connect. After this I went to my security group and added RDP from anywhere to the inbound rules. This prompted me for my credentials, and I provided the password I created earlier. I took a screenshot of my remote connection in for my fourth deliverable:

{80824631-EEB9-409F-8949-CD5F1DAAC555}

Part 04 - Terminating EC2 Instances

For this last part I just had to terminate my EC2 instances. To do this I ran the following commands:

# Terminate instances
aws ec2 terminate-instances --instance-ids i-07c43da8eea611352
aws ec2 terminate-instances --instance-ids i-0b300a5cca8f7ffcd

I went back into my console and refreshed to see the instances shutting down. After these finished terminating, I took a screenshot for my final deliverable:

{06049223-00B3-4ACD-BA22-2B67E7937A5E}

Deliverables

My submission for this lab can be viewed here.

Deliverable 01 - Use the describe-instances command to just output the instance-ids of running instances

This screenshot shows me running the aws ec2 describe-instances command but I am just filtering for the instance IDs of running instances.

image

Deliverable 02 - Use the describe-instances command to just output the instance-ids and public IP address of running instances

This screenshot shows me running the aws ec2 describe-instances command but I am just filtering for the public IPs of running instances.

image

Deliverable 03 - Use the describe-instances command to just output the instance-ids and public IP address of only Windows running instances

This screenshot shows me running the aws ec2 describe-instances command but I am just filtering for the public IPs of running Windows instances.

image

Deliverable 04 - Screenshot of successful connection to instance via RDP

This screenshot shows my successful remote desktop into my WIndows instance.

image

Deliverable 05 - Screenshot showing that the instances are terminated

This screenshot shows my two instances terminating after running the aws ec2 terminate-instances commands on their instance IDs.

image