AWS

How to Upload Files to S3 using AWS CLI

AWS CLI can be used to manage and manipulate the AWS services using simple commands. With AWS CLI you don’t need to visit AWS individual service consoles rather use all of them on the CLI. It saves a lot of time, energy, and resources for the operating system. AWS CLI can control all the AWS services through the terminal by running commands.

Let’s Start with how to upload files to S3 using AWS CLI:

Upload Files to S3 Using AWS CLI

To upload files to an AWS S3 bucket using the AWS CLI, simply search the “CMD” in the windows search bar and click on the “Run as administrator” button to open the command prompt:

On the command prompt simply configure the AWS CLI using the following command:

aws configure

In the configuration, it will prompt you to enter the Access and Secret keys for the IAM user and then you need to enter the region and format name:

Once the AWS is configured type the following command to check the list of S3 buckets:

aws s3 ls

Running the above command will display the following output:

Then select any bucket in which you want to upload the files and check if there are files available in the bucket by using the following command:

aws s3 ls s3://upload311

This command will display the list of all files in the bucket. In this case, we don’t have any file in the upload311 bucket so it doesn’t show anything:

The following command is used to upload files in the S3 bucket:

aws s3 cp "C:\Users\Lenovo\Documents\myapp.html" s3://upload311

This command will upload the file “myapp.html” in the bucket “upload311”:

To check the list of files uploaded simply use the following command:

aws s3 ls s3://upload311

This command will display the list of files in the S3 bucket:

You have successfully uploaded files in the S3 bucket using AWS CLI:

Conclusion

To upload a file in the AWS S3 bucket simply open the Command Prompt or PowerShell and configure AWS. After the configuration, simply look for the buckets available in which you want to upload the file and use simple commands to upload files in the S3 bucket and check the list of the uploaded files in the S3 bucket.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.