[Amazon] Installation and uninstallation of AWS CLI operation process (Windows, Linux systems)


The AWS Command Line Interface (AWS CLI) is a unified tool for managing AWS products. By simply downloading and configuring a tool, you can use the command line to control multiple AWS products and leverage scripts to automate these services.

AWS CLI v2 provides several new features, including an improved installer, new configuration options such as AWS IAM Identity Center (the successor to AWS SSO), and a variety of interactive features.

Insert image description here


1. AWS CLI authorization settings (Credentail file settings)

Log in to the AWS console and perform AWS CLI authorization settings. The steps are as follows:

  • Create an IAM user and create an access key
  • Authorization CLI identity
  1. Create an IAM user and create an access key.

image-20231119105454614

  1. Set access permissions for this user.

image-20231119105650343

  1. In Security Credentials, select Create访问密钥.

image-20231119105543755

  1. Save the access key locally.

image-20231119110015110
At this point, the user's AKSK is created and the AWS CLI installation begins in Linux and Windows environments.

2. Install AWS CLI operation process

2.1 Linux environment

Demo environment - based on Rocky Linux 9.2 system

$ sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

$ sudo unzip awscliv2.zip

$ sudo sudo ./aws/install

$ sudo aws --version

$ sudo aws configure

配置信息如下
aws_access_key_id = AKIAXxxxxxxxxx3GB
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ap-northeast-1
us-west-2
json

参考链接:https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/getting-started-install.html

Demonstration environment - based on openEuler 22.03 LTS system

[root@openEuler ~]# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"

[root@openEuler ~]# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 56.4M  100 56.4M    0     0  5165k      0  0:00:11  0:00:11 --:--:-- 5952k

[root@openEuler ~]# ll
总用量 57M
-rw-------. 1 root root 1.5K 1110 16:05 anaconda-ks.cfg
drwxr-xr-x. 3 root root 4.0K 118 20:33 aws
-rw-r--r--. 1 root root  57M 1110 16:16 awscliv2.zip


[root@openEuler ~]# sudo ./aws/install
You can now run: /usr/local/bin/aws --version

[root@openEuler ~]# aws configure
AWS Access Key ID [None]: AKIAXxxxxxxxxx3GB
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json

[root@openEuler ~]# aws s3 ls
2023-10-30 09:41:03 xybaws-account-access-s3
2023-10-30 16:16:47 xybaws-web
2023-09-20 23:32:16 xybawsbucket
2023-11-01 11:07:25 xybdiyaws-s3-web
2023-11-01 10:02:41 xybdiyaws-web-s3

2.2 Windows environment

Windows版本安装:

Download link:https://awscli.amazonaws.com/AWSCLIV2.msi

image-20230504094239787
image-20230504094249861
image-20230504094258380
image-20230504094304554
image-20230504094325902
image-20230504094505745

Authorize CLI identity (specify profile method—AWS Best Practices)

C:\Users\xyb>aws configure --profile xybaws-cli
AWS Access Key ID [None]: AKIAXxxxxxxxxx3GB
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json

Test whether you can access data resources on AWS.aws configure list --profile xybaws-cli

# 列出所有配置数据
C:\Users\xyb>aws configure list --profile xybaws-cli
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile               xybaws-cli           manual    --profile
access_key     ****************R3GB shared-credentials-file
secret_key     ****************j5tT shared-credentials-file
    region           ap-northeast-1      config-file    ~/.aws/config

3. Uninstall AWS CLI operation process

## 找到符号链接和安装路径
# which aws

# ls -l /usr/local/bin/aws

## 删除 --bin-dir 目录中的两个符号链接。
# rm /usr/local/b
# rm /usr/local/bin/aws_completerin/aws

## 删除 --install-dir 目录。
# rm -rf /usr/local/aws-cli

## 删除 .aws 文件夹中的共享 AWS SDK 和 AWS CLI 设置信息。
# sudo rm -rf ~/.aws/

参考链接:https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/uninstall.html

4. Reference links

[1] Install or update the latest version of the AWS CLI - AWS Command Line Interface (amazon.com)

[2] Uninstall AWS CLI version 2 - AWS Command Line Interface (amazon.com)

Guess you like

Origin blog.csdn.net/qq_45392321/article/details/134488239