Skip to content

s3 list-objects

List all objects of S3 bucket in the argument

Description

List all objects of S3 bucket in the argument

Synopsis

s3 list-objects
    [--site <site>]
    [--region <region>]
    <bucket>
    [--prefix <prefix>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

region - (string)

     AWS region for the service
     Example: --region "region-1"
     Default: _None_      Attributes: optional

bucket - (string)

     S3 bucket from which object keys are to be listed
     Example: "bucket-1"
     Default: _None_      Attributes: required

prefix - (string)

     Keys which start with the prefix argument
     Example: --prefix "maira"
     Default: _None_      Attributes: optional

Examples

Input:

x = ! s3 list-objects "test1"
Output:
{
  "objects": [
    {
      "name": "a/",
      "createdTime": "2022-09-19T13:04:08Z",
      "size": "0"
    },
    {
      "name": "maira123/",
      "createdTime": "2022-09-20T05:31:12Z",
      "size": "0"
    },
    {
      "name": "maira123/myfile.txt",
      "createdTime": "2022-09-20T16:21:35Z",
      "size": "16"
    },
    {
      "name": "maira123/test/",
      "createdTime": "2022-09-20T16:17:11Z",
      "size": "0"
    },
    {
      "name": "maira456/",
      "createdTime": "2022-09-20T05:31:24Z",
      "size": "0"
    }
  ]
}
Input:
! s3 list-objects "test1" --prefix "m"
Output:
{
  "objects": [
    {
      "name": "maira123/",
      "createdTime": "2022-09-20T05:31:12Z",
      "size": "0"
    },
    {
      "name": "maira123/myfile.txt",
      "createdTime": "2022-09-20T16:21:35Z",
      "size": "16"
    },
    {
      "name": "maira123/test/",
      "createdTime": "2022-09-20T16:17:11Z",
      "size": "0"
    },
    {
      "name": "maira456/",
      "createdTime": "2022-09-20T05:31:24Z",
      "size": "0"
    }
  ]
}
Input:
! s3 list-objects "test1"
Output:
CREATION_TIME                   SIZE                   NAME
2022-09-19 13:04:08 +0000 UTC      0                     a/
2022-09-20 05:31:12 +0000 UTC      0              maira123/
2022-09-20 16:21:35 +0000 UTC     16    maira123/myfile.txt
2022-09-20 16:17:11 +0000 UTC      0         maira123/test/
2022-09-20 05:31:24 +0000 UTC      0              maira456/
Input:
! s3 list-objects "test1" --prefix "m"
Output:
CREATION_TIME                   SIZE                   NAME
2022-09-20 05:31:12 +0000 UTC      0              maira123/
2022-09-20 16:21:35 +0000 UTC     16    maira123/myfile.txt
2022-09-20 16:17:11 +0000 UTC      0         maira123/test/
2022-09-20 05:31:24 +0000 UTC      0              maira456/

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "s3"
Service Instance
Namespace
Object Type "bucket"
Object ID bucket

Please see Access Control for details.