Skip to content

S3 Listing

In order to list files in a S3 bucket you need to execute connect list s3 followed by two mandatory parameters:

  • --bucket then the S3 bucket name
  • --region then the region where the bucket is located

You can also provide an optional folder with:

  • -d, --folder then the folder

Depending on the type of authentication you need to either use --access-key and --secret-access-key for key based authentication or use the IAM Role Assigned to the Instance (if the server is running on AWS).

To use the Access Key and Secret Access Key authentication you need to provide:

  • --access-key then the Access Key
  • --secret-access-key then the Secret Access Key

For example:

Terminal window
$ connect list s3 --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM4
2025/05/22 14:24:07 INFO Listing s3://my-s3-bucket/
d--------- 0 Jan 01 00:00 folder1/
-rw-rw-r-- 1024 Sep 15 21:04 file1.txt
-rw-rw-r-- 1024 Sep 15 21:04 file2.txt
-rw-rw-r-- 1024 Sep 15 21:04 file3.txt

Access Key and Secret Access Key with AWS CONFIGURE

Section titled “Access Key and Secret Access Key with AWS CONFIGURE”

You can use aws configure. This command prompts you to enter the Access Key ID and Secret Access Key, which are then stored in your AWS CLI configuration file ~/.aws/credentials.

For example:

Terminal window
$ aws configure
AWS Access Key ID [None]: AKIA4YINCR26KRN42IDA
AWS Secret Access Key [None]: PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM4
Default region name [None]: eu-central-1
Default output format [None]:

Then you can omit providing the credentials as they will be obtained from the configuration.

Terminal window
$ connect list s3 --bucket my-s3-bucket --region eu-central-1
2025/05/22 14:25:01 INFO Listing s3://my-s3-bucket/
d--------- 0 Jan 01 00:00 folder1/
-rw-rw-r-- 1024 Sep 15 21:04 file1.txt
-rw-rw-r-- 1024 Sep 15 21:04 file2.txt
-rw-rw-r-- 1024 Sep 15 21:04 file3.txt

If your instance is running in AWS the temporary credentials will be automatically retrieved from the instance metadata (unless you have overridden it with aws configure). You don’t have to specify the credentials then.

For example:

Terminal window
$ connect list s3 --bucket my-s3-bucket --region eu-central-1
2025/05/22 14:25:17 INFO Listing s3://my-s3-bucket/
d--------- 0 Jan 01 00:00 folder1/
-rw-rw-r-- 1024 Sep 15 21:04 file1.txt
-rw-rw-r-- 1024 Sep 15 21:04 file2.txt
-rw-rw-r-- 1024 Sep 15 21:04 file3.txt

You can also specify the optional target folder to list with:

  • -d, --folder remote folder name

If you don’t specify the folder, the command will list root folder of the bucket.

For example:

Terminal window
$ connect list s3 --bucket my-s3-bucket --region eu-central-1 -d folder1
2025/05/22 14:28:56 INFO Listing s3://my-s3-bucket/folder1/
-rw-rw-r-- 1024 Sep 15 21:11 folder1/file1.txt
-rw-rw-r-- 1024 Sep 15 21:11 folder1/file2.txt
-rw-rw-r-- 1024 Sep 15 21:11 folder1/file3.txt

To connect to an S3-compatible service like Minio you need to provide the URL using:

  • --custom-url and then the S3 instance URL

For example:

Terminal window
$ connect list s3 --bucket my-s3-bucket --region auto --custom-url https://my-s3-host.com --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM4
2025/05/22 14:30:28 INFO Listing s3://my-s3-bucket/
d--------- 0 Jan 01 00:00 folder1/
-rw-rw-r-- 1024 Sep 15 21:04 file1.txt
-rw-rw-r-- 1024 Sep 15 21:04 file2.txt
-rw-rw-r-- 1024 Sep 15 21:04 file3.txt
Terminal window
Usage:
connect list s3 [command] [flags]
Flags:
--access-key string S3 access key
--bucket string S3 bucket
--custom-url string S3 custom URL
--region string S3 region
--secret-access-key string S3 secret access key
Global Flags:
-d, --folder string Folder to list files
--godebug Turns on debug mode
--help Prints help for the command
--log-format string Log output format: text|json (default "text")
--no-color Do not use colors in logs
--quiet Makes no output

Please check here for information on the possible errors.