Amazon S3 Command Line Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 41: Line 41:
     ]
     ]
  }
  }
To return specific attributes:
  aws s3api list-objects --bucket ''bucket-name'' --query 'Contents[].{Key: Key}'

Revision as of 22:00, 17 March 2019

Internal

List all Buckets

aws s3api list-buckets --query "Buckets[].Name"

List Objects in a Bucket

aws s3api list-objects --bucket bucket-name

Example:

aws s3api list-objects --bucket thalarion-release-pipeline

{
   "Contents": [
       {
           "LastModified": "2019-03-17T20:26:01.000Z",
           "ETag": "\"901056c645f90d6aa4edf0a98720a2a3\"",
           "StorageClass": "STANDARD",
           "Key": "thalarion/BuildspecP/Uew1P4u",
           "Owner": {
               "DisplayName": "aws-admin-dv1",
               "ID": "ca887c9c7e3f48cf499d19b960e5ee436cb4ce34e035463003b51c21ea6b4499"
           },
           "Size": 395
       },
       {
           "LastModified": "2019-03-17T20:25:40.000Z",
           "ETag": "\"bbaa592d88d0d5024c776eed46fb6370-1\"",
           "StorageClass": "STANDARD",
           "Key": "thalarion/Repository/5CfRwn8.zip",
           "Owner": {
               "DisplayName": "aws-admin-dv1",
               "ID": "1f887c9c7e3f48cf499d195960e5ee436cb4ce3be035463003b51c21ea6b4493"
           },
           "Size": 3156
       }
   ]
}

To return specific attributes:

 aws s3api list-objects --bucket bucket-name --query 'Contents[].{Key: Key}'