hide's memo
26 Oct, 2025

Create an S3 on MinIO and operate it using AWS CLI

[Japanese(日本語)]

Cteate an S3 Bucket on MinIO and operate it using AWS CLI.

  • Set MinIO user, role using mc command(MinIO Client), because now MinIO Community Editon can’t allow us to set user, role using WEB Console.
  • No root account required.

■1. Install MinIO

mkdir ~/minio
cd ~/minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod u+x mc
chmod u+x minio
echo "export PATH=$PATH:~/minio" >> ~/.bashrc
echo "export MINIO_ROOT_USER=minioadmin" >> ~/.bashrc
echo "export MINIO_ROOT_PASSWORD=minioadmin123" >> ~/.bashrc
source ~/.bashrc
mkdir ~/minio/minio_data

 

 

■2. Start MinIO

Start MinIO in background and set alias, user.

minio server ~/minio/minio_data &
mc alias set myminio http://localhost:9000 minioadmin minioadmin123
mc admin user add myminio s3user s3password
mc admin policy attach myminio readwrite --user=s3user

 

■3. Create an S3 Bucket

mc mb myminio/my-bucket

 

■4. Install AWS CLI

cd
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
echo "export PATH=$PATH:~/aws/dist" >> ~/.bashrc
source ~/.bashrc
aws configure
aws_access_key_id = s3user
aws_secret_key_id = s3password

 

■5. Access to the S3 Bucket usiing AWS CLI

(1)upload a file to S3.

echo "test" > minio-bucket-test.txt
aws s3 cp minio-bucket-test.txt s3://my-bucket --endpoint-url http://localhost:9000

(2)Check if the file is uploaded correctly.

aws s3 ls --recursive s3://my-bucket --endpoint-url http://localhost:9000
28 May, 2022

Upload files to S3 Bucket using curl.

[日本語]

I followed the information below.
tuxfight3r/s3_upload.sh

#!/bin/bash

S3KEY="Your Acess Key"
S3SECRET="Your Access Secret"
S3BUCKET="Your Bucket Name"
S3STORAGETYPE="STANDARD"
AWSREGION="Your S3 Region"

# If you use mac OS. enable following code. 
#OS="mac"

function putS3
{
  file_path=$1
  aws_path=$2
  bucket="${S3BUCKET}"
  date=$(date -R -u)

  acl="x-amz-acl:private"
  content_type="text/plain"
  storage_type="x-amz-storage-class:${S3STORAGETYPE}"
  string="PUTnn$content_typen$daten$acln$storage_typen/$bucket$aws_path${file_path##/*/}"

  if [ $OS = "mac" ]; then
    signature=$(printf "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
  else
    signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
  fi

  curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path" 
  -H "Host: $bucket.${AWSREGION}.amazonaws.com" 
  -H "Date: $date" 
  -H "Content-Type: $content_type" 
  -H "$storage_type" 
  -H "$acl" 
  -H "Authorization: AWS ${S3KEY}:$signature" 
  "https://$bucket.${AWSREGION}.amazonaws.com$aws_path${file_path##/*/}"

}

# Upload test.txt file to /test/ folder.
putS3 test.txt /test/