# AWS CLI Cheatsheet

### AWSCLI

#### How to install:

```bash
# Arch Linux:
sudo pacman -S awscli

# Redhat based or Debian based:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
```

#### Or install via PIP

```bash
pip3 install awscli --upgrade --user
```

#### Resources:

* [Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

#### How to remove:

```bash
sudo rm -rf /usr/local/aws
sudo rm /usr/local/bin/aws
```

#### Check awscli version:

```bash
aws --version
```

### Configure cloud access

```bash
aws configure
```

* Add key
* Add Secret Key
* Add Region
* Add Format

{% hint style="info" %}
The above values can be obtained by using programmatic access (Access keys) via IAM Service
{% endhint %}

![](/files/6SSeNyr5EvifgPqfDSJZ)

### S3 commands

#### How to check Total S3 bucket size:

```bash
aws s3 ls --summarize --human-readable --recursive <BUCKET_NAME> | grep "Total Size"
```

### Lightsail commands

#### Restart Instance:

```bash
aws lightsail reboot-instance --instance-name <insance_name>
```

#### Stop Instance:

```bash
aws lightsail stop-instance --instance-name <insance_name>
```

#### Start Instance:

```bash
aws lightsail start-instance --instance-name <insance_name>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/cloud/aws/aws-cli-cheatsheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
