# Day 29: IAM Programmatic access and AWS CLI

Hello Everyone!

In the last article, we understood load balancers. Today we will see an interesting way to access AWS services.

**IAM Programmatic access**

In order to access your AWS account from a terminal or system, you can use AWS Access keys and AWS Secret Access keys.

**AWS CLI**

The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

The AWS CLI v2 offers several new features including improved installers, new configuration options such as AWS IAM Identity Center (successor to AWS SSO), and various interactive features.

**Tasks -**

**Task 1) Create AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY from AWS Console.**

Open the AWS console, Click on your profile name &gt; Security Credential

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693307441515/44bdf87d-f52e-4370-9259-162a0485749a.png align="center")

Scroll down to Access Keys &gt; Select Create Access Key

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693307572633/b5b30926-7879-4440-895f-3316a890bf0f.png align="center")

The Access key has been created. Download the .csv file to your desktop

**Task 2) Set up and install AWS CLI and configure your account credentials.**

I’m using Windows so to download AWS CLI on Windows run in Powershell

```powershell
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693307723068/875dc9b1-0c6f-4c9c-a588-4ed0c8e8808e.png align="center")

AWS CLI has been installed on your device.

Configure your account credentials by using:

```powershell
aws configure
```

Give the Access Key ID, and Secret Access Key that you’ve downloaded in .csv file and pass the region name and output format as given below.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693307831273/425e9dc8-be3e-453b-956e-f3be18d9125d.png align="center")

You can check if the AWS CLI is working or not. To check the S3 bucket details:

```powershell
aws s3 ls
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693307905629/8af9b3da-f6c5-4b0e-af32-2a1c9c2eeb12.png align="center")

**Troubleshooting**

As a part of the installation of AWS CLI on my Windows machine, I encountered an error that even after installation AWS CLI was not working. I searched on the web and found one solution on stack overflow.

```powershell
$command = "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
Invoke-Expression $command
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -Outfile C:\AWSCLIV2.msi
$arguments = "/i `"C:\AWSCLIV2.msi`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
aws --version
```

[PowerShell does not recognize AWS CLI installed in the same script](https://stackoverflow.com/questions/62973120/powershell-does-not-recognize-aws-cli-installed-in-the-same-script/62973327#62973327?newreg=8a3acdb2c189402e8f2d6e6845e0eccf)

---

Thanks for reading ;)
