AWS Command Line Interface
User Guide (Version 0.4.4)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

Getting Started with the AWS Command Line Interface

This section explains how to specify which credentials and region the AWS Command Line Interface should use when interacting with AWS. Following the setup instructions is a list of the AWS services supported by the CLI.

Specify Your AWS Credentials

Before using AWS CLI, you first need to specify your AWS account credentials in order to use any AWS command that connects to a service. To specify your credentials choose one of the following three options:

  • Set the AWS_CONFIG_FILE environment variable to point to a configuration file containing your credentials.

  • Configure the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables with your credentials.

  • Create an IAM role. This is the recommended option when using AWS CLI on an Amazon EC2 instance.

Set the AWS_CONFIG_FILE Environment Variable

Use the environment variable AWS_CONFIG_FILE to point to the configuration file that contains your AWS access and secret keys. For example, the name of the environment variable must be AWS_CONFIG_FILE, and the value for the variable must point to the location of your credential file, such as ~/myconfigfile.txt or C:\Config\MyConfigFile.txt.

Important

It is recommended to set the file permissions of the config file to read-only for the current user.

The following example shows the syntax of the configuration file for the default profile containing access and secret keys for AWS.

[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Configure the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY Environment Variables

Configure the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with your key values. The following example shows the syntax.

AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
      

Create an IAM role

For overview information about IAM roles, see Roles. For information about creating IAM roles, see Creating a Role

Set the AWS Region

You must specify an AWS region when using AWS CLI. You set the desired region by either configuring the region setting in your default profile for the environment variable AWS_CONFIG_FILE, such as:

[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
region = us-west-2

Or, by using the --region option with an AWS CLI command, such as:

aws --region us-west-2 sqs list-queues

This example first sets the region to us-west-2 and then lists the Amazon SQS queues for that region.

Test the Setup

To ensure that everything is set up correctly, test the installation by issuing a common AWS command, aws help:

aws help

If the test is successful, you will see the help displayed on your terminal.

You can see the help for each of the supported services by adding the service name between aws and help. For example, to see the help for Amazon EC2 type:

aws ec2 help

Supported Services

For a list of the available services you can use with AWS Command Line Interface, see Supported Services.