AWS Cloud Services and AWS CLI

  1. Home
  2. AWS Cloud Services and AWS CLI

Introduction to AWS Cloud Services

For becoming a qualified candidate for the AWS Certified SysOps Administrator – Associate certification, it is not suggested ti just read the guide — it is important to dig deep and get into the depth of computing.

Systems Operations Using the AWS Toolset

Several AWS-provided tools are available for customers to create, maintain, and delete AWS resources at the command line or in code such as –

  • AWS Command Line Interface (AWS CLI)
  • AWS Tools for PowerShell
  • AWS Software Development Kits (SDKs).
  •  

Process of Installing AWS Command Line Interface (CLI)

In order to find instructions on how to install the latest version of the AWS CLI, navigate to http://aws.amazon.com/cli in a web browser. Also for windows, we will download and install the 32-bit or 64-bit installer that is appropriate for the computer. In case of using Mac or Linux and have Python and pip installed, installing the latest version of the AWS CLI is as simple as running pip install awscli.

Upgrading the AWS CLI

The process of upgrading the AWS CLI on a Linux or Mac computer is very simple as it involves running pip install – upgrade awscli . Now, for Windows users, we would have to download the latest installer and install the latest version.

Configuration

Post installing the AWS CLI, run aws configure to configure it with credentials. Specifically, we would need an access key and secret key created for AWS Identity and Access Management (IAM) user. Also, we can set a region (for instance like, us-east-1 ) and a default output format (for instance, JSON) after entering the access key and secret key.

We will now consider the AWS configure Command Options

We also can also create multiple profiles by appending –profile profile-name to the aws configure command.

Environment Variables

We can use environment variables to specify configuration parameters , as listed in the table below. These variables gives the ability that comes in handy for making swift changes in scripts or on a temporary basis from the command line.

Getting Help on the AWS CLI

We can also add the option of help to the end of nearly every AWS CLI command to determine a list of available options. For instance, executing AWS help returns a list of all of the services available to use as options. Running AWS S3 help will return a list of the valid parameters to pass as part of a command-line call to Amazon Simple Storage Service (Amazon S3).

  • Autocompletion We can enable autocompletion for the bash shell (Linux or Mac) by typing complete -C aws_completer aws.
  • Source Code – Also AWS makes the command line interface source code available within the terms of the Apache License, Version 2.0. Such that there is an active community involved with the source code in which we are encouraged to participate.
  • Working with Services – Now executing an AWS CLI command is as simple as typing aws and then a command string followed by a list of options. Such that the format of the command will generally take the form of the following

aws service parameter1 parameter2 … parameterN

AWS CLI Output Types

Now in the Configuration section, we can represent the data retrieved using the AWS CLI in three output formats namely “JSON,” “text,” or “table.” Such that each format can provide a number of benefits to the user depending on the use case in question.

JSON

JSON is the default format, as it provides data in a form that is easily parsed and ingested by applications. This format is commonly used in other AWS Cloud services and it is a standard in which operations personnel should become well versed if they want to excel.

  • Avoiding Unwieldy Lines – There are several strategies to deal with this problem. At first, in Linux or Mac, we can use the backslash character to separate a command into several lines. For instance, this command –

aws rds download-db-log-file-portion –db-instance-identifier awstest1

–log-file-name “error/postgres.log”

Above command is similar to the following command, parsed with backslashes –

aws rds \

download-db-log-file-portion \

–db-instance-identifier awstest1 \

–log-file-name “error/postgres.log”

  • Also, using backslashes makes the command more easily comprehensible to a human reader, thereby assisting with troubleshooting when errors occur.
  • Next, some AWS CLI commands take a JSON-formatted string as part of the input.

For instance,the aws ec2 create-security-group command has a parameter –cli-input-json that takes a JSON-formatted string as an input. As an alternative to

Note that for entering the string through the command line, we can refer to a local file as follows –

aws ec2 create-security-group –cli-input-json file://filename.json

where filename.json is the file containing the JSON string.

In addition, we can store the JSON string as an object in Amazon S3 or another web hosted location and access the file as a URL –

aws ec2 create-security-group \

–cli-input-json \

This gives us the ability to reuse more easily the JSON string that you’ve created for one environment in another.

Using query to Filter Results

As we use the AWS CLI, we find that there is a alot of information about the AWS environment which can be retrieved using the tool. Command-line output is comprehensive. Running the command aws ec2 describe-instances returns dozens of values describing each instance running such as – InstanceId, PublicDnsName, PrivateDnsName, InstanceType, and much more.

Using AWS Tools for Windows PowerShell

So far we have been focusing on the AWS CLI tool in the discussion of how a systems operator can effectively administer a customer’s cloud resources from the command line. As this tool works across operating systems, the AWS CLI provides an effective way to administer across various shells.

Menu