---
title: "AWS CLI"
sidebar_label: "AWS CLI"
description: "How to configure AWS CLI for logs"
sidebar_position: 1
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import IssueS3Key from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/common/issue-s3-key.mdx'

# AWS CLI

[AWS CLI](https://aws.amazon.com/ru/cli/) (AWS Command Line Interface) is a command-line interface for working with AWS services that allows you to use Amazon CloudWatch API methods. For more details, see the [DescribeLogGroups](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogGroups.html), [DescribeLogStreams](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html), [GetLogEvents](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogEvents.html) and [FilterLogEvents](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_FilterLogEvents.html) articles in the AWS documentation.

You can use AWS CLI to work with logs: [get events](/logs/manage/get-logs.mdx#get-events), [event streams](/logs/manage/get-logs.mdx#get-list-of-event-streams), and [log groups](/logs/manage/get-logs.mdx#get-list-of-log-groups).

Before you begin, [configure AWS CLI](#configure-aws-cli).

## Configure AWS CLI \{#configure-aws-cli}

1. [Add a service user](#add-service-user).
2. [Issue an S3 key to the user](#issue-s3-key).
3. [Install the client](#install-client).
4. [Configure the AWS CLI settings](#configure-aws-cli).

### 1. Add a service user \{#add-service-user}

[Add a service user](/access-control/manage/add-user.mdx#add-service-user) with permission in the **Projects** access scope and the role:

* [`member`](/access-control/role-reference.mdx#member) or [`logs.admin`](/logs/manage-access.mdx#logs-admin) for read and write access to logs;
* [`logs.write`](/logs/manage-access.mdx#logs-writer) for write access to logs;
* [`reader`](/access-control/role-reference.mdx#reader) or [`logs.viewer`](/logs/manage-access.mdx#logs-viewer) for read-only access to logs.

[Account Owner](/access-control/user-types.mdx#account-owner) or users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin) role can add users.

### 2. Issue an S3 key to the user \{#issue-s3-key}

<IssueS3Key />

### 3. Install the client⁠​ \{#install-client}

Follow the [Install or update to the latest version of the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) guide in the Amazon documentation.

### 4. Configure AWS CLI settings⁠​ \{#configure-aws-cli}

1. Open the CLI.

2. Open configuration mode:

   ```
   aws configure
   ```

3. Enter `AWS Access Key ID` — the value of the **Access key** field from the S3 key you [issued to the user](#issue-s3-key), and press **Enter**.

4. Enter `AWS Secret Access Key` — the value of the **Secret key** field from the S3 key you [issued to the user](#issue-s3-key), and press **Enter**.

5. Enter `Default region name` — the [pool](/infrastructure/locations.mdx#pool) where your logs are located (e.g.,  `ru-9`), and press **Enter**.

6. Optional: enter `Default output format` or leave it blank and press **Enter**. If you do not specify a value, the default output format will be `json`.

7. Settings will be saved in the configuration files:

   * credentials in `.aws/credentials`;
   * pool in `~/.aws/config`.

8. In the `~/.aws/config` file, add the `endpoint_url` parameter after the `region`:

   ```bash
   [default]
   endpoint_url = <log_endpoint>
   ```

   Specify `<log_endpoint>` — the URL for accessing the Logs service API in the required pool. The list of URLs can be found in the [Logs](/api/urls/#logs) subsection of the [List of URLs](/api/urls/).

<Formbricks />
