AWS CLI
AWS CLI (AWS Command Line Interface) is a command-line interface for working with AWS services that allows you to use Amazon CloudWatch API methods. Learn more in the DescribeLogGroups, DescribeLogStreams, GetLogEvents, and FilterLogEvents articles in the AWS documentation.
You can use AWS CLI to work with logs: get events, event streams, and log groups.
Before you begin, configure AWS CLI.
Configure AWS CLI
- Add a service user.
- Issue an S3 key to the user.
- Install the client.
- Configure the AWS CLI settings.
1. Add a service user
Add a service user with permission in the Projects access scope and the role:
memberorlogs.adminfor read and write access to logs;logs.writefor write access to logs;readerorlogs.viewerfor read-only access to logs.
Account Owner or users with the iam.admin role can add users.
2. Issue an S3 key to the user
Users with access to the control panel can issue S3 keys for themselves, but we recommend creating service users and issuing S3 keys to them.
Only the Account Owner or a user with the iam.admin role can issue S3 keys to other users. A service user cannot get an S3 key independently because they do not have access to the control panel — the Account Owner or iam.admin.
You must create a separate key for each project. You can issue multiple keys for one project.
-
In the control panel, click IAM.
-
Go to the section for the required user type:
- Users — for users with access to the control panel;
- Service users — for service users.
-
Open the user page → in the Access tab.
-
In the S3 keys block, click Add key.
-
Enter a key name.
-
Select a project for which the key will work.
-
Click Generate. Two values will be generated:
- Access key — Access Key ID, a key identifier;
- Secret key — Secret Access Key, a secret key.
-
Click Copy and save the key — you will not be able to view it after closing the window.
3. Install the client
Follow the Install or update to the latest version of the AWS CLI guide in the Amazon documentation.
4. Configure AWS CLI settings
-
Open the CLI.
-
Open configuration mode:
aws configure -
Enter
AWS Access Key ID— the value of the Access key field from the S3 key you issued to the user, and press Enter. -
Enter
AWS Secret Access Key— the value of the Secret key field from the S3 key you issued to the user, and press Enter. -
Enter
Default region name— the pool where your logs are located (e.g.,ru-9), and press Enter. -
Optional: enter
Default output formator leave it blank and press Enter. If you do not specify a value, the default output format will bejson. -
Settings will be saved in the configuration files:
- credentials in
.aws/credentials; - pool in
~/.aws/config.
- credentials in
-
In the
~/.aws/configfile, add theendpoint_urlparameter after theregion:[default]endpoint_url = <log_endpoint>Specify
<log_endpoint>— the URL to access the Logs service API in the required pool. The list of URLs can be found in the URL Lists guide