Preparing to Use the Amazon Web Services Command Line Client


General AWScloud

I’m so impressed with the AWS services that I’m going to use them to create my own set of services for my personal domains. The plan is to introduce a few proof-of-concept services to show others both how to use AWS and how to have some fun with a couple i18n/g11n services as well.

Let’s get started. First thing, you’ll need an AWS account. It’s not difficult at all, and you can get a 12-month free trial. Yes, 12 months F-R-E-E! If you’re a hands-on engineer or dev ops person, you owe it to yourself to investigate this if you haven’t already.

If you’re new to AWS, you’ll spend your first hours browsing the console, creating server instances, etc. However, for anything beyond casual browsing, the AWS command-line client (AWS CLI) is critical. The AWS CLI helps you create resource templates that you can reuse over and over again in scripts. And we all know that creating a well-defined script is critical for creating anything in a reproducible, reliable, standard way. This article describes how to setup and use the AWS CLI. Your steps are these:

  1. Create a ‘deploy’ user.
  2. Create an access key for the ‘deploy’ user.
  3. Install and configure the AWS CLI.
  4. Test it out.

Creating a User

General user

Whether you use the CLI or an AWS SDK for Java, Ruby, or other language, you’ll run those scripts/programs using a set of secret access keys. You get those keys when you create users for your account. In the console, click on the Identity and Access Management (IAM) links. Create yourself a new user called “deploy”. You should use this user when creating or managing resources. Place that user in a administrative group or provide a policy that allows for creation of the resources you’ll need.

Creating an Access Key

Security Identity AWSIAM long termsecuritycredential

Once you have a “deploy” user, you’ll need to create an “Access Key” for it. Download it immediately at creation time. This is the only time you’ll be able to download it. This “key” has two parts: a key id, and a key secret. The command line client will need these, so store it away somewhere safe.

Installing the AWS CLI


You can install the CLI using a variety of options. Two easy options are the pip and Homebrew installers.

Use this to install with the Python pip installer:

pip install awscli

Or use Homebrew on a Mac:

brew install awscli

Once installed, you can use the following the create a default aws profile to use with your account. Remember that access key you created earlier? You’ll need that now. Run the following:

aws configure

This tool will ask you a few questions like this:

$ aws configure
AWS Access Key ID [None]: YOUR_KEY_ID_HERE
Default region name [None]: us-west-2
Default output format [None]: json

Copy and paste your access key id and secret key into the tool. This will create a couple files in the hidden ~/.aws directory. The AWS CLI will use these configuration files when accessing your account. You can find even more detailed information on the AWS CLI configuration website.

Confirming Your AWS Client Installation

Once you’ve installed and configured the CLI correctly, you should be able to work with your account resources immediately. Give it a try:

aws iam list-users

This should return at least two users from your account, including the recently created deploy user. The output looks like this:

    "Users": [
            "UserName": "deploy",
            "PasswordLastUsed": "2016-03-25T04:34:00Z",
            "CreateDate": "2016-03-07T00:51:35Z",
            "UserId": "ABCD1234ABCD1234",
            "Path": "/",
            "Arn": "arn:aws:iam::123412341234:user/deploy"
            "UserName": "jsoconner",
            "PasswordLastUsed": "2015-04-14T04:41:18Z",
            "CreateDate": "2015-04-11T07:21:45Z",
            "UserId": "ABCD1234ABCD1234",
            "Path": "/",
            "Arn": "arn:aws:iam::123412341234:user/jsoconner"

If you got this far and are still reading, you’re ready to do something even better with the AWS CLI. In the next article, we’ll create a complete stack of resources using Cloudformation.

Thanks for reading. If you enjoy this type of content, please provide feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *