AWS CLI: Another Path to Services – Part 1
So, you have an Amazon Web Services Account and you are quite comfortable with using the services that AWS gives you. Great. But let us say, you want to be able to use these services on a larger scale. After all, it is not just that everything is available to you a click away. Some things may be hidden or may not be accessible easily. Not everything can be done through the browser.
Now, you did not think of this, did you?
At my workplace, we use AWS quite a bit and we are comfortable with it (as I pointed out earlier). In one of our projects, it was required that the developer have limited access to the Root AWS Account. A profile was created for the user and permissions were set up. The credentials were shared with the developer. To access it, the client requested us to use the AWS CLI. That’s when we started our association with AWS CLI.
So, what is this CLI, you might ask? What is its necessity?
Quite simply, AWS CLI is a Command Line Interface we can use to control multiple AWS services and automate them through scripts. CLI provides a good interface to access the AWS account without root access. It helps maintain data security as it is configured to a particular profile with restricted access and permissions.
Got you interested? Good.
Now what do you need to use CLI?
Step 1: Download the CLI Installer (MSI for Windows and a bundled installer or pip for Linux/Mac OS).
- Run the MSI to install on Windows. (Just follow the instructions).
Note: Python 2 version 2.6.5+ or Python 3 version 3.3+ before you can install on Linux or Mac OS.
- To install on Linux or Mac OS, follow these steps from the command line :
$ curl “https://s3.amazonaws.com/aws-cli/awscli-bundle.zip” -o “awscli-bundle.zip”
$ unzip awscli-bundle.zip
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
- Add the CLI directory to the PATH variable in Windows.
- Confirm the installation. Run the following command:
> aws –version
Step 2: Configure it.
- The easiest and quickest way to configure it in Windows is to us the following command.
> aws configure
- The aws configure will ask for 4 pieces of information. Your AWS Access Key ID, AWS Secret Access Key (these are your account credentials), the region and the output format. Now you can probably leave out the region and the output format as the default values but the AWS Access credentials are compulsory.
> aws configure
AWS Access Key ID [None]: XXXXXXXXXXXX
AWS Secret Access Key [None]: xxxxxXXXXX/XXXXXX/xxxxxxEXAMPLEKEY
Default region name [None]: xx-xxxx-1
Default output format [None]: json
That is it. Now you are configured to the AWS Account in Windows
- In Linux, add your Access Key ID and Secret Access Key to ~/.aws/config using this format :
aws_access_key_id = <access key id>
aws_secret_access_key = <secret access key>
region = us-east-1
- Protect the config file.
chmod 600 ~/.aws/config
You can also add it to the Environment variable if you want to keep it in a non-standard location.
Now you can access the Amazon Services through aws cli.
We will see how to access the Services in the next installment.