aws: awscli: s3 and s3api

The post discusses using AWS CLI to request S3 service.


bash-3.2$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G1510
bash-3.2$ python --version
Python 2.7.10
bash-3.2$ aws --version
aws-cli/1.11.127 Python/2.7.10 Darwin/15.6.0 botocore/1.5.90

aws configure
AWS’s IAM(Identity and Access Management) service manages user, group and permissions. Each user granted AWS CLI permission is assigned a access key id and secret access key. aws configure can setup access key id, secret access key, and etc. In my case, the user is granted AmazonS3FullAccess permission.

bash-3.2$ aws configure
AWS Access Key ID [None]: $(access_key_id)
AWS Secret Access Key [None]: $(secrect_access_key)
Default region name [None]: 
Default output format [None]: 

s3 and s3api

  • aws s3 command provides high level s3 commands
  • aws s3api command provides low level s3 commands

list all buckets
Each data in S3 is in a bucket. The name of each bucket is globally unique for all users and regions.

bash-3.2$ aws s3 ls 
2017-01-18 14:24:52 bucket_name_01
2017-07-31 13:53:14 bucket_name_02
bash-3.2$ aws s3api list-buckets
    "Owner": {
        "DisplayName": $(DisplayName), 
        "ID": $(ID)
    "Buckets": [
            "CreationDate": "2017-01-18T06:24:52.000Z", 
            "Name": "bucket_name_01"
            "CreationDate": "2017-07-31T05:53:14.000Z", 
            "Name": "bucket_name_02"

list all objects in a bucket

bash-3.2$ aws s3api list-objects --bucket bucket_name_01
    "Contents": [
            "LastModified": "2017-07-30T20:46:02.000Z", 
            "ETag": "\"af8a4df66bd9ef2433b3f29e07fbbac4\"", 
            "StorageClass": "STANDARD", 
            "Key": "hello.txt", 
            "Owner": {
                "DisplayName": $(DisplayName), 
                "ID": $(ID)
            "Size": 12

The post discusses using aws s3 and aws s3api to send requests to AWS s3 service.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: