官术网_书友最值得收藏!

  • Amazon EC2 Cookbook
  • Sekhar Reddy Aurobindo Sarkar
  • 727字
  • 2021-07-30 10:14:15

Preparing AWS CLI tools

AWS CLI is a set of unified command-line tools to work with multiple AWS services. Using AWS CLI tools you can manage EC2 resources (such as instances, security groups, and volumes) and your VPC resources (such as VPCs, subnets, route tables, and Internet gateways).

How to do it…

In the following two sections, we list the set of instructions required to accomplish this on Linux and Windows/Mac platforms.

Getting access key ID and secret access key

You need AWS access key ID and AWS secret access key to access AWS services. Instead of generating these credentials from the root account, it's always best practice to use IAM users. You should save these credentials in a secure location. If you lose these keys, you must delete the access key and then create a new key.

You can get the AWS credentials from AWS management portal by following these steps:

  1. Log in to the AWS management portal using your AWS username and password.
  2. Select account name from top menu at the right corner in the console.
  3. Select security credentials.
  4. Click on access keys (access key ID and secret access key).
  5. Click on the Create New Access Key button.
  6. Click on Download Key File, which will download the file. If you do not download the key file now, you will not be able to retrieve your secret access key again.
  7. Copy this key file to a secure location.

    Note

    Don't upload your code base with AWS security credentials to public code repositories such as GitHub. Attackers are scraping GitHub for AWS credentials. If anyone gets access to these credentials, they can misuse your AWS account.

Installing AWS CLI using pip in Linux

We can use the pip tool to install the Python packages.

  1. Before installing Python, please check whether Python is already installed on your machine or not using the following command. If Python is already installed on your machine, then skip to the pip installation step.
    $ python --help
    
  2. Start by installing Python. Download the compressed TAR archive file from the Python site, and then install it using the commands listed below. The following steps target the apt-based Linux distributions:
    $ sudo apt-get install gcc
    $ wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
    $ tar -zxvf Python-2.7.8.tgz
    $ cd Python-2.7.8
    $ ./configure
    $ make
    $ sudo make install
    
  3. Next, check the Python installation:
    $ python –help
    
  4. Before installing pip, please check whether pip is already installed on your machine or not by using the following command. If pip is already installed on your machine, then skip to the awscli installation step:
    $ pip –help
    
  5. Move on to installing pip:
    $ sudo apt-get install pip
    
  6. Then install AWS CLI. If you have already installed awscli, you can upgrade the installation using the –upgrade option.
    $ sudo pip install awscli
    
  7. Next, configure AWS CLI.

    On the command prompt, type the following command, which will prompt for the AWSAccessKey ID, AWSSecretKey, default AWS region, and default output format.

    $ sudo aws configure
    
  8. Finally, check the installation by getting regions list:
    $ sudo aws ec2 describe-regions
    

Installing AWS CLI using pip in Windows/Mac

We can use the pip tool to install the Python packages.

  1. Before installing Python, please check whether Python is already installed on your machine or not by using the following command. If Python is already installed on your machine, then skip to the pip installation step.
    $ python –help
    
  2. Start by installing Python. Download the installer from the following URL and install Python by using that installer: https://www.python.org/downloads/.
  3. Check your Python installation:
    $ python –help
    
  4. Before installing pip, check whether pip is already installed on your machine or not by using the following command. If pip is already installed on your machine, skip to the awscli installation step.
    $ pip –help
    
  5. In the next step, we install pip. Download and run the installation script from https://bootstrap.pypa.io/get-pip.py. After that, run the following command:
    $ python get-pip.py
    
  6. Install AWS CLI. If you have already installed awscli, you can upgrade the installation using the –upgrade option.
    $ pip install awscli
    
  7. Next, we configure AWS CLI. Execute the following command from the command prompt.
    $ aws configure
    

    This command will then prompt you for the AWSAccessKey ID, AWSSecretKey, default AWS region, and default output format.

  8. Check the installation by getting the regions list:
    $ aws ec2 describe-regions
    
主站蜘蛛池模板: 稷山县| 霸州市| 互助| 临桂县| 龙海市| 五莲县| 广州市| 大渡口区| 沭阳县| 成安县| 鹤庆县| 龙泉市| 读书| 武冈市| 桃园市| 新建县| 稻城县| 宁陕县| 呼伦贝尔市| 景洪市| 海盐县| 江山市| 太和县| 双鸭山市| 武胜县| 榆林市| 岳池县| 金川县| 梁平县| 英德市| 阆中市| 凤凰县| 武陟县| 浠水县| 通渭县| 丁青县| 新乡市| 岫岩| 沾益县| 开阳县| 龙南县|