AWS CLI Commands S3 management
AWS S3 is the ideal solution for managing static files. Widely s3 buckets are used for backing up files , websites , web-apps and even mobile apps . Here is a quick guide to getting started with AWS Command-line interface from very installation to manage your buckets, copy files, sync folders and more
Prerequisites
- AWS Account , if you dont have one , start from here
- A Linux server , VPS is enough you can start one with AWS or DigitalOcean
Install AWS CLI on your server
Download installer :-
]# curl ‘https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o ‘awscliv2.zip’
Unzip archive :-
]# unzip awscliv2.zip
Install executable :-
]# ./aws/install
Verify AWS CLI Installation
]# aws — version
aws-cli/2.0.57 Python/3.7.3 Linux/5.4.0–42-generic exe/x86_64.ubuntu.20
Now Configure with your AWS Credentials
First create an IAM User from inside your AWS console , This guide will help
Once you are set with your AWS Access ID and Secret Proceed to next step
]# aws configure
This will prompt you to supply Access ID and Secret , supply both and feel free to leave all rest questions for now
List all buckets inside your account
]# aws s3 ls
this will list all your buckets
List all folders inside an S3 bucket
]# aws s3 ls s3://bucketname
Create a Folder inside an S3 bucket
]# aws s3api put-object — bucket bucket_name — key folder_name/
List all contents inside an S3 bucket Recursively
]# aws s3 ls s3://bucket_name — recursive
To make this readable
]# aws s3 ls s3://bucket_name — recursive — human-readable — summarise
Copy local file to S3 Bucket
]# aws s3 cp file_name.txt s3://bucket_name/folder_name/file_name.txt
Copy a Folder to S3 Bucket
]# aws s3 sync ./folder_name s3://bucket_name/folder_name/
This is not a complete reference , if you got questions , reach us directly on our website or on twitter