安装AWS CLI

姚文轩
2023-12-01

操作系统为Oracle Linux 7.6

  1. 安装python
sudo yum install python
  1. 安装 pip
sudo yum install python-setuptools
sudo yum install python-pip python-wheel
  1. 升级pip
sudo pip install --upgrade pip
  1. 安装aws cli
sudo pip install awscli
  1. 设置命令自动完成
complete -C aws_completer aws
  1. 配置aws cli

首先在Console中的IAM服务中创建Access Key。

[vagrant@sysops ~]$ aws config
configservice  configure
[vagrant@sysops ~]$ aws configure
AWS Access Key ID [None]: AKIAI......6HA
AWS Secret Access Key [None]: +cd+blGLWb0g8HuPLzRIMG0V0hjEHjb9iYhc4c7t
Default region name [None]:us-east-1
Default output format [None]:

  1. 测试
    确定用户有相应的权限。
[vagrant@sysops ~]$ aws ec2 describe-availability-zones
{
    "AvailabilityZones": [
        {
            "State": "available",
            "ZoneName": "us-east-1a",
            "Messages": [],
            "ZoneId": "use1-az6",
            "RegionName": "us-east-1"
        },
        {
            "State": "available",
            "ZoneName": "us-east-1b",
            "Messages": [],
            "ZoneId": "use1-az1",
            "RegionName": "us-east-1"
        },
        {
            "State": "available",
            "ZoneName": "us-east-1c",
            "Messages": [],
            "ZoneId": "use1-az2",
            "RegionName": "us-east-1"
        },
        {
            "State": "available",
            "ZoneName": "us-east-1d",
            "Messages": [],
            "ZoneId": "use1-az4",
            "RegionName": "us-east-1"
        },
        {
            "State": "available",
            "ZoneName": "us-east-1e",
            "Messages": [],
            "ZoneId": "use1-az3",
            "RegionName": "us-east-1"
        },
        {
            "State": "available",
            "ZoneName": "us-east-1f",
            "Messages": [],
            "ZoneId": "use1-az5",
            "RegionName": "us-east-1"
        }
    ]
}
[vagrant@sysops ~]$ aws ec2 describe-availability-zones --output text
AVAILABILITYZONES       us-east-1       available       use1-az6        us-east-1a
AVAILABILITYZONES       us-east-1       available       use1-az1        us-east-1b
AVAILABILITYZONES       us-east-1       available       use1-az2        us-east-1c
AVAILABILITYZONES       us-east-1       available       use1-az4        us-east-1d
AVAILABILITYZONES       us-east-1       available       use1-az3        us-east-1e
AVAILABILITYZONES       us-east-1       available       use1-az5        us-east-1f

参考:

  1. https://www.makeuseof.com/tag/install-pip-for-python/
  2. http://jmespath.org/tutorial.html
  3. https://github.com/aws/aws-cli
 类似资料: