Skip to content

S3 Connection Testing

In order to test connection to an S3 bucket you need to execute connect test s3 followed by two mandatory parameters:

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

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 test s3 --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM4
2025/05/19 20:56:56 INFO Testing connection to s3://my-s3-bucket/
2025/05/19 20:56:56 INFO Connection successful

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 test s3 --bucket my-s3-bucket --region eu-central-1
2025/05/19 20:57:23 INFO Testing connection to s3://my-s3-bucket/
2025/05/19 20:57:24 INFO Connection successful

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 test s3 --bucket my-s3-bucket --region eu-central-1
2025/05/19 21:08:22 INFO Testing connection to s3://my-s3-bucket/
2025/05/19 21:08:23 INFO Connection successful

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 test s3 --bucket my-s3-bucket --region auto --custom-url https://my-s3-host.com --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM4
2025/05/19 21:09:11 INFO Testing connection to s3://my-s3-bucket/
2025/05/19 21:09:11 INFO Connection successful
Terminal window
Usage:
connect test 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:
--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.