AWS CLI helps us to connect to AWS infrastructure. With the help of CLI, we can manage AWS resources very easily. You can list AWS S3 buckets or even create S3 bucket from AWS CLI itself or you can download file too. The se cases are limitless, this is just few of the example.
Let’s get started on How to install AWS CLI on Windows, If you are looking for installation in MAC, You can jump here to Install AWS CLI on MAC skipping windows installation.
I assume you already created your AWS Account, If not, Please Create your AWS account. AWS offer various free tiers to get started with but I will recommend you to check the pricing section in order to be always on free tier if you are beginner.
Install AWS CLI on windows
To install AWS CLI, We have to download setup file. AWS documentation has provided the link to download the setup file. Download AWS CLI MSI File.
Expand the windows section. You can find the download link given on the page. You can alternatively install with the commands but I will recommend you to follow this easy method to get started with. Once downloaded, Install the MSI file & finish the setup.
Before we connect the CLI to your AWS Account, lets check whether installation is properly succeeded as expected or not. Open your command prompt from your start menu, The easy way to open command prompt in Windows is to press Windows Button then Press R, this will open the Run command dialog box, now type cmd in input box & hit Enter. You will see command prompt pops up.
On your command prompt type following command (aws)
This will start showing list of argument supported such as aws help command. Please find below image to check the command prompt output.
Congratulations! You just finished one step in checklist. Now lets move ahead together for creating IAM user.
Create IAM user to Access AWS CLI
AWS IAM is Identity & Access management service provided by AWS. Whenever we want to provide access, security credentials to different services, resources, users or programmatic access, We will be using AWS IAM service. AWS IAM is global service. Please stay connected as we will be soon publishing the Beginners guide on AWS IAM Service.
Open AWS IAM from AWS console. Once you open the IAM Dashboard, Navigate to Access Management -> Users. We have to create one user in order to give our AWS CLI access to our AWS resources. Click on Add Users to create user in IAM.
Please provide User name for the AWS CLI Installation. As a best practice give proper naming to help you identify later what this user do. Keep unchecking the Enable console access as we are not creating any user for console access. We are only using this to give access to our AWS CLI to connect to AWS resource & Click Next.
Next step is to attach policies. Permission in AWS are managed by policies. We will be covering Policy section in Beginners guide on AWS IAM Service once we published yet. Click on Attach Policies directly & click Next.
Please Attached AWS S3 Full access policy Please find below image for more info. For demo purpose to test AWS CLI connection with AWS we will be creating S3 bucket and for that we requires AWS S3 full access policy to be attached to AWS IAM user given the programmatic access. Click Next & Create User.
The AWS IAM user is successfully created. Remember, We have given programmatic access to this user, So we will be requiring AWS Access Key & AWS Secret key to connect with this user. This article follows the new interface of AWS. To find your Access Key & Secret key, Please Go to Access Management -> Users & Select the user you just created. Open Security Credentials Tab and Scroll down to Access Keys Section.
Click on Create access key. Once you created your access key, you can see your credentials for the user. This will also containing secret key too.
Once you obtained the credentials, Store this at secure place. You cannot get secret again if you lost it & you have to regenerate it. It means all the apps or CLI which are working on it has to be updated once again. Save the future pain & keep it in your safe. Also make sure you are not sharing this with others as this will directly give other people access to your AWS Account programmatically.
To configure AWS Credentials in your CLI, We will be using AWS Configure command. Type below command in your command prompt.
This will ask you Access Key ID & Secret key ID. Copy paste the access & secret key which you just downloaded above. You can leave default region as blank or can provide any such as eu-west-2. Keep default format as as blank for now.
Alright, Lets test it. We will connect to AWS S3 Bucket. Lets list the buckets in your AWS Account, if you don’t have any bucket, you can login to AWS Console & create few buckets & then run following command. This will list the buckets in your AWS S3 –
aws s3 ls
Awesome, Your installation is successful, I hope you have enjoyed this article, Good Luck!