How to use AWSCLI to download S3 object
Shubham Kumar
Posted on May 18, 2023
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:
- Create IAM user
- Configure AWSCLI in your local
- Use awscli to download it.
Implementation:
Step 1: IAM user creation
- Login to AWS console, go to the IAM service and create one user.
- Make sure to add S3 specific permission with this user. For your test purpose you can give AWS managed S3FullAccess permission.
- 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
- --> scroll down and under access key section click on create access key.
- --> 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>
If you want to download complete folder, use the following command.
aws s3 sync <s3://bucket-name>/<folder_name> <local/path>
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!
Posted on May 18, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.