Accessing AWS services using command line interface on Windows.

Sumit
Tensult Blogs
Published in
4 min readDec 7, 2018

This blog has moved from Medium to blogs.tensult.com. All the latest content is available there. Subscribe to our newsletter to stay updated.

We all know how to access our AWS management console using our favourite browser, be it Chrome or Safari, and then work on the various services offered by Amazon Web Services. Once we are logged into the management console, we get a web-based GUI similar to the below image.

Management Console

There is an alternative way to access all these amazing services and that is what we are about to discuss in this article. Programmers, developers, and people who work extensively on Linux machines agree upon one thing: working on command line interface(CLI) is a faster and easier way to perform tasks, and that is exactly the method we have to access our AWS services. We have a command line interface(CLI) tool which can be downloaded and installed on the local system and can be used to access the AWS services and even automate many scripts.

Let us first discuss how to download and install this CLI tool on our Windows system.

Steps:

  1. Search ‘AWS Command Line Interface’ on the AWS management console and you will reach this page.
Command Line Interface

2. Click on the download link as per your system configuration.

Download link highlighted

3. Once the download is finished, you should have a .msi file in your downloads folder with the name AWSCLI64PY3.msi. If Google Chrome doesn’t allow to save the downloaded file, you can use the download link in IE and do the same.

4. Run the installer from your Downloads folder.

Installation Step 1
Installation Step 2
Installation Step 3
Installation Step 4

5. Once the installation is completed, open Command Prompt from your Start Menu.

6. Since the installation is completed, let’s run a basic aws command on Command Prompt.

command to check the version

The command result in the above reference shows that we are able to access aws using command prompt.

7. Now, to access particular AWS services like EC2 and S3, we need to login to AWS using command prompt. For that, we can use ‘SET’ command.

SET AWS_ACCESS_KEY=”access key”
SET AWS_SECRET_ACCESS_KEY=”secret access key”
SET AWS_SESSION_TOKEN=”session token”

Obviously, you would have to input your login credentials in the above command without the quotes. Once they are input correctly, we are ready to use specific AWS services and configure them using command line.

The above method of providing the access key, secret access key and session token is for a temporary login to the AWS console. There is another method using which we can permanently save the environment variables in our local system and then login using Command Prompt whenever we want. Command ‘aws configure’ is used for that purpose.

When we run the command ‘aws configure’, it will ask all the 3 login credentials mentioned above and the region as well. Once we input the values, it will automatically save a file in our system. Typical path for that file will be PC/C:/Users/Hostname/.aws

Environment Credentials file

Config file, as shown above, will have the region that we input and the credentials will contain the login keys that we input.

Alternatively, we can also use Windows PowerShell to access AWS. The important thing to note here is that the login credentials are input on PowerShell using different set of commands as below:

Set-Item Env:AWS_ACCESS_KEY_ID “access key”
Set-Item Env:AWS_SECRET_ACCESS_KEY “secret access key”
Set-Item Env:AWS_SESSION_TOKEN “session token”

PowerShell interface

Once the environment variables(login credentials) are input in Windows PowerShell as above, we can start using AWS services using commands from it.

So, to conclude this article, I would like to reiterate that we have two methods to login to AWS console using command line interface. One is through Command Prompt and the other is through Windows PowerShell.

Thanks to Dilip for the inputs.

--

--