concept CLI in category aws

appears as: CLI, CLI, The CLI
Amazon Web Services in Action, Second Edition

This is an excerpt from Manning's book Amazon Web Services in Action, Second Edition.

Figure 1.14. The CLI allows you to manage and access AWS services from your terminal.

The command-line interface (CLI) allows you to manage and access AWS services within your terminal. Because you can use your terminal to automate or semi-automate recurring tasks, CLI is a valuable tool. You can use the terminal to create new cloud infrastructures based on blueprints, upload files to the object store, or get the details of your infrastructure’s networking configuration regularly. Figure 1.14 shows the CLI in action.

Figure 1.14. The CLI allows you to manage and access AWS services from your terminal.

If you want to automate parts of your infrastructure with the help of a continuous integration server, like Jenkins, the CLI is the right tool for the job. The CLI offers a convenient way to access the API and combine multiple calls into a script.

You can even begin to automate your infrastructure with scripts by chaining multiple CLI calls together. The CLI is available for Windows, Mac, and Linux, and there is also a PowerShell version available.

Now that you know how important dependencies are to infrastructure as code, let’s see how you can use the terminal to create infrastructure. The CLI is one tool for implementing infrastructure as code.

It’s time to test whether the CLI works. Switch to the terminal window, and enter aws ec2 describe-regions to get a list of all available regions:

$ aws ec2 describe-regions
{
  "Regions": [
    {
      "Endpoint": "ec2.eu-central-1.amazonaws.com",
      "RegionName": "eu-central-1"
    },
    {
      "Endpoint": "ec2.sa-east-1.amazonaws.com",
      "RegionName": "sa-east-1"
    },
    [...]
    {
      "Endpoint": "ec2.ap-southeast-2.amazonaws.com",
      "RegionName": "ap-southeast-2"
    },
    {
      "Endpoint": "ec2.ap-southeast-1.amazonaws.com",
      "RegionName": "ap-southeast-1"
    }
  ]
}

It works! You can now begin to use the CLI.

4.2.2. Installing the CLI

How you proceed depends on your OS. If you’re having difficulty installing the CLI, consult http://mng.bz/N8L6 for a detailed description of many installation options.

Learn Amazon Web Services in a Month of Lunches

This is an excerpt from Manning's book Learn Amazon Web Services in a Month of Lunches.

The AWS command-line interface (CLI) is a powerful program that effectively lets you remotely control all of your AWS resources from the command line of any internet-connected computer. We’ll spend a lot more time on the CLI in chapter 12. For now, though, you’ll do just enough to get it running for this example.

Why install the CLI now? Because that’s the tool you’ll use to upload your backup archive to the S3 bucket you’re about to create. Technically, you could also upload files to buckets from the S3 browser dashboard, but that’s not an effective or efficient way to manage an ongoing backup operation.

You can download and install the CLI onto just about any Windows, macOS, or Linux computer running an up-to-date version of Python. You’re probably fine in the Python department, but just to make sure, check the version you’re running by typing python --version in your terminal:

  • Although, in the long run, the CLI will probably become your best friend, getting to know it can be complicated at first. So I thought it would be best to leave it until you’re comfortable with the basics.
  • 12.6. Using the CLI to administer your AWS account resources

    Let’s try performing a few real tasks through the CLI. aws s3 ls lists all the S3 buckets in your account (S3 is a global service, so buckets aren’t limited to a single region):