How To Download Folder From AWS S3 CLI & UI ?
Last Updated :
05 Jul, 2024
The AWS Simple Storage Service (S3) is a cloud service provided by Amazon Web Services (AWS) to store your data securely. There are different approaches to storing and retrieving data from AWS S3; one of them is by using AWS CLI provided by Amazon Web Services. In this article, we will provide you with step-by-step instructions on how to use AWS CLI download folders from Amazon S3 securely.
What Is Amazon S3?
Amazon S3 is a simple storage service provided by Amazon Web Services. It is highly durable and provides security and scalability to any kind of data. This data is stored as objects within resources called buckets.
Downloading Folder From Amazon S3
Create an AWS account and an IAM Role. Identity and Access Management (IAM) helps you secure the services you want to use by providing authentication and authorization as per your team's requirements. Use the IAM role for accessing the S3 bucket data instead of directly using your main or root account.
Step 1: Create An Amazon S3 Bucket

Step 2: Configure The Amazon S3 Bucket
- Select an AWS Region and enter a unique bucket name to create a new bucket.


Step 3: Create Folder On Your Amazon S3 bucket
- Click on upload and create a new folder on the S3 bucket.
- On successful creation, you'll see the folder in your bucket's object list.
.png)
Step 4: Add files To Your Folder
- Add few files to your folder by clicking on the upload button.
- You can see 3 files are added below.

Step 4: Configure AWS CLI
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

- Verify successful installation by checking the version of aws using below command.
aws --version

- Configure your IAM user on the AWS CLI using below command
aws configure

- Execute below command to list the buckets.
aws s3 ls

Step 5: Download Folder From Amazon S3
Download Entire S3 bucket
- Execute below command to download all data on your S3 bucket. This command will download your S3 bucket data on the current location.
aws s3 sync s3://<bucket_name> .

- We had one folder on the S3 bucket. Check if the folder is downloaded at the current location.
- List the files under the downloaded folder to verify if all files are downloaded successfully.

Download A Specific Folder From The Amazon S3 bucket
- Add a new folder to the mygfgbucket on AWS S3.

- Add files to this new folder - NEW_GFG_FOLDER.

- Execute below command to download NEW_GFG_FOLDER on the current location.
aws s3 sync s3://<bucket_name>/<folder_name> .

- As you can see below, files from the folder NEW_GFG_FOLDER are directly downloaded on the current location.

- Now let's download this folder into a new folder instead of directly downloading the files inside.
- Execute below command to download NEW_GFG_FOLDER into new_downloaded_folder.
- You can name the new folder as per your requirement. It doesn't have to match the original folder.
aws s3 sync s3://<bucket_name>/<folder_name> <download_path>
.png)
- Verify if new folder is created on the current location with the provided name in the command.

- Verify if the content matches with the one available on the AWS S3 bucket folder.

In this way, you can downloaded the entire S3 bucket or specific folders from the S3 bucket using AWS CLI.
Similar Reads
How To Upload And Download Files From AWS S3 Using Python? Pre-requisite: AWS and S3Amazon Web Services (AWS) offers on-demand cloud services which means it only charges on the services we use (pay-as-you-go pricing). AWS S3 is a cloud storage service from AWS. S3 stands for 'Simple Storage Service. It is scalable, cost-effective, simple, and secure. We gen
3 min read
How to Download a File from a Server with SSH / SCP? Secure Copy Protocol (SCP) is a secure file transfer protocol that allows you to transfer files between computers over a secure connection. It is based on the Secure Shell (SSH) protocol and is commonly used to transfer files between servers and local computers. One of the main benefits of using SCP
3 min read
How to Delete S3 Bucket from AWS CLI ? Amazon Simple Storage Service (S3) is a versatile, scalable object storage service given by Amazon Web Services (AWS). It is intended to store and recover any amount of data from any place on the web, offering developers and IT teams a durable, dependable solution for their storage needs. S3 is gene
6 min read
How to Download a File Using Node.js? Downloading files from the internet is a common task in many Node.js applications, whether it's fetching images, videos, documents, or any other type of file. In this article, we'll explore various methods for downloading files using Node.js, ranging from built-in modules to external libraries.Using
3 min read
How to Use AWS CLI in Docker Container ? The AWS Command Line Interface (CLI) is a powerful tool that allows users to interact with AWS services directly from the terminal. Integrating AWS CLI within a Docker container can significantly streamline workflows, especially for development and deployment processes that rely on cloud infrastruct
4 min read
Download Files From Cloud Storage in Firebase Cloud storage has become an integral part of how individuals and businesses store and manage their data. With the ability to access files from anywhere at any time and cloud storage services offer convenience and flexibility. However, understanding how to efficiently and securely download files from
3 min read