> For the complete documentation index, see [llms.txt](https://paul-gleason.gitbook.io/champlain-college-classes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paul-gleason.gitbook.io/champlain-college-classes/sys-360-cloud-admin/labs/lab-3-1-aws-with-cli.md).

# Lab 3-1: AWS with CLI

### **Step 1 - Install AWS CLI**

For this (and future) labs, you will need to AWS CLI (Command Line Interface) tools installed.

1. Follow the steps to install AWS CLI version 2 for your appropriate OS at: [https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.htmlLinks to an external site.](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
2. Run "aws --version" to verify installation
3. **Submit screenshot of aws --version output**

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2F4XiqGj1gK7Tm5iTu3ID8%2Fimage.png?alt=media&amp;token=97df49df-94a3-41ee-b540-693c10d8fa70" alt=""><figcaption></figcaption></figure>

### Step 2 - Get Creds / Configure AWS CLI

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2F9qiT3D3xHPDhms6LpByT%2Fimage.png?alt=media&amp;token=d49e1091-eaf7-4a1a-b6b8-da37f40a3d1e" alt=""><figcaption></figcaption></figure>

Then - AWS CLI - Show. After you get this information copy and paste the following into \~/.aws/credentials. Add the line below to the file as well

```
region = us-east-1
```

### **Step 3 - Launch an AWS Instance**

{% code overflow="wrap" %}

```
aws ec2 run-instances --image-id ami-0a3c3a20c09d6f377 --count 1 --instance-type t2.micro --key-name Paul-360 --security-groups Paul-SG-360 --region us-east-1
```

{% endcode %}

**--image-id = Amazon Linux ID**

**--key-name = Name of ssh key**

**--security-groups = Name of security group**

**--region = region you want the instance to be deployed**

1. **Submit Screenshot showing that the Instance was started (Instance ID and Launch Time included)**

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2FLwLpLcakBSYqaFXCZlYd%2Fimage.png?alt=media&amp;token=e9bb8f52-9428-486a-ab45-357b2d61d430" alt=""><figcaption></figcaption></figure>

### **Step 4 - Connect to Instance**

**To view instances**

```
aws ec2 describe-instances
```

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2FLpj5yWwr3WAhlMsPS8IA%2Fimage.png?alt=media&amp;token=5f0cad75-360c-4717-8bc5-e2995d1fc8bc" alt=""><figcaption></figcaption></figure>

Get IP or DNS from decribes and now.

```
ssh -i Paul-360.pem ec2-user@3.95.158.84
```

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2F7fkFGP4BrwxjYEiT6mDJ%2Fimage.png?alt=media&amp;token=276468bc-322a-4147-8a9e-d4979b09de97" alt=""><figcaption></figcaption></figure>

### **Step 5 - Terminate Your Instance**

**Take not of the "instance-id" in the describe.**

```
aws ec2 terminate-instances --instance-ids i-0cc56f2564da3e902
```

**Submit - from the AWS Console - EC2 - Instances - Screenshot showing the terminated instance (you may need to refresh if it still shows running)**

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2F8kxDg4OLh6B1sUejrUqT%2Fimage.png?alt=media&amp;token=f573b0a9-925b-4bbf-8075-6713cb09d261" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1702353884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg4BXXN6DhMLmwASC6sFj%2Fuploads%2FiitBIP0B3ILNmQ6uIcT1%2Fimage.png?alt=media&amp;token=c0c5997d-17cb-4724-95c0-afb0baae176b" alt=""><figcaption></figcaption></figure>
