amazon-s3 Getting started with amazon-s3 Installation of AWS CLI for accessing S3


Example

Installing aws cli in Ubuntu / Debian Instance

sudo apt-get install -y python-dev python-pip
sudo pip install awscli
aws --version
aws configure

Installing aws cli using python

Using pip you can install aws cli in windows, OS X and Linux

sudo pip install awscli

Configuring the AWS Command Line Interface

This section explains how to configure settings that the AWS Command Line Interface uses when interacting with AWS, such as your security credentials and the default region.

$ aws configure
AWS Access Key ID [None]: <Your access key >
AWS Secret Access Key [None]: <Your secret key>
Default region name [None]: us-west-2
Default output format [None]: json

Get the Access key and Secret key from the account page in AWS

Creating Buckets

Use the aws s3 mb command to create a new bucket. Bucket names must be unique and should be DNS compliant. Bucket names can contain lowercase letters, numbers, hyphens and periods

aws s3 mb s3://bucket-name

Removing Buckets

To remove a bucket, use the aws s3 rb command.By default bucket should be empty.

aws s3 rb s3://bucket-name

To remove a non-empty bucket, you need to include the --force option.

aws s3 rb s3://bucket-name --force

Listing Buckets

To list all buckets or their contents, use the aws s3 ls command

aws s3 ls
aws s3 ls s3://bucket-name

The following command lists the objects in bucket-name/path

aws s3 ls s3://bucket-name/path

Synchronize files between local file system and S3

aws s3 sync . s3://my-bucket/path 

It will upload all the files in the current directory to S3. To download the files from S3 to the current directory execute

aws s3 sync s3://my-bucket/path .