Wednesday, November 8, 2017

What is AWS command line interface ( AWS CLI )

Amazon CLI: - Amazon CLI is an open source top of AWS SDK for python that provides us an interface for AWS resources with minimal configuration.

AWS CLI can perform all task, the functionality provided by the AWS Management Console.
Either you can use Windows command or Powershell to run commands.

Install AWS CLI on Microsoft Windows: 
 1- Run the MSI installer





















Click Next and follow the below steps.






















Click on Install





















Click on Finish





















AWS CLI installation has done successfully.

Step 2- Adding the AWS CLI Executable to your Command Line Path
After AWS CLI installation, we need to set the environment variable for AWS CLI. Let's follow steps below.
  1. Go to System Properties
  2. Click on Environment Variables































      3.  Select Path and choose Edit





























        4- Add ";C:\Program Files\Amazon\AWSCLI\" in the end of line and click 3 time OK.





























Step 3- Validate AWS CLI Installation:
To Validate AWS CLI installation run following commands.
PS C:\Users\ISHIR Admin> aws --version
aws-cli/1.11.182 Python/2.7.9 Windows/7 botocore/1.7.40
If the installation goes well you will get AWS CLI version details.
Step 4- Configure AWS Credentials
AWS CLI can be used either for storing Access Key and secret key or we can define access and secret key in the script. 
Here, I am going to demonstrate how to setup AWS credentials.

  1. Open Windows command prompt or PowerShell
  2. Enter command "aws configure"and hit enter button
  3. Enter Access Key and Secret Key when prompt

PS C:\Users\Amar> aws configure
AWS Access Key ID [None]: AKIAJRH4767SE3YKCR2A
AWS Secret Access Key [None]: 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
Default region name [None]: us-east-1
Default output format [None]: Amar
PS C:\Users\Amar>

Let's validate Stored Credentials: And you will see output like below
PS C:\Users\ishir> aws configure
AWS Access Key ID [****************CR2A]:
AWS Secret Access Key [****************e390]:
Default region name [us-east-1]:
Default output format [Amar]:
PS C:\Users\ishir>

Let's Try to access S3 bucket 
PS C:\Users\ishir> aws s3 ls
2017-11-06 18:17:17 aamars3
2017-11-06 18:08:32 vasus3
In the above output, I have two buckets name aamars3 and vasus3. I am able to see my buckets that mean AWS credentials working as expected.

AWS CLI installation and configuration part completed successfully.



2 comments: