DEV Community

Shubham Kumar
Shubham Kumar

Posted on • Updated on

How to use AWSCLI to download S3 object

AWS console doesn't allows to download multiple files or folder together. This is a limitation for the AWS console. But we can use awscli to get it. This is a very small doc but good to start with.

Prerequisite:

  • AWS Active Account
  • AWS CLI
  • IAM user with s3 list and get access

Steps:

  1. Create IAM user
  2. Configure AWSCLI in your local
  3. Use awscli to download it.

Implementation:
Step 1: IAM user creation

  1. Login to AWS console, go to the IAM service and create one user.
  2. Make sure to add S3 specific permission with this user. For your test purpose you can give AWS managed S3FullAccess permission.
  3. Once the user is created
  • --> click on users under the IAM page
  • --> click on the user that you created just now
  • --> click on security credentials

Image description

  • --> scroll down and under access key section click on create access key.

Image description

  • --> Save you access key and secrets key in safe place. You will not be able to find it if you missed to save.

Step 2: Configure AWSCLI

Please refer step 1 and 2 of the below mentioned doc to get the steps if you need it.

https://dev.to/shubhamkcloud/automate-application-deployment-into-lightsail-instance-28co

Step 3: Use awscli to download it

We may have different use cases of downloading a single file or a complete folder.

If you need to download a single file, use the following command.

aws s3 cp <s3://bucket-name>/<file_name> <local/path>
Enter fullscreen mode Exit fullscreen mode

If you want to download complete folder, use the following command.

aws s3 sync <s3://bucket-name>/<folder_name> <local/path>
Enter fullscreen mode Exit fullscreen mode

By using the above mentioned command you will be able to download S3 objects from your S3 bucket to your local system.

Thanks for reading. This is a very small blog but important one to save our time.

Cheers!

Top comments (0)