Setup AWS Credentials
Tags: aws, webdev, beginners
Published: 2023-03-21 02:11:24

First, we need to create an IAM user with programmatic access. 
Let's get into the AWS Management Console and search for IAM. Go to the IAM and click "Add User" button.

![Add User](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7kkrjuyd4ljih7v762q.png)

Provide a username and click next and next. If you want to add any tags, you can add them here and click create. Now the user will be created. 

![User Created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4liumr56p9c1w1ynnv6.png)

Click the user. You'll see the permission tab. For our application to access the S3 storage, we need to provide this user with S3 permission. To do that, Click on the Add permission button and 
choose the "Attach Policies Directly" option. Now choose "**AmazonS3FullAccess**" and click Next. Now review the policy and press Add Permission. The permission should be added now to the user.


![Add Permission Button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ao24gyybiokze8bfpo5t.png)

![s3 Access Chosen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thsloslz3fu5qfukt95b.png)

![Permission List](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onurufrxyluqq9c9lfl3.png)


Now it's time to configure the IAM user credentials on our pc. To do that, we need to create access key and secret for the user we created just now.

Go to the "Security Credentials" inside the IAM user. Click the "**Create access key**" button to create keys. 

![Create Access Key Button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kph9j2t4b6hpkg6sofm6.png)

Now choose the "Application running outside AWS" option and click next.  Add any description tag value if you want and press "Create access key"

You can see your access key in the console now. You can download the secrets in a CSV file by clicking "Download .csv file" at the bottom.

![Download CSV File](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyi7bhyypncumrtuy4u7.png)

That's it. We have created the IAM user, provided the S3 permission, and created the access keys to access S3 from our application. Let's go and configure the credentials on our pc.

To configure the AWS Credentials, the latest AWS Cli must be installed on your machine. You can download the Cli on the official AWS website [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

To make sure the AWS Cli is installed on your machine, run the below command in your command prompt.

`aws --version`

The response should be like this below except the version number might be different.

![AWS Version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejejfez3e1wp7aald6ex.png)

Now run the below command,

`aws configure`

The command prompt will ask for the access key, secret key, default regions, and output format. You can find the access key and secret key in the CSV file you downloaded just now. Provide the same. 
For the default region, I'm providing us-east-2 and "json" as the default output format. But you can provide whatever region you're gonna use for other AWS services. 

![AWS Cred Setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/093p4fia6bhydwo30p82.png)