SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for AWS Amazon Web Services, Redshift, AWS Lambda Functions, S3 Buckets, VPC, EC2, IAM

AWS CLI Installation and Configuration on Windows


Recently I had downloaded AWS CLI for Windows and installed it on my development computer. Later I had to configure it for my profile to access my Amazon Web Services AWS cloud resources programmatically and pass proxy preventing my access to cloud. Although you can find required resources on Amazon.com Documents portal, it is also beneficial for me to keep my notes on my website in case an emergency to reach easily.

Download AWS CLI (AWS Command Line Interface)

For Windows, AWS developers can download AWS Command Line Interface AWS CLI using download links provided at docs.aws.amazon.com

A direct download link for AWS CLI MSI for Windows 64-bit is here


Install AWS CLI using MSI Installer File

After I download the 64-bit msi file for AWS CLI setup, I launched Command Prompt as Administrator.
Then you can execute the msi installer program after you navigate to the file folder where the setup program exists.


Confirm AWS CLI Installation

After the installation is completed, AWS programmer can validate the setup using following command

C:\>aws --version
Code

If you get a return message similar to below, then the setup is completed successfully

aws-cli/1.16.102 Python/3.6.0 Windows/10 botocore/1.12.92
Code

If you get a message indicating aws is not recognized, then we have to add the installation path of the AWS CLI to the system environment variables and restart the Command Prompt


Add AWS CLI Instalation Path to Environment Variables

If executing aws command on Command Prompt failed since the command is not recognized, you can check if AWS CLI installation path is declared in Environment Variables

Again, the guide for this configuration also exists on AWS Docs. Also experienced developers or system admins are very familiar with this configuration.

Version 1 setup program installs AWS CLI to path where I found the AWS.exe file: C:\Program Files\Amazon\AWSCLI\bin

For version 2 of the Command Line Interface software, the default installation path is: C:\Program Files\Amazon\AWSCLIV2\

You can launch the Control Panel with administrative rights and run Edit the system environment variables (Advanced System Settings) program. Go to Environment Variables using the button at the bottom of the screen

AWS CLI settings on System Control Panel

When the variables are listed, find and highlight Path environment variable and press Edit button.

edit path environment variable for AWS CLI

Add the AWS CLI path as a new list item of the Path variable.

add AWS CLI path to System Environment Variables

After Path declaration, close Command Prompt and launch once more. Now the developers should be able to execute above "aws --version" command successfully.

aws version command to test AWS CLI installation


AWS CLI Configuration for Profile

I later required to get AWS IAM policies for a Lambda function. When I execute following command on AWS CLI tool, I faced below error message:
Unable to locate credentials. You can configure credentials by running "aws configure".

aws configure to configure credentials for AWS CLI tool

So the solution of the problem is obvious within the message itself :)
Please also check following URL for official documentation.

So I executed aws configure command and provided each information one by one when it is asked at command prompt
I copied down the sample values (Access Key Id and Secret Access Key) which should be really kept in a secret place and should not be published as below.
So be sure these are dummy values.

aws configure
AWS Access Key ID [None]: aWsAcCeSsKeYiD
AWS Secret Access Key [None]: aWsSecReTaCceSsKeY
Default region name [None]: eu-central-1
Default output format [None]: json
Code

AWS Access Key ID and AWS Secret Key for CLI


Configure HTTP and HTTPS Proxy Settings

Luckily when I executed the AWS command, this time I experienced Failed to connect to proxy URL: "https://127.0.0.1:8888" error message showing that I had to suffer a little bit more :)

So I had to complete the HTTP/HTTPS Proxy configuration which is also described at Amazon.com

Since I know the proxy address and port number for my case, I executed following commands on Command Prompt

set HTTP_PROXY=http://WindowsUserName:Password@ProxyURL:Port
Code

If you do not provide username and password, although the proxy is successfully identified this time authentication errors can occur like:
Could not connect to the endpoint URL: "https://lambda.eu-central-1.amazonaws.com/....

Please provide the same for HTTPS as well like

set HTTPS_PROXY=http://WindowsUserName:Password@ProxyURL:Port
Code

After the proxy URL and authenticating to pointed proxy is completed, I could successfully reach to AWS Lambda endpoints

If cloud application developers want to use AWS CLI tool for accessing Amazon S3 buckets and bucket folders for transferring data files between your servers and AWS, please refer to AWS tutorial at Upload File to Amazon S3 Bucket using AWS CLI Command Line Interface.



AWS


Copyright © 2004 - 2024 Eralper YILMAZ. All rights reserved.