How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

We have three steps in this article:

  1. Create an AWS IM User.
  2. Install and Configure the AWS CLI.
  3. Configure Amazon S3 using AWS CLI.

What is AWS IAM User?

AWS Identity and Access Management (IAM) enables you to securely control access to AWS services and resources for your users. Using IAM, you can create and manage AWS users and groups and use permissions to allow and deny their permissions to AWS resources.

Create an AWS IAM User

In this step, we will create a new user account with administrative permission,

  • Login to AWS console and enter email and password.
  • Go to services and click on IAM from Security, Identity & compliance or type IAM in textbox.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • From the AWS Identity and Access Management dashboard, click on Users on the left side.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • Click Add User button.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • Enter the User name in text box and select Programmatic access for Access type and click on Permissions button. 

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • On set permissions, click Attach existing policies directly and select AdministratorAccess policy and click Next button.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • Next you can Add tags which is optional and click Review button. 

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI
  • Review all the settings and click Create user.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • User is create with Access key ID and Secret access key. You can download .csv file.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

Install and Configure AWS CLI

So we are done with IAM user, now let's install the AWS Command Line Interface (CLI).

What is AWS CLI?

The AWS Command Line Interface (AWS CLI) is an Amazon Web Services tool that enables developers to control Amazon public cloud services by typing commands on a specified line. AWS' version of a command-line interface is one of several methods a developer can use to create and manage AWS tools.

Follow these instructions to install AWS CLI,

  • Download and run the Windows installer (64-bit, 32-bit).
  • Open a command prompt by pressing the Windows Key + r to open the run box and enter cmd and press the OK button.

    How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

  • Type aws configure and hit enter, now provide AWS Access Key ID, AWS Secret Access Key, Default region name and Default output format like this.
    • AWS Access Key ID [None]: enter the Access Key Id from the credentials.csv file you downloaded.
    • AWS Secret Access Key [None]: enter the Secret Access Key from the credentials.csv file you downloaded.
    • Default region name [None]: enter us-east-1
    • Default output format [None]: enter json

How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI
 

Configure Amazon S3 using AWS CLI 

In this step you will learn, how to create S3 Bucket, how to upload file from local to S3 bucket, how to download a file from S3 bucket and how to delete a file from S3 bucket.

What is Amazon S3?

Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites.

Create a new bucket

Bucket name should be globally unique, two different AWS users can not have same bucket name.

Type this command in CLI:

How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

Upload a file in bucket

To upload a file from local to s3, you need to provide local file path and s3 bucket name.

How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

Download file from S3 Bucket

To download a file from s3 bucket, provide following command along with bucket name and file name and path where you want to download file.

How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

Delete a file from S3 Bucket

To delete a file from S3 bucket, provide the following command along with bucket name and file name.

How To Setup IAM User And AWS CLI And Upload Download Files Using S3 Bucket Using AWS CLI

Conclusion

In this article, we have learned how to create an IAM user and provide permissions and how to install and setup AWS CLI and how to create S3 bucket and upload, download and delete file from S3 bucket using AWS CLI.


Similar Articles