# 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 %}

![](https://3885248957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoE4wMO1dMVDOGDjh0En7%2Fuploads%2FGRXqu4oKl28LLdT3OhP9%2Fimage.png?alt=media\&token=cf4b2f2a-a1d1-418d-9d55-715986632d9f)

### 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>
```
